Java Code Examples for org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse#getNodes()
The following examples show how to use
org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse#getNodes() .
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: 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 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: 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 4
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 5
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 6
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 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: 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 9
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 10
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 11
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 12
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)); } } }