/** * Add the {@link Group} list to the result. * * @param result the result where to add the group list. */ public void addGroupListToResult(ManageGroupResult result) { Set<Group> groups = groupManager.listAllGroups(); for (Group g : groups) { if (g.getName() != null && !g.getName().isEmpty()) { result.getGroups().add(g); } } }
/** * Add the {@link Group} list to the result. * * @param result the result where to add the group list. */ public void addGroupListToResult(ManageGroupResult result) { Set<Group> groups = groupManager.listAllGroups(); for (Group g : groups) { if (g.getName() != null && !g.getName().isEmpty()) { result.getGroups().add(g); } } }
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); try { for (Group group : groupManager.listAllGroups()) { if (acceptsGroup(group)) { String name = group.getName(); if (delegate.getStrings() != null && !delegate.getStrings().contains(name)) { delegate.getStrings().add(name); } } } } 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 (Group group : groupManager.listAllGroups()) { if (acceptsGroup(group)) { String name = group.getName(); if (delegate.getStrings() != null && !delegate.getStrings().contains(name)) { delegate.getStrings().add(name); } } } } catch (Exception e) { // ignore } return delegate.complete(session, commandLine, candidates); }
@Override public TabularData getGroups() throws Exception { Set<Group> allGroups = groupManager.listAllGroups(); CompositeType groupType = new CompositeType("Group", "Karaf Cellar cluster group", new String[]{ "name", "members"}, new String[]{ "Name of the cluster group", "Members of the cluster group" }, new OpenType[]{ SimpleType.STRING, SimpleType.STRING }); TabularType tableType = new TabularType("Groups", "Table of all Karaf Cellar groups", groupType, new String[]{ "name" }); TabularData table = new TabularDataSupport(tableType); for (Group group : allGroups) { StringBuffer members = new StringBuffer(); for (Node node : group.getNodes()) { // display only up and running nodes in the cluster if (clusterManager.findNodeById(node.getId()) != null) { if (node.getAlias() != null) { members.append(node.getAlias()); } else { members.append(node.getId()); } members.append(" "); } } CompositeData data = new CompositeDataSupport(groupType, new String[]{ "name", "members" }, new Object[]{ group.getName(), members.toString() }); table.put(data); } return table; }
@Override public TabularData getGroups() throws Exception { Set<Group> allGroups = groupManager.listAllGroups(); CompositeType groupType = new CompositeType("Group", "Karaf Cellar cluster group", new String[]{ "name", "members"}, new String[]{ "Name of the cluster group", "Members of the cluster group" }, new OpenType[]{ SimpleType.STRING, SimpleType.STRING }); TabularType tableType = new TabularType("Groups", "Table of all Karaf Cellar groups", groupType, new String[]{ "name" }); TabularData table = new TabularDataSupport(tableType); for (Group group : allGroups) { StringBuffer members = new StringBuffer(); for (Node node : group.getNodes()) { // display only up and running nodes in the cluster if (clusterManager.findNodeById(node.getId()) != null) { if (node.getAlias() != null) { members.append(node.getAlias()); } else { members.append(node.getId()); } members.append(" "); } } CompositeData data = new CompositeDataSupport(groupType, new String[]{ "name", "members" }, new Object[]{ group.getName(), members.toString() }); table.put(data); } return table; }
private void writeJSON(final PrintWriter pw) throws IOException { final Set<Group> groups = groupManager.listAllGroups(); final Set<Node> nodes = clusterManager.listNodes();