@Override public TabularData producerStatus() throws Exception { ProducerSwitchCommand command = new ProducerSwitchCommand(clusterManager.generateId()); command.setStatus(null); Map<Node, ProducerSwitchResult> results = executionContext.execute(command); CompositeType compositeType = new CompositeType("Event Producer", "Karaf Cellar cluster event producer", new String[]{"node", "status", "local"}, new String[]{"Node hosting event producer", "Current status of the event producer", "True if the node is local"}, new OpenType[]{SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN}); TabularType tableType = new TabularType("Event Producers", "Table of Karaf Cellar cluster event producers", compositeType, new String[]{"node"}); TabularDataSupport table = new TabularDataSupport(tableType); for (Node node : results.keySet()) { boolean local = (node.equals(clusterManager.getNode())); ProducerSwitchResult producerSwitchResult = results.get(node); String nodeName = node.getAlias(); if (nodeName == null) { nodeName = node.getId(); } CompositeDataSupport data = new CompositeDataSupport(compositeType, new String[]{"node", "status", "local"}, new Object[]{nodeName, producerSwitchResult.getStatus(), local}); table.put(data); } return table; }
@Override public TabularData producerStatus() throws Exception { ProducerSwitchCommand command = new ProducerSwitchCommand(clusterManager.generateId()); command.setStatus(null); Map<Node, ProducerSwitchResult> results = executionContext.execute(command); CompositeType compositeType = new CompositeType("Event Producer", "Karaf Cellar cluster event producer", new String[]{"node", "status", "local"}, new String[]{"Node hosting event producer", "Current status of the event producer", "True if the node is local"}, new OpenType[]{SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN}); TabularType tableType = new TabularType("Event Producers", "Table of Karaf Cellar cluster event producers", compositeType, new String[]{"node"}); TabularDataSupport table = new TabularDataSupport(tableType); for (Node node : results.keySet()) { boolean local = (node.equals(clusterManager.getNode())); ProducerSwitchResult producerSwitchResult = results.get(node); String nodeName = node.getAlias(); if (nodeName == null) { nodeName = node.getId(); } CompositeDataSupport data = new CompositeDataSupport(compositeType, new String[]{"node", "status", "local"}, new Object[]{nodeName, producerSwitchResult.getStatus(), local}); table.put(data); } return table; }
if (result.getStatus()) { statusString = "ON";