/** * Remove a {@link Node} from the target {@link Group}. * * @param targetGroupName the target group name where to remove the node. */ public void quitGroup(String targetGroupName) { Node node = clusterManager.getNode(); Map<String, Group> groups = groupManager.listGroups(); if (groups != null && !groups.isEmpty()) { Group targetGroup = groups.get(targetGroupName); if (targetGroup.getNodes().contains(node)) { targetGroup.getNodes().remove(node); groupManager.unRegisterGroup(targetGroup); } } }
/** * Add {@link Node} to the target {@link Group}. * * @param targetGroupName the target group name where to add the node. */ public void joinGroup(String targetGroupName) { Node node = clusterManager.getNode(); Map<String, Group> groups = groupManager.listGroups(); if (groups != null && !groups.isEmpty()) { Group targetGroup = groups.get(targetGroupName); if (targetGroup == null) { groupManager.registerGroup(targetGroupName); } else if (!targetGroup.getNodes().contains(node)) { targetGroup.getNodes().add(node); groupManager.listGroups().put(targetGroupName, targetGroup); groupManager.registerGroup(targetGroup); } } }
/** * Remove a {@link Node} from the target {@link Group}. * * @param targetGroupName the target group name where to remove the node. */ public void quitGroup(String targetGroupName) { Node node = clusterManager.getNode(); Map<String, Group> groups = groupManager.listGroups(); if (groups != null && !groups.isEmpty()) { Group targetGroup = groups.get(targetGroupName); if (targetGroup.getNodes().contains(node)) { targetGroup.getNodes().remove(node); groupManager.unRegisterGroup(targetGroup); } } }
/** * Add {@link Node} to the target {@link Group}. * * @param targetGroupName the target group name where to add the node. */ public void joinGroup(String targetGroupName) { Node node = clusterManager.getNode(); Map<String, Group> groups = groupManager.listGroups(); if (groups != null && !groups.isEmpty()) { Group targetGroup = groups.get(targetGroupName); if (targetGroup == null) { groupManager.registerGroup(targetGroupName); } else if (!targetGroup.getNodes().contains(node)) { targetGroup.getNodes().add(node); groupManager.listGroups().put(targetGroupName, targetGroup); groupManager.registerGroup(targetGroup); } } }
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); try { Map<String, Group> groups = groupManager.listGroups(); if (groups != null && !groups.isEmpty()) { for (String groupName : groups.keySet()) { Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName); if (clusterConfigurations != null && !clusterConfigurations.isEmpty()) { for (String pid : clusterConfigurations.keySet()) { if (delegate.getStrings() != null && !delegate.getStrings().contains(pid)) { delegate.getStrings().add(pid); } } } } } } catch (Exception e) { // nothing to do } return delegate.complete(session, commandLine, candidates); }
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); try { Map<String, Group> groups = groupManager.listGroups(); if (groups != null && !groups.isEmpty()) { for (String groupName : groups.keySet()) { Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName); if (clusterConfigurations != null && !clusterConfigurations.isEmpty()) { for (String pid : clusterConfigurations.keySet()) { if (delegate.getStrings() != null && !delegate.getStrings().contains(pid)) { delegate.getStrings().add(pid); } } } } } } catch (Exception e) { // nothing to do } return delegate.complete(session, commandLine, candidates); }