@Override protected Object handleOperation(String operationName, OperationContext context, ModelNode operation) throws OperationFailedException { if (ClusterConnectionDefinition.GET_NODES.equals(operationName)) { ClusterConnectionControl control = getActiveMQComponentControl(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()); } } catch (Exception e) { context.getFailureDescription().set(e.getLocalizedMessage()); } } else { unsupportedOperation(operationName); } return null; } }
@Override protected Object handleOperation(String operationName, OperationContext context, ModelNode operation) throws OperationFailedException { if (ClusterConnectionDefinition.GET_NODES.equals(operationName)) { ClusterConnectionControl control = getActiveMQComponentControl(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()); } } catch (Exception e) { context.getFailureDescription().set(e.getLocalizedMessage()); } } else { unsupportedOperation(operationName); } return null; } }
@Test 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()); server1.start(); waitForServerToStart(server1); long start = System.currentTimeMillis(); while (true) { nodes = clusterConnectionControl_0.getNodes(); if (nodes.size() == 1 || System.currentTimeMillis() - start > 30000) { break; } Thread.sleep(50); } Assert.assertEquals(1, nodes.size()); String remoteAddress = nodes.values().iterator().next(); Assert.assertTrue(remoteAddress.endsWith(":" + port_1)); }