private static void issueWarnings(Client tc) { NodesInfoResponse nir = tc.admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet(); Version maxVersion = nir.getNodes().stream().max((n1,n2) -> n1.getVersion().compareTo(n2.getVersion())).get().getVersion(); Version minVersion = nir.getNodes().stream().min((n1,n2) -> n1.getVersion().compareTo(n2.getVersion())).get().getVersion(); if(!maxVersion.equals(minVersion)) { System.out.println("WARNING: Your cluster consists of different node versions. It is not recommended to run sgadmin against a mixed cluster. This may fail."); System.out.println(" Minimum node version is "+minVersion.toString()); System.out.println(" Maximum node version is "+maxVersion.toString()); } else { System.out.println("Elasticsearch Version: "+minVersion.toString()); } if(nir.getNodes().size() > 0) { List<PluginInfo> pluginInfos = nir.getNodes().get(0).getPlugins().getPluginInfos(); String sgVersion = pluginInfos.stream().filter(p->p.getClassname().equals("com.floragunn.searchguard.SearchGuardPlugin")).map(p->p.getVersion()).findFirst().orElse("<unknown>"); System.out.println("Search Guard Version: "+sgVersion); } } }
pluginsLoaded.addAll(loaded); this.info = new PluginsAndModules(pluginsList, modulesList); this.plugins = Collections.unmodifiableList(pluginsLoaded); logPluginInfo(info.getModuleInfos(), "module", logger); logPluginInfo(info.getPluginInfos(), "plugin", logger);
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startArray("plugins"); for (PluginInfo pluginInfo : getPluginInfos()) { pluginInfo.toXContent(builder, params); } builder.endArray(); // TODO: not ideal, make a better api for this (e.g. with jar metadata, and so on) builder.startArray("modules"); for (PluginInfo moduleInfo : getModuleInfos()) { moduleInfo.toXContent(builder, params); } builder.endArray(); return builder; } }
info = new PluginsAndModules(); info.addPlugin(pluginInfo); pluginsLoaded.addAll(loaded); for (Tuple<PluginInfo, Plugin> module : loaded) { info.addModule(module.v1()); pluginsLoaded.addAll(loaded); for (Tuple<PluginInfo, Plugin> plugin : loaded) { info.addPlugin(plugin.v1()); for (PluginInfo moduleInfo : info.getModuleInfos()) { moduleNames.add(moduleInfo.getName()); for (PluginInfo pluginInfo : info.getPluginInfos()) { jvmPluginNames.add(pluginInfo.getName());
nodeInfo.getPlugins().toXContent(builder, params);
plugins = new PluginsAndModules(); plugins.readFrom(in);
@Override public void writeTo(StreamOutput out) throws IOException { if (out.getVersion().before(Version.V_2_2_0)) { out.writeInt(plugins.size() + modules.size()); for (PluginInfo plugin : getPluginInfos()) { plugin.writeTo(out); } for (PluginInfo module : getModuleInfos()) { module.writeTo(out); } } else { out.writeInt(plugins.size()); for (PluginInfo plugin : getPluginInfos()) { plugin.writeTo(out); } out.writeInt(modules.size()); for (PluginInfo module : getModuleInfos()) { module.writeTo(out); } } }
private Map<String, String> getNodesInfos(NodesInfoResponse nodesInfoResponse) { Map<String, String> nodeInfoMap = new HashMap<>(); for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) { try (XContentBuilder builder = XContentFactory.jsonBuilder()) { builder.humanReadable(true).prettyPrint(); builder.startObject(); nodeInfo.getSettings().toXContent(builder, ToXContent.EMPTY_PARAMS); nodeInfo.getOs().toXContent(builder, ToXContent.EMPTY_PARAMS); nodeInfo.getProcess().toXContent(builder, ToXContent.EMPTY_PARAMS); nodeInfo.getJvm().toXContent(builder, ToXContent.EMPTY_PARAMS); nodeInfo.getThreadPool().toXContent(builder, ToXContent.EMPTY_PARAMS); nodeInfo.getTransport().toXContent(builder, ToXContent.EMPTY_PARAMS); nodeInfo.getPlugins().toXContent(builder, ToXContent.EMPTY_PARAMS); nodeInfo.getIngest().toXContent(builder, ToXContent.EMPTY_PARAMS); builder.endObject(); nodeInfoMap.put(nodeInfo.getNode().getName(), builder.string()); } catch (IOException e) { Exceptions.handle(e); } } return nodeInfoMap; }
ClusterStatsNodes(List<ClusterStatsNodeResponse> nodeResponses) { this.versions = new HashSet<>(); this.fs = new FsInfo.Path(); this.plugins = new HashSet<>(); Set<InetAddress> seenAddresses = new HashSet<>(nodeResponses.size()); List<NodeInfo> nodeInfos = new ArrayList<>(nodeResponses.size()); List<NodeStats> nodeStats = new ArrayList<>(nodeResponses.size()); for (ClusterStatsNodeResponse nodeResponse : nodeResponses) { nodeInfos.add(nodeResponse.nodeInfo()); nodeStats.add(nodeResponse.nodeStats()); this.versions.add(nodeResponse.nodeInfo().getVersion()); this.plugins.addAll(nodeResponse.nodeInfo().getPlugins().getPluginInfos()); // now do the stats that should be deduped by hardware (implemented by ip deduping) TransportAddress publishAddress = nodeResponse.nodeInfo().getTransport().address().publishAddress(); final InetAddress inetAddress = publishAddress.address().getAddress(); if (!seenAddresses.add(inetAddress)) { continue; } if (nodeResponse.nodeStats().getFs() != null) { this.fs.add(nodeResponse.nodeStats().getFs().getTotal()); } } this.counts = new Counts(nodeInfos); this.os = new OsStats(nodeInfos, nodeStats); this.process = new ProcessStats(nodeStats); this.jvm = new JvmStats(nodeInfos, nodeStats); this.networkTypes = new NetworkTypes(nodeInfos); }
pluginsLoaded.addAll(loaded); this.info = new PluginsAndModules(pluginsList, modulesList); this.plugins = Collections.unmodifiableList(pluginsLoaded); logPluginInfo(info.getModuleInfos(), "module", logger); logPluginInfo(info.getPluginInfos(), "plugin", logger);
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startArray("plugins"); for (PluginInfo pluginInfo : getPluginInfos()) { pluginInfo.toXContent(builder, params); } builder.endArray(); // TODO: not ideal, make a better api for this (e.g. with jar metadata, and so on) builder.startArray("modules"); for (PluginInfo moduleInfo : getModuleInfos()) { moduleInfo.toXContent(builder, params); } builder.endArray(); return builder; } }
nodeInfo.getPlugins().toXContent(builder, params);
private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo) { DiscoveryNodes nodes = state.getState().nodes(); Table table = getTableWithHeader(req); for (DiscoveryNode node : nodes) { NodeInfo info = nodesInfo.getNodesMap().get(node.getId()); for (PluginInfo pluginInfo : info.getPlugins().getPluginInfos()) { table.startRow(); table.addCell(node.getId()); table.addCell(node.getName()); table.addCell(pluginInfo.getName()); table.addCell(pluginInfo.getVersion()); table.addCell(pluginInfo.getDescription()); table.endRow(); } } return table; } }
pluginsLoaded.addAll(loaded); this.info = new PluginsAndModules(pluginsList, modulesList); this.plugins = Collections.unmodifiableList(pluginsLoaded); logPluginInfo(info.getModuleInfos(), "module", logger); logPluginInfo(info.getPluginInfos(), "plugin", logger);
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startArray("plugins"); for (PluginInfo pluginInfo : getPluginInfos()) { pluginInfo.toXContent(builder, params); } builder.endArray(); // TODO: not ideal, make a better api for this (e.g. with jar metadata, and so on) builder.startArray("modules"); for (PluginInfo moduleInfo : getModuleInfos()) { moduleInfo.toXContent(builder, params); } builder.endArray(); return builder; } }
nodeInfo.getPlugins().toXContent(builder, params);
private static void issueWarnings(Client tc) { NodesInfoResponse nir = tc.admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet(); Version maxVersion = nir.getNodes().stream().max((n1,n2) -> n1.getVersion().compareTo(n2.getVersion())).get().getVersion(); Version minVersion = nir.getNodes().stream().min((n1,n2) -> n1.getVersion().compareTo(n2.getVersion())).get().getVersion(); if(!maxVersion.equals(minVersion)) { System.out.println("WARNING: Your cluster consists of different node versions. It is not recommended to run sgadmin against a mixed cluster. This may fail."); System.out.println(" Minimum node version is "+minVersion.toString()); System.out.println(" Maximum node version is "+maxVersion.toString()); } else { System.out.println("Elasticsearch Version: "+minVersion.toString()); } if(nir.getNodes().size() > 0) { List<PluginInfo> pluginInfos = nir.getNodes().get(0).getPlugins().getPluginInfos(); String sgVersion = pluginInfos.stream().filter(p->p.getClassname().equals("com.floragunn.searchguard.SearchGuardPlugin")).map(p->p.getVersion()).findFirst().orElse("<unknown>"); System.out.println("Search Guard Version: "+sgVersion); } } }
pluginsLoaded.addAll(loaded); this.info = new PluginsAndModules(pluginsList, modulesList); this.plugins = Collections.unmodifiableList(pluginsLoaded); logPluginInfo(info.getModuleInfos(), "module", logger); logPluginInfo(info.getPluginInfos(), "plugin", logger);
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startArray("plugins"); for (PluginInfo pluginInfo : getPluginInfos()) { pluginInfo.toXContent(builder, params); } builder.endArray(); // TODO: not ideal, make a better api for this (e.g. with jar metadata, and so on) builder.startArray("modules"); for (PluginInfo moduleInfo : getModuleInfos()) { moduleInfo.toXContent(builder, params); } builder.endArray(); return builder; } }
nodeInfo.getPlugins().toXContent(builder, params);