org.elasticsearch.action.admin.cluster.node.info.NodeInfo Java Examples
The following examples show how to use
org.elasticsearch.action.admin.cluster.node.info.NodeInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransportClusterStatsAction.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override protected ClusterStatsNodeResponse nodeOperation(ClusterStatsNodeRequest nodeRequest) { NodeInfo nodeInfo = nodeService.info(false, true, false, true, false, true, false, true); NodeStats nodeStats = nodeService.stats(CommonStatsFlags.NONE, true, true, true, false, true, false, false, false, false); List<ShardStats> shardsStats = new ArrayList<>(); for (IndexService indexService : indicesService) { for (IndexShard indexShard : indexService) { if (indexShard.routingEntry() != null && indexShard.routingEntry().active()) { // only report on fully started shards shardsStats.add(new ShardStats(indexShard.routingEntry(), indexShard.shardPath(), new CommonStats(indexShard, SHARD_STATS_FLAGS), indexShard.commitStats())); } } } ClusterHealthStatus clusterStatus = null; if (clusterService.state().nodes().localNodeMaster()) { clusterStatus = new ClusterStateHealth(clusterService.state()).getStatus(); } return new ClusterStatsNodeResponse(nodeInfo.getNode(), clusterStatus, nodeInfo, nodeStats, shardsStats.toArray(new ShardStats[shardsStats.size()])); }
Example #2
Source File: CustomRealmIT.java From shield-custom-realm-example with Apache License 2.0 | 6 votes |
public void testTransportClient() throws Exception { NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get(); List<NodeInfo> nodes = nodeInfos.getNodes(); assertTrue(nodes.size() > 0); TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress(); String clusterName = nodeInfos.getClusterName().value(); Settings settings = Settings.builder() .put("cluster.name", clusterName) .put(ThreadContext.PREFIX + "." + CustomRealm.USER_HEADER, randomFrom(KNOWN_USERS)) .put(ThreadContext.PREFIX + "." + CustomRealm.PW_HEADER, PASSWORD) .build(); try (TransportClient client = new PreBuiltXPackTransportClient(settings)) { client.addTransportAddress(publishAddress); ClusterHealthResponse response = client.admin().cluster().prepareHealth().execute().actionGet(); assertThat(response.isTimedOut(), is(false)); } }
Example #3
Source File: Elasticsearch5SearchIndex.java From vertexium with Apache License 2.0 | 6 votes |
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; }
Example #4
Source File: ClusterStatsNodeResponse.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); clusterStatus = null; if (in.readBoolean()) { clusterStatus = ClusterHealthStatus.fromValue(in.readByte()); } this.nodeInfo = NodeInfo.readNodeInfo(in); this.nodeStats = NodeStats.readNodeStats(in); int size = in.readVInt(); shardsStats = new ShardStats[size]; for (size--; size >= 0; size--) { shardsStats[size] = ShardStats.readShardStats(in); } }
Example #5
Source File: IngestAutodiscoverTest.java From elasticsearch-helper with Apache License 2.0 | 5 votes |
@Test public void testAutodiscover() throws IOException { startNode("2"); Settings.Builder settingsBuilder = Settings.builder() .put("cluster.name", getClusterName()) .put("path.home", System.getProperty("path.home")) .put("autodiscover", true); int i = 0; NodesInfoRequest nodesInfoRequest = new NodesInfoRequest().transport(true); NodesInfoResponse response = client("1").admin().cluster().nodesInfo(nodesInfoRequest).actionGet(); for (NodeInfo nodeInfo : response) { TransportAddress ta = nodeInfo.getTransport().getAddress().publishAddress(); if (ta instanceof InetSocketTransportAddress) { InetSocketTransportAddress address = (InetSocketTransportAddress) ta; settingsBuilder.put("host." + i++, address.address().getHostName() + ":" + address.address().getPort()); } } final IngestTransportClient ingest = ClientBuilder.builder() .put(settingsBuilder.build()) .setMetric(new LongAdderIngestMetric()) .toIngestTransportClient(); try { ingest.newIndex("test"); } finally { ingest.shutdown(); } if (ingest.hasThrowable()) { logger.error("error", ingest.getThrowable()); } assertFalse(ingest.hasThrowable()); }
Example #6
Source File: DecompoundQueryTests.java From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 | 5 votes |
public void testPluginIsLoaded() { NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().setPlugins(true).get(); for (NodeInfo nodeInfo : response.getNodes()) { boolean pluginFound = false; for (PluginInfo pluginInfo : nodeInfo.getPlugins().getPluginInfos()) { if (pluginInfo.getName().equals(BundlePlugin.class.getName())) { pluginFound = true; break; } } assertThat(pluginFound, is(true)); } }
Example #7
Source File: ElasticSearchService.java From sakai with Educational Community License v2.0 | 5 votes |
protected NodesStatsResponse getNodesStats() { final NodesInfoResponse nodesInfoResponse = client.admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet(); final String[] nodes = new String[nodesInfoResponse.getNodes().length]; int i = 0; for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) { nodes[i++] = nodeInfo.getNode().getName(); } return client.admin().cluster().nodesStats(new NodesStatsRequest(nodes)).actionGet(); }
Example #8
Source File: EmbeddedElasticsearchNode.java From calcite with Apache License 2.0 | 5 votes |
/** * Returns current address to connect to with HTTP client. * @return hostname/port for HTTP connection */ public TransportAddress httpAddress() { Preconditions.checkState(isStarted, "node is not started"); NodesInfoResponse response = client().admin().cluster().prepareNodesInfo() .execute().actionGet(); if (response.getNodes().size() != 1) { throw new IllegalStateException("Expected single node but got " + response.getNodes().size()); } NodeInfo node = response.getNodes().get(0); return node.getHttp().address().boundAddresses()[0]; }
Example #9
Source File: VietnameseAnalysisIntegrationTest.java From elasticsearch-analysis-vietnamese with Apache License 2.0 | 5 votes |
public void testPluginIsLoaded() throws Exception { NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().setPlugins(true).get(); for (NodeInfo nodeInfo : response.getNodes()) { boolean pluginFound = false; for (PluginInfo pluginInfo : nodeInfo.getPlugins().getPluginInfos()) { if (pluginInfo.getName().equals(AnalysisVietnamesePlugin.class.getName())) { pluginFound = true; break; } } assertThat(pluginFound, is(true)); } }
Example #10
Source File: ElasticSearchService.java From sakai with Educational Community License v2.0 | 5 votes |
protected NodesStatsResponse getNodesStats() { final NodesInfoResponse nodesInfoResponse = client.admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet(); final String[] nodes = new String[nodesInfoResponse.getNodes().length]; int i = 0; for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) { nodes[i++] = nodeInfo.getNode().getName(); } return client.admin().cluster().nodesStats(new NodesStatsRequest(nodes)).actionGet(); }
Example #11
Source File: AbstractUnitTest.java From elasticsearch-shield-kerberos-realm with Apache License 2.0 | 5 votes |
public final void startES(final Settings settings) throws Exception { FileUtils.copyFileToDirectory(getAbsoluteFilePathFromClassPath("roles.yml").toFile(), new File("testtmp/config/shield")); final Set<Integer> ports = new HashSet<>(); do { ports.add(NetworkUtil.getServerPort()); } while (ports.size() < 7); final Iterator<Integer> portIt = ports.iterator(); elasticsearchHttpPort1 = portIt.next(); elasticsearchHttpPort2 = portIt.next(); elasticsearchHttpPort3 = portIt.next(); //elasticsearchNodePort1 = portIt.next(); //elasticsearchNodePort2 = portIt.next(); //elasticsearchNodePort3 = portIt.next(); esNode1 = new PluginEnabledNode(getDefaultSettingsBuilder(1, 0, elasticsearchHttpPort1, false, true).put( settings == null ? Settings.Builder.EMPTY_SETTINGS : settings).build(), Lists.newArrayList(ShieldPlugin.class, LicensePlugin.class, KerberosRealmPlugin.class)).start(); client = esNode1.client(); esNode2 = new PluginEnabledNode(getDefaultSettingsBuilder(2, 0, elasticsearchHttpPort2, true, true).put( settings == null ? Settings.Builder.EMPTY_SETTINGS : settings).build(), Lists.newArrayList(ShieldPlugin.class, LicensePlugin.class, KerberosRealmPlugin.class)).start(); esNode3 = new PluginEnabledNode(getDefaultSettingsBuilder(3, 0, elasticsearchHttpPort3, true, false).put( settings == null ? Settings.Builder.EMPTY_SETTINGS : settings).build(), Lists.newArrayList(ShieldPlugin.class, LicensePlugin.class, KerberosRealmPlugin.class)).start(); waitForGreenClusterState(); final NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get(); final NodeInfo[] nodes = nodeInfos.getNodes(); Assert.assertEquals(nodes + "", 3, nodes.length); }
Example #12
Source File: KerberosRealmEmbeddedTests.java From elasticsearch-shield-kerberos-realm with Apache License 2.0 | 5 votes |
@Test public void testTransportClientMultiRound() throws Exception { //Mock mode, no kerberos involved embeddedKrbServer.getSimpleKdcServer().stop(); final Settings esServerSettings = Settings.builder().put(PREFIX + SettingConstants.ACCEPTOR_KEYTAB_PATH, "mock") .put(PREFIX + SettingConstants.ACCEPTOR_PRINCIPAL, "mock").put(PREFIX + "mock_mode", true) .putArray(PREFIX + SettingConstants.ROLES+".cc_kerberos_realm_role", "spock/[email protected]","mock_principal") .build(); this.startES(esServerSettings); final NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get(); final NodeInfo[] nodes = nodeInfos.getNodes(); assertTrue(nodes.length > 2); final Settings settings = Settings.builder().put("cluster.name", clustername) .putArray("plugin.types", ShieldPlugin.class.getName()).build(); try (TransportClient client = TransportClient.builder().settings(settings).build()) { client.addTransportAddress(nodes[0].getTransport().address().publishAddress()); try (KerberizedClient kc = new MockingKerberizedClient(client)) { ClusterHealthResponse response = kc.admin().cluster().prepareHealth().execute().actionGet(); assertThat(response.isTimedOut(), is(false)); response = kc.admin().cluster().prepareHealth().execute().actionGet(); assertThat(response.isTimedOut(), is(false)); response = kc.admin().cluster().prepareHealth().execute().actionGet(); assertThat(response.isTimedOut(), is(false)); assertThat(response.status(), is(RestStatus.OK)); assertThat(response.getStatus(), is(ClusterHealthStatus.GREEN)); } } }
Example #13
Source File: CustomRealmIT.java From shield-custom-realm-example with Apache License 2.0 | 5 votes |
public void testTransportClientWrongAuthentication() throws Exception { NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get(); List<NodeInfo> nodes = nodeInfos.getNodes(); assertTrue(nodes.size() > 0); TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress(); String clusterName = nodeInfos.getClusterName().value(); Settings settings; if (randomBoolean()) { settings = Settings.builder() .put("cluster.name", clusterName) .put(ThreadContext.PREFIX + "." + CustomRealm.USER_HEADER, randomFrom(KNOWN_USERS) + randomAlphaOfLength(1)) .put(ThreadContext.PREFIX + "." + CustomRealm.PW_HEADER, PASSWORD) .build(); } else { settings = Settings.builder() .put("cluster.name", clusterName) .put(ThreadContext.PREFIX + "." + CustomRealm.USER_HEADER, randomFrom(KNOWN_USERS)) .put(ThreadContext.PREFIX + "." + CustomRealm.PW_HEADER, randomAlphaOfLengthBetween(16, 32)) .build(); } try (TransportClient client = new PreBuiltXPackTransportClient(settings)) { client.addTransportAddress(publishAddress); client.admin().cluster().prepareHealth().execute().actionGet(); fail("authentication failure should have resulted in a NoNodesAvailableException"); } catch (NoNodeAvailableException e) { // expected } }
Example #14
Source File: EmbeddedElasticsearchNode.java From Quicksql with MIT License | 5 votes |
/** * Returns current address to connect to with HTTP client. * @return hostname/port for HTTP connection */ public TransportAddress httpAddress() { Preconditions.checkState(isStarted, "node is not started"); NodesInfoResponse response = client().admin().cluster().prepareNodesInfo() .execute().actionGet(); if (response.getNodes().size() != 1) { throw new IllegalStateException("Expected single node but got " + response.getNodes().size()); } NodeInfo node = response.getNodes().get(0); return node.getHttp().address().boundAddresses()[0]; }
Example #15
Source File: ClusterStatsNodeResponse.java From Elasticsearch with Apache License 2.0 | 5 votes |
public ClusterStatsNodeResponse(DiscoveryNode node, @Nullable ClusterHealthStatus clusterStatus, NodeInfo nodeInfo, NodeStats nodeStats, ShardStats[] shardsStats) { super(node); this.nodeInfo = nodeInfo; this.nodeStats = nodeStats; this.shardsStats = shardsStats; this.clusterStatus = clusterStatus; }
Example #16
Source File: ClusterStatsNodes.java From Elasticsearch with Apache License 2.0 | 5 votes |
public void addNodeInfoStats(NodeInfo nodeInfo, NodeStats nodeStats) { versions.addTo(new JvmVersion(nodeInfo.getJvm()), 1); org.elasticsearch.monitor.jvm.JvmStats js = nodeStats.getJvm(); if (js == null) { return; } if (js.getThreads() != null) { threads += js.getThreads().getCount(); } maxUptime = Math.max(maxUptime, js.getUptime().millis()); if (js.getMem() != null) { heapUsed += js.getMem().getHeapUsed().bytes(); heapMax += js.getMem().getHeapMax().bytes(); } }
Example #17
Source File: ClusterStatsNodes.java From Elasticsearch with Apache License 2.0 | 5 votes |
public void addNodeInfoStats(NodeInfo nodeInfo, NodeStats nodeStats) { availableProcessors += nodeInfo.getOs().getAvailableProcessors(); allocatedProcessors += nodeInfo.getOs().getAllocatedProcessors(); if (nodeInfo.getOs().getName() != null) { names.addTo(nodeInfo.getOs().getName(), 1); } if (nodeStats.getOs() != null && nodeStats.getOs().getMem() != null) { availableMemory += nodeStats.getOs().getMem().getFree().bytes(); } }
Example #18
Source File: ClusterStatsNodes.java From Elasticsearch with Apache License 2.0 | 5 votes |
public void addNodeInfo(NodeInfo nodeInfo) { total++; DiscoveryNode node = nodeInfo.getNode(); if (node.masterNode()) { if (node.dataNode()) { masterData++; } else { masterOnly++; } } else if (node.dataNode()) { dataOnly++; } else if (node.clientNode()) { client++; } }
Example #19
Source File: NodeService.java From Elasticsearch with Apache License 2.0 | 5 votes |
public NodeInfo info(boolean settings, boolean os, boolean process, boolean jvm, boolean threadPool, boolean transport, boolean http, boolean plugin) { return new NodeInfo(version, Build.CURRENT, discovery.localNode(), serviceAttributes, settings ? this.settings : null, os ? monitorService.osService().info() : null, process ? monitorService.processService().info() : null, jvm ? monitorService.jvmService().info() : null, threadPool ? this.threadPool.info() : null, transport ? transportService.info() : null, http ? (httpServer == null ? null : httpServer.info()) : null, plugin ? (pluginService == null ? null : pluginService.info()) : null ); }
Example #20
Source File: NodeService.java From Elasticsearch with Apache License 2.0 | 5 votes |
public NodeInfo info() { return new NodeInfo(version, Build.CURRENT, discovery.localNode(), serviceAttributes, settings, monitorService.osService().info(), monitorService.processService().info(), monitorService.jvmService().info(), threadPool.info(), transportService.info(), httpServer == null ? null : httpServer.info(), pluginService == null ? null : pluginService.info() ); }
Example #21
Source File: RestPluginsAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
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.id()); for (PluginInfo pluginInfo : info.getPlugins().getPluginInfos()) { table.startRow(); table.addCell(node.id()); table.addCell(node.name()); table.addCell(pluginInfo.getName()); table.addCell(pluginInfo.getVersion()); String type; if (pluginInfo.isSite()) { if (pluginInfo.isJvm()) { type = "j/s"; } else { type = "s"; } } else { if (pluginInfo.isJvm()) { type = "j"; } else { type = ""; } } table.addCell(type); table.addCell(pluginInfo.getUrl()); table.addCell(pluginInfo.getDescription()); table.endRow(); } } return table; }
Example #22
Source File: RestNodeAttrsAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo, NodesStatsResponse nodesStats) { boolean fullId = req.paramAsBoolean("full_id", false); DiscoveryNodes nodes = state.getState().nodes(); Table table = getTableWithHeader(req); for (DiscoveryNode node : nodes) { NodeInfo info = nodesInfo.getNodesMap().get(node.id()); ImmutableMap<String, String> attrs = node.getAttributes(); for(String att : attrs.keySet()) { table.startRow(); table.addCell(node.name()); table.addCell(fullId ? node.id() : Strings.substring(node.getId(), 0, 4)); table.addCell(info == null ? null : info.getProcess().getId()); table.addCell(node.getHostName()); table.addCell(node.getHostAddress()); if (node.address() instanceof InetSocketTransportAddress) { table.addCell(((InetSocketTransportAddress) node.address()).address().getPort()); } else { table.addCell("-"); } table.addCell(att); table.addCell(attrs.containsKey(att) ? attrs.get(att) : null); table.endRow(); } } return table; }
Example #23
Source File: AnalysisOpenKoreanTextPluginTest.java From elasticsearch-analysis-openkoreantext with Apache License 2.0 | 5 votes |
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); } }
Example #24
Source File: EmbeddedElasticsearchNode.java From Quicksql with MIT License | 5 votes |
/** * Returns current address to connect to with HTTP client. * * @return hostname/port for HTTP connection */ public TransportAddress httpAddress() { Preconditions.checkState(isStarted, "node is not started"); NodesInfoResponse response = client().admin().cluster().prepareNodesInfo() .execute().actionGet(); if (response.getNodes().size() != 1) { throw new IllegalStateException("Expected single node but got " + response.getNodes().size()); } NodeInfo node = response.getNodes().get(0); return node.getHttp().address().boundAddresses()[0]; }
Example #25
Source File: ClusterStatsNodeResponse.java From Elasticsearch with Apache License 2.0 | 4 votes |
public NodeInfo nodeInfo() { return this.nodeInfo; }
Example #26
Source File: KerberosRealmEmbeddedTests.java From elasticsearch-shield-kerberos-realm with Apache License 2.0 | 4 votes |
@Test public void testTransportClient() throws Exception { embeddedKrbServer.getSimpleKdcServer().createPrincipal("spock/[email protected]", "secret"); embeddedKrbServer.getSimpleKdcServer().createPrincipal("elasticsearch/[email protected]", "testpwd"); FileUtils.forceMkdir(new File("testtmp/config/keytab/")); embeddedKrbServer.getSimpleKdcServer().exportPrincipal("elasticsearch/[email protected]", new File("testtmp/config/keytab/es_server.keytab")); //server, acceptor final Settings esServerSettings = Settings.builder() .put(PREFIX + SettingConstants.ACCEPTOR_KEYTAB_PATH, "keytab/es_server.keytab") //relative to config .put(PREFIX + SettingConstants.ACCEPTOR_PRINCIPAL, "elasticsearch/[email protected]") .put(PREFIX + SettingConstants.STRIP_REALM_FROM_PRINCIPAL, true) .putArray(PREFIX + SettingConstants.ROLES+".cc_kerberos_realm_role", "spock/[email protected]") //.put(PREFIX+SettingConstants.KRB5_FILE_PATH,"") //if already set by kerby here //.put(PREFIX+SettingConstants.KRB_DEBUG, true) .build(); this.startES(esServerSettings); final NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get(); final NodeInfo[] nodes = nodeInfos.getNodes(); assertTrue(nodes.length > 2); final Settings settings = Settings.builder().put("cluster.name", clustername) .putArray("plugin.types", ShieldPlugin.class.getName()).build(); try (TransportClient client = TransportClient.builder().settings(settings).build()) { client.addTransportAddress(nodes[0].getTransport().address().publishAddress()); try (KerberizedClient kc = new KerberizedClient(client, "spock/[email protected]", "secret", "elasticsearch/[email protected]")) { ClusterHealthResponse response = kc.admin().cluster().prepareHealth().execute().actionGet(); assertThat(response.isTimedOut(), is(false)); response = kc.admin().cluster().prepareHealth().execute().actionGet(); assertThat(response.isTimedOut(), is(false)); response = kc.admin().cluster().prepareHealth().execute().actionGet(); assertThat(response.isTimedOut(), is(false)); assertThat(response.status(), is(RestStatus.OK)); assertThat(response.getStatus(), is(ClusterHealthStatus.GREEN)); } } }
Example #27
Source File: KerberosRealmEmbeddedTests.java From elasticsearch-shield-kerberos-realm with Apache License 2.0 | 4 votes |
@Test(expected = LoginException.class) public void testTransportClientBadUser() throws Exception { embeddedKrbServer.getSimpleKdcServer().createPrincipal("spock/[email protected]", "secret"); embeddedKrbServer.getSimpleKdcServer().createPrincipal("elasticsearch/[email protected]", "testpwd"); FileUtils.forceMkdir(new File("testtmp/config/keytab/")); embeddedKrbServer.getSimpleKdcServer().exportPrincipal("elasticsearch/[email protected]", new File("testtmp/config/keytab/es_server.keytab")); //server, acceptor final Settings esServerSettings = Settings.builder().put(PREFIX + SettingConstants.ACCEPTOR_KEYTAB_PATH, "keytab/es_server.keytab") .put(PREFIX + SettingConstants.ACCEPTOR_PRINCIPAL, "elasticsearch/[email protected]") .put(PREFIX + SettingConstants.STRIP_REALM_FROM_PRINCIPAL, true) .putArray(PREFIX + SettingConstants.ROLES+".cc_kerberos_realm_role", "spock/[email protected]") //.put(PREFIX+SettingConstants.KRB5_FILE_PATH,"") //if already set by kerby here //.put(PREFIX+SettingConstants.KRB_DEBUG, true) .build(); this.startES(esServerSettings); final NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get(); final NodeInfo[] nodes = nodeInfos.getNodes(); assertTrue(nodes.length > 2); final Settings settings = Settings.builder().put("cluster.name", clustername) .putArray("plugin.types", ShieldPlugin.class.getName()).build(); try (TransportClient client = TransportClient.builder().settings(settings).build()) { client.addTransportAddress(nodes[0].getTransport().address().publishAddress()); try (KerberizedClient kc = new KerberizedClient(client, "spock/[email protected]_bad", "secret-wrong", "elasticsearch/[email protected]")) { ClusterHealthResponse response = kc.admin().cluster().prepareHealth().execute().actionGet(); assertThat(response.isTimedOut(), is(false)); response = kc.admin().cluster().prepareHealth().execute().actionGet(); assertThat(response.isTimedOut(), is(false)); response = kc.admin().cluster().prepareHealth().execute().actionGet(); assertThat(response.isTimedOut(), is(false)); assertThat(response.status(), is(RestStatus.OK)); assertThat(response.getStatus(), is(ClusterHealthStatus.GREEN)); } } }
Example #28
Source File: RestThreadPoolAction.java From Elasticsearch with Apache License 2.0 | 4 votes |
private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo, NodesStatsResponse nodesStats) { boolean fullId = req.paramAsBoolean("full_id", false); DiscoveryNodes nodes = state.getState().nodes(); Table table = getTableWithHeader(req); for (DiscoveryNode node : nodes) { NodeInfo info = nodesInfo.getNodesMap().get(node.id()); NodeStats stats = nodesStats.getNodesMap().get(node.id()); table.startRow(); table.addCell(fullId ? node.id() : Strings.substring(node.getId(), 0, 4)); table.addCell(info == null ? null : info.getProcess().getId()); table.addCell(node.getHostName()); table.addCell(node.getHostAddress()); if (node.address() instanceof InetSocketTransportAddress) { table.addCell(((InetSocketTransportAddress) node.address()).address().getPort()); } else { table.addCell("-"); } final Map<String, ThreadPoolStats.Stats> poolThreadStats; final Map<String, ThreadPool.Info> poolThreadInfo; if (stats == null) { poolThreadStats = Collections.emptyMap(); poolThreadInfo = Collections.emptyMap(); } else { poolThreadStats = new HashMap<>(14); poolThreadInfo = new HashMap<>(14); ThreadPoolStats threadPoolStats = stats.getThreadPool(); for (ThreadPoolStats.Stats threadPoolStat : threadPoolStats) { poolThreadStats.put(threadPoolStat.getName(), threadPoolStat); } if (info != null) { for (ThreadPool.Info threadPoolInfo : info.getThreadPool()) { poolThreadInfo.put(threadPoolInfo.getName(), threadPoolInfo); } } } for (String pool : SUPPORTED_NAMES) { ThreadPoolStats.Stats poolStats = poolThreadStats.get(pool); ThreadPool.Info poolInfo = poolThreadInfo.get(pool); Long maxQueueSize = null; String keepAlive = null; Integer minThreads = null; Integer maxThreads = null; if (poolInfo != null) { if (poolInfo.getQueueSize() != null) { maxQueueSize = poolInfo.getQueueSize().singles(); } if (poolInfo.getKeepAlive() != null) { keepAlive = poolInfo.getKeepAlive().toString(); } if (poolInfo.getMin() >= 0) { minThreads = poolInfo.getMin(); } if (poolInfo.getMax() >= 0) { maxThreads = poolInfo.getMax(); } } table.addCell(poolInfo == null ? null : poolInfo.getThreadPoolType().getType()); table.addCell(poolStats == null ? null : poolStats.getActive()); table.addCell(poolStats == null ? null : poolStats.getThreads()); table.addCell(poolStats == null ? null : poolStats.getQueue()); table.addCell(maxQueueSize); table.addCell(poolStats == null ? null : poolStats.getRejected()); table.addCell(poolStats == null ? null : poolStats.getLargest()); table.addCell(poolStats == null ? null : poolStats.getCompleted()); table.addCell(minThreads); table.addCell(maxThreads); table.addCell(keepAlive); } table.endRow(); } return table; }