@Override public void join(String groupName, String nodeIdOrAlias) throws Exception { Group group = groupManager.findGroupByName(groupName); if (group == null) { throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist"); } Node node = clusterManager.findNodeByIdOrAlias(nodeIdOrAlias); if (node == null) { throw new IllegalArgumentException("Cluster node " + nodeIdOrAlias + " doesn't exist"); } Set<Node> nodes = new HashSet<Node>(); nodes.add(node); ManageGroupCommand command = new ManageGroupCommand(clusterManager.generateId()); command.setAction(ManageGroupAction.JOIN); command.setGroupName(groupName); command.setDestination(nodes); executionContext.execute(command); }
@Override public void quit(String groupName, String nodeIdOrAlias) throws Exception { Group group = groupManager.findGroupByName(groupName); if (group == null) { throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist"); } Node node = clusterManager.findNodeByIdOrAlias(nodeIdOrAlias); if (node == null) { throw new IllegalArgumentException("Cluster node " + nodeIdOrAlias + " doesn't exist"); } Set<Node> nodes = new HashSet<Node>(); nodes.add(node); ManageGroupCommand command = new ManageGroupCommand(clusterManager.generateId()); command.setAction(ManageGroupAction.QUIT); command.setGroupName(groupName); command.setDestination(nodes); executionContext.execute(command); }
@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 join(String groupName, String nodeIdOrAlias) throws Exception { Group group = groupManager.findGroupByName(groupName); if (group == null) { throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist"); } Node node = clusterManager.findNodeByIdOrAlias(nodeIdOrAlias); if (node == null) { throw new IllegalArgumentException("Cluster node " + nodeIdOrAlias + " doesn't exist"); } Set<Node> nodes = new HashSet<Node>(); nodes.add(node); ManageGroupCommand command = new ManageGroupCommand(clusterManager.generateId()); command.setAction(ManageGroupAction.JOIN); command.setGroupName(groupName); command.setDestination(nodes); executionContext.execute(command); }
@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 quit(String groupName, String nodeIdOrAlias) throws Exception { Group group = groupManager.findGroupByName(groupName); if (group == null) { throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist"); } Node node = clusterManager.findNodeByIdOrAlias(nodeIdOrAlias); if (node == null) { throw new IllegalArgumentException("Cluster node " + nodeIdOrAlias + " doesn't exist"); } Set<Node> nodes = new HashSet<Node>(); nodes.add(node); ManageGroupCommand command = new ManageGroupCommand(clusterManager.generateId()); command.setAction(ManageGroupAction.QUIT); command.setGroupName(groupName); command.setDestination(nodes); executionContext.execute(command); }
command.setGroupName(group);