LOGGER.trace("CELLAR DOSGI: found {} remote endpoints", remoteEndpoints.size()); Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); final Set<Node> activeNodes = clusterManager.listNodes();
@Override protected Object doExecute() throws Exception { org.apache.karaf.cellar.core.control.ShutdownCommand command = new org.apache.karaf.cellar.core.control.ShutdownCommand(clusterManager.generateId()); Set<Node> recipientList = clusterManager.listNodes(); command.setDestination(recipientList); command.setHalt(halt); System.out.println("!! Cluster shutdown !!"); executionContext.execute(command); return null; }
@Override public void delete(String name) throws Exception { ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); Group g = groupManager.findGroupByName(name); List<String> nodes = new LinkedList<String>(); if (g.getNodes() != null && !g.getNodes().isEmpty()) { for (Node n : g.getNodes()) { nodes.add(n.getId()); } ManageGroupCommand command = new ManageGroupCommand(clusterManager.generateId()); command.setAction(ManageGroupAction.QUIT); command.setGroupName(name); Set<Node> recipientList = clusterManager.listNodes(nodes); command.setDestination(recipientList); executionContext.execute(command); } groupManager.deleteGroup(name); } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } }
@Override public void delete(String name) throws Exception { ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); Group g = groupManager.findGroupByName(name); List<String> nodes = new LinkedList<String>(); if (g.getNodes() != null && !g.getNodes().isEmpty()) { for (Node n : g.getNodes()) { nodes.add(n.getId()); } ManageGroupCommand command = new ManageGroupCommand(clusterManager.generateId()); command.setAction(ManageGroupAction.QUIT); command.setGroupName(name); Set<Node> recipientList = clusterManager.listNodes(nodes); command.setDestination(recipientList); executionContext.execute(command); } groupManager.deleteGroup(name); } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } }
@Override public Object doExecute() throws Exception { SetLogCommand command = new SetLogCommand(clusterManager.generateId()); command.setTimeout(timeout * 1000); Set<Node> recipientList = new HashSet<Node>(); if (nodes != null && !nodes.isEmpty()) { for (String nodeId : nodes) { Node node = clusterManager.findNodeByIdOrAlias(nodeId); if (node == null) { System.err.println("Node " + nodeId + " doesn't exist"); } else { recipientList.add(node); } } } else { recipientList = clusterManager.listNodes(); } if (recipientList.size() < 1) return null; command.setDestination(recipientList); command.setLogger(logger); command.setLevel(level); Map<Node, SetLogResult> results = executionContext.execute(command); if (results == null || results.isEmpty()) { System.err.println("No result received within given timeout"); } return null; }
@Override public void setLevel(String level, String logger, String nodeId) throws Exception { SetLogCommand command = new SetLogCommand(clusterManager.generateId()); command.setTimeout(30 * 1000); Set<Node> recipientList = new HashSet<Node>(); if (nodeId != null && clusterManager.findNodeByIdOrAlias(nodeId) == null) { throw new IllegalArgumentException("Node " + nodeId + " doesn't exist"); } if (nodeId == null) { recipientList = clusterManager.listNodes(); } else { recipientList.add(clusterManager.findNodeByIdOrAlias(nodeId)); } if (recipientList.size() < 1) throw new IllegalArgumentException("No recipient list"); command.setDestination(recipientList); command.setLogger(logger); command.setLevel(level); Map<Node, SetLogResult> results = executionContext.execute(command); if (results == null || results.isEmpty()) { throw new IllegalStateException("No result received within given timeout"); } }
@Override public void shutdown(boolean poweroff) throws Exception { ShutdownCommand command = new ShutdownCommand(clusterManager.generateId()); Set<Node> nodes = clusterManager.listNodes(); command.setDestination(nodes); command.setHalt(poweroff); executionContext.execute(command); }
@Override public void shutdown(boolean poweroff) throws Exception { ShutdownCommand command = new ShutdownCommand(clusterManager.generateId()); Set<Node> nodes = clusterManager.listNodes(); command.setDestination(nodes); command.setHalt(poweroff); executionContext.execute(command); }
Map<String, ClusterNode> clusterNodes = new LinkedHashMap<String, ClusterNode>(); Set<org.apache.karaf.cellar.core.Node> karafCellarNodes = karafCellarClusterManager.listNodes(); org.apache.karaf.cellar.core.Node thisKarafNode = karafCellarClusterManager.getNode(); Map<String, Properties> clusterConfigurations = karafCellarClusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + karafCellarGroupName);
Map<String, ClusterNode> clusterNodes = new LinkedHashMap<String, ClusterNode>(); Set<org.apache.karaf.cellar.core.Node> karafCellarNodes = karafCellarClusterManager.listNodes(); org.apache.karaf.cellar.core.Node thisKarafNode = karafCellarClusterManager.getNode(); Map<String, Properties> clusterConfigurations = karafCellarClusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + karafCellarGroupName);
recipientList = clusterManager.listNodes(); } else { recipientList.add(clusterManager.findNodeByIdOrAlias(nodeId));
@Override public TabularData getNodes() throws Exception { CompositeType nodeType = new CompositeType("Node", "Karaf Cellar cluster node", new String[]{ "id", "alias", "hostname", "port", "local" }, new String[]{ "ID of the node", "Alias of the node", "Hostname of the node", "Port number of the node", "Flag defining if the node is local" }, new OpenType[]{ SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.INTEGER, SimpleType.BOOLEAN }); TabularType tableType = new TabularType("Nodes", "Table of all Karaf Cellar nodes", nodeType, new String[]{ "id" }); TabularData table = new TabularDataSupport(tableType); Set<Node> nodes = clusterManager.listNodes(); for (Node node : nodes) { boolean local = (node.equals(clusterManager.getNode())); CompositeData data = new CompositeDataSupport(nodeType, new String[]{ "id", "alias", "hostname", "port", "local" }, new Object[]{ node.getId(), node.getAlias(), node.getHost(), node.getPort(), local }); table.put(data); } return table; }
@Override public TabularData getNodes() throws Exception { CompositeType nodeType = new CompositeType("Node", "Karaf Cellar cluster node", new String[]{ "id", "alias", "hostname", "port", "local" }, new String[]{ "ID of the node", "Alias of the node", "Hostname of the node", "Port number of the node", "Flag defining if the node is local" }, new OpenType[]{ SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.INTEGER, SimpleType.BOOLEAN }); TabularType tableType = new TabularType("Nodes", "Table of all Karaf Cellar nodes", nodeType, new String[]{ "id" }); TabularData table = new TabularDataSupport(tableType); Set<Node> nodes = clusterManager.listNodes(); for (Node node : nodes) { boolean local = (node.equals(clusterManager.getNode())); CompositeData data = new CompositeDataSupport(nodeType, new String[]{ "id", "alias", "hostname", "port", "local" }, new Object[]{ node.getId(), node.getAlias(), node.getHost(), node.getPort(), local }); table.put(data); } return table; }
ManageHandlersCommand command = new ManageHandlersCommand(clusterManager.generateId()); command.setDestination(clusterManager.listNodes()); command.setHandlerName(null); command.setStatus(null);
ManageHandlersCommand command = new ManageHandlersCommand(clusterManager.generateId()); command.setDestination(clusterManager.listNodes()); command.setHandlerName(null); command.setStatus(null);
recipientList = clusterManager.listNodes();
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); try { for (Node node : clusterManager.listNodes()) { if (acceptsNode(node)) { if (addId()) { String id = node.getId(); if (delegate.getStrings() != null && !delegate.getStrings().contains(id)) { delegate.getStrings().add(id); } } if (addAlias()) { String alias = node.getAlias(); if (delegate.getStrings() != null && !delegate.getStrings().contains(alias)) { delegate.getStrings().add(alias); } } } } } catch (Exception e) { // Ignore } return delegate.complete(session, commandLine, candidates); }
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); try { for (Node node : clusterManager.listNodes()) { if (acceptsNode(node)) { if (addId()) { String id = node.getId(); if (delegate.getStrings() != null && !delegate.getStrings().contains(id)) { delegate.getStrings().add(id); } } if (addAlias()) { String alias = node.getAlias(); if (delegate.getStrings() != null && !delegate.getStrings().contains(alias)) { delegate.getStrings().add(alias); } } } } } catch (Exception e) { // Ignore } return delegate.complete(session, commandLine, candidates); }
@Override protected Object doExecute() throws Exception { Set<Node> nodes = clusterManager.listNodes(); if (nodes != null && !nodes.isEmpty()) { ShellTable table = new ShellTable(); table.column(" "); table.column("Id"); table.column("Alias"); table.column("Host Name"); table.column("Port"); for (Node node : nodes) { String local = ""; if (node.equals(clusterManager.getNode())) local = "x"; table.addRow().addContent(local, node.getId(), node.getAlias(), node.getHost(), node.getPort()); } table.print(System.out); } else { System.err.println("No node found in the cluster"); } return null; }
private void writeJSON(final PrintWriter pw) throws IOException { final Set<Group> groups = groupManager.listAllGroups(); final Set<Node> nodes = clusterManager.listNodes();