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); } } }
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); }
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; } }
nodeInfo.getHttp().toXContent(builder, params); if (nodeInfo.getPlugins() != null) { 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); } } }
private boolean checkPluginInstalled(Client client) { NodesInfoResponse nodesInfoResponse = client.admin().cluster().prepareNodesInfo().setPlugins(true).get(); for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) { for (PluginInfo pluginInfo : nodeInfo.getPlugins().getPluginInfos()) { if ("Vertexium".equals(pluginInfo.getName())) { return true; } } } LOGGER.warn("Running without the server side Vertexium plugin will be deprecated in the future."); return false; }
private boolean checkPluginInstalled(Client client) { NodesInfoResponse nodesInfoResponse = client.admin().cluster().prepareNodesInfo().setPlugins(true).get(); for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) { for (PluginInfo pluginInfo : nodeInfo.getPlugins().getInfos()) { if ("Vertexium".equals(pluginInfo.getName())) { return true; } } } LOGGER.warn("Running without the server side Vertexium plugin will be deprecated in the future."); return false; }
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); }
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); }
private boolean checkPluginInstalled(Client client) { if (config.isForceDisableVertexiumPlugin()) { LOGGER.info("Forcing the vertexium plugin off. Running without the server side Vertexium plugin will disable some features."); return false; } NodesInfoResponse nodesInfoResponse = client.admin().cluster().prepareNodesInfo().setPlugins(true).get(); for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) { for (PluginInfo pluginInfo : nodeInfo.getPlugins().getPluginInfos()) { if ("vertexium".equals(pluginInfo.getName())) { return true; } } } if (config.isErrorOnMissingVertexiumPlugin()) { throw new VertexiumException("Vertexium plugin cannot be found"); } LOGGER.warn("Running without the server side Vertexium plugin will disable some features."); return false; }
private boolean checkPluginInstalled(Client client) { if (config.isForceDisableVertexiumPlugin()) { LOGGER.info("Forcing the vertexium plugin off. Running without the server side Vertexium plugin will disable some features."); return false; } NodesInfoResponse nodesInfoResponse = client.admin().cluster().prepareNodesInfo().setPlugins(true).get(); for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) { for (PluginInfo pluginInfo : nodeInfo.getPlugins().getPluginInfos()) { if ("vertexium".equals(pluginInfo.getName())) { return true; } } } if (config.isErrorOnMissingVertexiumPlugin()) { throw new VertexiumException("Vertexium plugin cannot be found"); } LOGGER.warn("Running without the server side Vertexium plugin will disable some features."); return false; }
public void testPluginIsLoaded() { NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().setPlugins(true).get(); for (NodeInfo node : response.getNodes()) { boolean founded = false; for (PluginInfo pluginInfo : node.getPlugins().getPluginInfos()) { if (pluginInfo.getName().equals(AnalysisOpenKoreanTextPlugin.class.getName())) { founded = true; } } Assert.assertTrue(founded); } } }
@Test public void testPluginLoaded() { NodesInfoResponse nodesInfoResponse = client().admin().cluster().prepareNodesInfo().clear().setPlugins(true).get(); assertTrue(nodesInfoResponse.getNodes().length != 0); assertThat(nodesInfoResponse.getNodes()[0].getPlugins().getPluginInfos(), notNullValue()); assertThat(nodesInfoResponse.getNodes()[0].getPlugins().getPluginInfos().size(), not(0)); boolean pluginFound = false; for (PluginInfo pluginInfo : nodesInfoResponse.getNodes()[0].getPlugins().getPluginInfos()) { if (pluginInfo.getName().equals("SirenJoinPlugin")) { pluginFound = true; break; } } assertThat(pluginFound, is(true)); }
@Test public void testPluginLoaded() { NodesInfoResponse nodesInfoResponse = client().admin().cluster().prepareNodesInfo().clear().setPlugins(true).get(); assertTrue(nodesInfoResponse.getNodes().length != 0); assertThat(nodesInfoResponse.getNodes()[0].getPlugins().getInfos(), notNullValue()); assertThat(nodesInfoResponse.getNodes()[0].getPlugins().getInfos().size(), not(0)); boolean pluginFound = false; for (PluginInfo pluginInfo : nodesInfoResponse.getNodes()[0].getPlugins().getInfos()) { if (pluginInfo.getName().equals("siren-plugin")) { pluginFound = true; break; } } assertThat(pluginFound, is(true)); }
public ClusterStatsNodes(ClusterStatsNodeResponse[] nodeResponses) { this.counts = new Counts(); this.versions = new HashSet<>(); this.os = new OsStats(); this.jvm = new JvmStats(); this.fs = new FsInfo.Path(); this.plugins = new HashSet<>(); this.process = new ProcessStats(); Set<InetAddress> seenAddresses = new HashSet<>(nodeResponses.length); for (ClusterStatsNodeResponse nodeResponse : nodeResponses) { counts.addNodeInfo(nodeResponse.nodeInfo()); versions.add(nodeResponse.nodeInfo().getVersion()); process.addNodeStats(nodeResponse.nodeStats()); jvm.addNodeInfoStats(nodeResponse.nodeInfo(), nodeResponse.nodeStats()); 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(); InetAddress inetAddress = null; if (publishAddress.uniqueAddressTypeId() == 1) { inetAddress = ((InetSocketTransportAddress) publishAddress).address().getAddress(); } if (!seenAddresses.add(inetAddress)) { continue; } os.addNodeInfoStats(nodeResponse.nodeInfo(), nodeResponse.nodeStats()); if (nodeResponse.nodeStats().getFs() != null) { fs.add(nodeResponse.nodeStats().getFs().total()); } } }
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; }
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; } }
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; } }
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; } }
NodeInfo info = nodesInfo.getNodesMap().get(node.id()); for (PluginInfo pluginInfo : info.getPlugins().getPluginInfos()) { table.startRow(); table.addCell(node.id());