@Override protected Object doExecute() throws Exception { Group group = groupManager.findGroupByName(groupName); if (group == null) { System.err.println("Cluster group " + groupName + " doesn't exist"); return null; } return doExecute(ManageGroupAction.QUIT, groupName, null, nodes, false); }
@Override protected Object doExecute() throws Exception { Group group = groupManager.findGroupByName(groupName); if (group == null) { System.err.println("Cluster group " + groupName + " doesn't exist"); return null; } return doExecute(ManageGroupAction.SET, groupName, null, nodes, false); }
@Override public void create(String name) throws Exception { // check if the group exists Group group = groupManager.findGroupByName(name); if (group != null) { throw new IllegalArgumentException("Cluster group " + name + " already exists"); } groupManager.createGroup(name); }
@Override protected Object doExecute() throws Exception { // check if the group exists Group group = groupManager.findGroupByName(groupName); if (group != null) { System.err.println("Cluster group " + groupName + " already exists"); return null; } groupManager.createGroup(groupName); return null; }
@Override protected Object doExecute() throws Exception { Group group = groupManager.findGroupByName(groupName); if (group == null) { System.err.println("Cluster group " + groupName + " doesn't exist"); return null; } return doExecute(ManageGroupAction.JOIN, groupName, null, nodes,false); }
@Override public void create(String name) throws Exception { // check if the group exists Group group = groupManager.findGroupByName(name); if (group != null) { throw new IllegalArgumentException("Cluster group " + name + " already exists"); } groupManager.createGroup(name); }
@Override public List<String> getConfigs(String groupName) throws Exception { // check if the group exists Group group = groupManager.findGroupByName(groupName); if (group == null) { throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist"); } List<String> result = new ArrayList<String>(); Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName); for (String pid : clusterConfigurations.keySet()) { result.add(pid); } return result; }
@Override public List<String> getConfigs(String groupName) throws Exception { // check if the group exists Group group = groupManager.findGroupByName(groupName); if (group == null) { throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist"); } List<String> result = new ArrayList<String>(); Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName); for (String pid : clusterConfigurations.keySet()) { result.add(pid); } return result; }
@Override public List<String> getUrls(String groupName) throws Exception { // check if the group exists Group group = groupManager.findGroupByName(groupName); if (group == null) { throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist"); } List<String> result = new ArrayList<String>(); Set<String> clusterUrls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName); for (String url : clusterUrls) { result.add(url); } return result; }
@Override public List<String> getRepositories(String groupName) throws Exception { // check if the group exists Group group = groupManager.findGroupByName(groupName); if (group == null) { throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist"); } // get the features repositories in the cluster group Map<String, String> clusterRepositories = clusterManager.getMap(Constants.REPOSITORIES_MAP + Configurations.SEPARATOR + groupName); List<String> result = new ArrayList<String>(); for (String clusterRepository : clusterRepositories.keySet()) { result.add(clusterRepository); } return result; }
@Override public List<String> getRepositories(String groupName) throws Exception { // check if the group exists Group group = groupManager.findGroupByName(groupName); if (group == null) { throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist"); } // get the features repositories in the cluster group Map<String, String> clusterRepositories = clusterManager.getMap(Constants.REPOSITORIES_MAP + Configurations.SEPARATOR + groupName); List<String> result = new ArrayList<String>(); for (String clusterRepository : clusterRepositories.keySet()) { result.add(clusterRepository); } return result; }
@Override public Object doExecute() throws Exception { // check if the group exists Group group = groupManager.findGroupByName(groupName); if (group == null) { System.err.println("Cluster group " + groupName + " doesn't exist"); return null; } // get the OBR URLs in a cluster group Set<String> clusterUrls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName); if (clusterUrls != null) { for (String url : clusterUrls) { System.out.println(url); } } return null; }
@Override public Map<String, String> listHttp(String groupName) throws Exception { Map<String, String> result = new HashMap<String, String>(); Group group = groupManager.findGroupByName(groupName); if (group == null) { throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist"); } Map<String, List<String>> clusterServlets = clusterManager.getMap(Constants.BALANCER_MAP + Configurations.SEPARATOR + groupName); for (String alias : clusterServlets.keySet()) { List<String> locations = clusterServlets.get(alias); StringBuilder builder = new StringBuilder(); for (String location : locations) { builder.append(location).append(" "); } result.put(alias, builder.toString()); } return result; } }
@Override protected Object doExecute() throws Exception { // check if the group exists Group group = groupManager.findGroupByName(groupName); if (group == null) { System.err.println("Cluster group " + groupName + " doesn't exist"); return null; } // check if the group doesn't contain nodes if (group.getNodes() != null && !group.getNodes().isEmpty()) { System.err.println("Cluster group " + groupName + " is not empty"); return null; } groupManager.deleteGroup(groupName); return null; }
@Override public Object doExecute() throws Exception { Group group = groupManager.findGroupByName(groupName); if (group == null) { System.err.println("Cluster group " + groupName + " doesn't exist"); return null; } Map<String, List<String>> clusterServlets = clusterManager.getMap(Constants.BALANCER_MAP + Configurations.SEPARATOR + groupName); ShellTable table = new ShellTable(); table.column("Alias"); table.column("Locations"); for (String alias : clusterServlets.keySet()) { List<String> locations = clusterServlets.get(alias); StringBuilder builder = new StringBuilder(); for (String location : locations) { builder.append(location).append(" "); } table.addRow().addContent(alias, builder.toString()); } table.print(System.out); return null; }
@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 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 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 block(String groupName, String featurePattern, boolean whitelist, boolean blacklist, boolean in, boolean out) throws Exception { Group group = groupManager.findGroupByName(groupName); if (group == null) { throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist"); } CellarSupport support = new CellarSupport(); support.setClusterManager(clusterManager); support.setGroupManager(groupManager); support.setConfigurationAdmin(configurationAdmin); if (in) { if (whitelist) support.switchListEntry(Configurations.WHITELIST, groupName, Constants.CATEGORY, EventType.INBOUND, featurePattern); if (blacklist) support.switchListEntry(Configurations.BLACKLIST, groupName, Constants.CATEGORY, EventType.INBOUND, featurePattern); } if (out) { if (whitelist) support.switchListEntry(Configurations.WHITELIST, groupName, Constants.CATEGORY, EventType.OUTBOUND, featurePattern); if (blacklist) support.switchListEntry(Configurations.BLACKLIST, groupName, Constants.CATEGORY, EventType.OUTBOUND, featurePattern); } }