Package org.hornetq.api.core.management

Examples of org.hornetq.api.core.management.ClusterConnectionControl


    }

    @Override
    protected void handleReadAttribute(String attributeName, OperationContext context, ModelNode operation) throws OperationFailedException {
        if (NODE_ID.equals(attributeName)) {
            ClusterConnectionControl control = getHornetQComponentControl(context, operation, false);
            context.getResult().set(control.getNodeID());
        } else {
            unsupportedAttribute(attributeName);
        }
    }
View Full Code Here


    }

    @Override
    protected Object handleOperation(String operationName, OperationContext context, ModelNode operation) throws OperationFailedException {
        if (GET_STATIC_CONNECTORS_AS_JSON.equals(operationName)) {
            ClusterConnectionControl control = getHornetQComponentControl(context, operation, false);
            try {
                context.getResult().set(control.getStaticConnectorsAsJSON());
            } catch (Exception e) {
                context.getFailureDescription().set(e.getLocalizedMessage());
            }
        } else if (GET_NODES.equals(operationName)) {
            ClusterConnectionControl control = getHornetQComponentControl(context, operation, false);
            try {
                Map<String, String> nodes = control.getNodes();
                final ModelNode result = context.getResult();
                result.setEmptyObject();
                for (Map.Entry<String, String> entry : nodes.entrySet()) {
                    result.get(entry.getKey()).set(entry.getValue());
                }
View Full Code Here

    }

    @Override
    protected void handleReadAttribute(String attributeName, OperationContext context, ModelNode operation) throws OperationFailedException {
        if (NODE_ID.equals(attributeName)) {
            ClusterConnectionControl control = getHornetQComponentControl(context, operation, false);
            context.getResult().set(control.getNodeID());
        } else if (TOPOLOGY.equals(attributeName)) {
            ClusterConnectionControl control = getHornetQComponentControl(context, operation, false);
            context.getResult().set(control.getTopology());
        } else {
            unsupportedAttribute(attributeName);
        }
    }
View Full Code Here

    }

    @Override
    protected Object handleOperation(String operationName, OperationContext context, ModelNode operation) throws OperationFailedException {
        if (GET_STATIC_CONNECTORS_AS_JSON.equals(operationName)) {
            ClusterConnectionControl control = getHornetQComponentControl(context, operation, false);
            try {
                context.getResult().set(control.getStaticConnectorsAsJSON());
            } catch (Exception e) {
                context.getFailureDescription().set(e.getLocalizedMessage());
            }
        } else if (GET_NODES.equals(operationName)) {
            ClusterConnectionControl control = getHornetQComponentControl(context, operation, false);
            try {
                Map<String, String> nodes = control.getNodes();
                final ModelNode result = context.getResult();
                result.setEmptyObject();
                for (Map.Entry<String, String> entry : nodes.entrySet()) {
                    result.get(entry.getKey()).set(entry.getValue());
                }
View Full Code Here

    }

    @Override
    protected void handleReadAttribute(String attributeName, OperationContext context, ModelNode operation) throws OperationFailedException {
        if (ClusterConnectionDefinition.NODE_ID.getName().equals(attributeName)) {
            ClusterConnectionControl control = getHornetQComponentControl(context, operation, false);
            context.getResult().set(control.getNodeID());
        } else if (ClusterConnectionDefinition.TOPOLOGY.getName().equals(attributeName)) {
            ClusterConnectionControl control = getHornetQComponentControl(context, operation, false);
            context.getResult().set(control.getTopology());
        } else {
            unsupportedAttribute(attributeName);
        }
    }
View Full Code Here

    }

    @Override
    protected Object handleOperation(String operationName, OperationContext context, ModelNode operation) throws OperationFailedException {
        if (ClusterConnectionDefinition.GET_STATIC_CONNECTORS_AS_JSON.equals(operationName)) {
            ClusterConnectionControl control = getHornetQComponentControl(context, operation, false);
            try {
                context.getResult().set(control.getStaticConnectorsAsJSON());
            } catch (Exception e) {
                context.getFailureDescription().set(e.getLocalizedMessage());
            }
        } else if (ClusterConnectionDefinition.GET_NODES.equals(operationName)) {
            ClusterConnectionControl control = getHornetQComponentControl(context, operation, false);
            try {
                Map<String, String> nodes = control.getNodes();
                final ModelNode result = context.getResult();
                result.setEmptyObject();
                for (Map.Entry<String, String> entry : nodes.entrySet()) {
                    result.get(entry.getKey()).set(entry.getValue());
                }
View Full Code Here

   {
      ClientSessionFactory sf = HornetQClient.createClientSessionFactory(new TransportConfiguration(InVMConnectorFactory.class.getName()));
      session = sf.createSession(false, true, true);
      session.start();

      return new ClusterConnectionControl()
      {
         private final CoreMessagingProxy proxy = new CoreMessagingProxy(session,
                                                                         ResourceNames.CORE_CLUSTER_CONNECTION + name);

         public String getAddress()
View Full Code Here

   // Public --------------------------------------------------------

   public void testNodes() throws Exception
   {
      ClusterConnectionControl clusterConnectionControl_0 = createManagementControl(clusterConnectionConfig_0.getName());
      Assert.assertTrue(clusterConnectionControl_0.isStarted());
      Map<String, String> nodes = clusterConnectionControl_0.getNodes();
      Assert.assertEquals(0, nodes.size());

      server_1.start();
      long start = System.currentTimeMillis();

      while (true)
      {
         nodes = clusterConnectionControl_0.getNodes();

         if (nodes.size() != 1 && System.currentTimeMillis() - start < 30000)
         {
            Thread.sleep(500);
         }
View Full Code Here

   public void testAttributes1() throws Exception
   {
      checkResource(ObjectNameBuilder.DEFAULT.getClusterConnectionObjectName(clusterConnectionConfig1.getName()));

      ClusterConnectionControl clusterConnectionControl = createManagementControl(clusterConnectionConfig1.getName());

      Assert.assertEquals(clusterConnectionConfig1.getName(), clusterConnectionControl.getName());
      Assert.assertEquals(clusterConnectionConfig1.getAddress(), clusterConnectionControl.getAddress());
      Assert.assertEquals(clusterConnectionConfig1.getDiscoveryGroupName(),
                          clusterConnectionControl.getDiscoveryGroupName());
      Assert.assertEquals(clusterConnectionConfig1.getRetryInterval(), clusterConnectionControl.getRetryInterval());
      Assert.assertEquals(clusterConnectionConfig1.isDuplicateDetection(),
                          clusterConnectionControl.isDuplicateDetection());
      Assert.assertEquals(clusterConnectionConfig1.isForwardWhenNoConsumers(),
                          clusterConnectionControl.isForwardWhenNoConsumers());
      Assert.assertEquals(clusterConnectionConfig1.getMaxHops(), clusterConnectionControl.getMaxHops());

      Object[] connectorPairs = clusterConnectionControl.getStaticConnectorNamePairs();
      Assert.assertEquals(1, connectorPairs.length);
      Object[] connectorPairData = (Object[])connectorPairs[0];
      Assert.assertEquals(clusterConnectionConfig1.getStaticConnectorNamePairs().get(0).a, connectorPairData[0]);
      Assert.assertEquals(clusterConnectionConfig1.getStaticConnectorNamePairs().get(0).b, connectorPairData[1]);

      String jsonString = clusterConnectionControl.getStaticConnectorNamePairsAsJSON();
      Assert.assertNotNull(jsonString);
      JSONArray array = new JSONArray(jsonString);
      Assert.assertEquals(1, array.length());
      JSONObject data = array.getJSONObject(0);
      Assert.assertEquals(clusterConnectionConfig1.getStaticConnectorNamePairs().get(0).a, data.optString("a"));
      Assert.assertEquals(clusterConnectionConfig1.getStaticConnectorNamePairs().get(0).b, data.optString("b", null));

      Assert.assertNull(clusterConnectionControl.getDiscoveryGroupName());

      Assert.assertTrue(clusterConnectionControl.isStarted());
   }
View Full Code Here

   public void testAttributes2() throws Exception
   {
      checkResource(ObjectNameBuilder.DEFAULT.getClusterConnectionObjectName(clusterConnectionConfig2.getName()));

      ClusterConnectionControl clusterConnectionControl = createManagementControl(clusterConnectionConfig2.getName());

      Assert.assertEquals(clusterConnectionConfig2.getName(), clusterConnectionControl.getName());
      Assert.assertEquals(clusterConnectionConfig2.getAddress(), clusterConnectionControl.getAddress());
      Assert.assertEquals(clusterConnectionConfig2.getDiscoveryGroupName(),
                          clusterConnectionControl.getDiscoveryGroupName());
      Assert.assertEquals(clusterConnectionConfig2.getRetryInterval(), clusterConnectionControl.getRetryInterval());
      Assert.assertEquals(clusterConnectionConfig2.isDuplicateDetection(),
                          clusterConnectionControl.isDuplicateDetection());
      Assert.assertEquals(clusterConnectionConfig2.isForwardWhenNoConsumers(),
                          clusterConnectionControl.isForwardWhenNoConsumers());
      Assert.assertEquals(clusterConnectionConfig2.getMaxHops(), clusterConnectionControl.getMaxHops());

      Object[] connectorPairs = clusterConnectionControl.getStaticConnectorNamePairs();
      Assert.assertNull(connectorPairs);

      String jsonPairs = clusterConnectionControl.getStaticConnectorNamePairsAsJSON();
      Assert.assertNull(jsonPairs);

      Assert.assertEquals(clusterConnectionConfig2.getDiscoveryGroupName(),
                          clusterConnectionControl.getDiscoveryGroupName());
   }
View Full Code Here

TOP

Related Classes of org.hornetq.api.core.management.ClusterConnectionControl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.