org.elasticsearch.node.PluginAwareNode Java Examples
The following examples show how to use
org.elasticsearch.node.PluginAwareNode.
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: AbstractUnitTest.java From deprecated-security-ssl with Apache License 2.0 | 6 votes |
public final void startES(final Settings settings) throws Exception { FileUtils.deleteDirectory(new File("data")); esNode1 = new PluginAwareNode(getDefaultSettingsBuilder(1, false, true).put( settings == null ? Settings.Builder.EMPTY_SETTINGS : settings).build(), Netty4Plugin.class, OpenDistroSecuritySSLPlugin.class); esNode2 = new PluginAwareNode(getDefaultSettingsBuilder(2, true, true).put( settings == null ? Settings.Builder.EMPTY_SETTINGS : settings).build(), Netty4Plugin.class, OpenDistroSecuritySSLPlugin.class); esNode3 = new PluginAwareNode(getDefaultSettingsBuilder(3, true, false).put( settings == null ? Settings.Builder.EMPTY_SETTINGS : settings).build(), Netty4Plugin.class, OpenDistroSecuritySSLPlugin.class); esNode1.start(); esNode2.start(); esNode3.start(); waitForGreenClusterState(esNode1.client()); }
Example #2
Source File: SSLTest.java From deprecated-security-ssl with Apache License 2.0 | 5 votes |
@Test public void testNodeClientSSL() throws Exception { final Settings settings = Settings.builder().put("opendistro_security.ssl.transport.enabled", true) .put(SSLConfigConstants.OPENDISTRO_SECURITY_SSL_HTTP_ENABLE_OPENSSL_IF_AVAILABLE, allowOpenSSL) .put(SSLConfigConstants.OPENDISTRO_SECURITY_SSL_TRANSPORT_ENABLE_OPENSSL_IF_AVAILABLE, allowOpenSSL) .put(SSLConfigConstants.OPENDISTRO_SECURITY_SSL_TRANSPORT_KEYSTORE_ALIAS, "node-0") .put("opendistro_security.ssl.transport.keystore_filepath", getAbsoluteFilePathFromClassPath("node-0-keystore.jks")) .put("opendistro_security.ssl.transport.truststore_filepath", getAbsoluteFilePathFromClassPath("truststore.jks")) .put("opendistro_security.ssl.transport.enforce_hostname_verification", false) .put("opendistro_security.ssl.transport.resolve_hostname", false) .build(); startES(settings); final Settings tcSettings = Settings.builder().put("cluster.name", clustername).put("path.home", ".") .put("node.name", "client_node_" + new Random().nextInt()) .put(settings)// ----- .build(); try (Node node = new PluginAwareNode(tcSettings, Netty4Plugin.class, OpenDistroSecuritySSLPlugin.class).start()) { ClusterHealthResponse res = node.client().admin().cluster().health(new ClusterHealthRequest().waitForNodes("4").timeout(TimeValue.timeValueSeconds(5))).actionGet(); Assert.assertFalse(res.isTimedOut()); Assert.assertEquals(4, res.getNumberOfNodes()); Assert.assertEquals(4, node.client().admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet().getNodes().size()); } Assert.assertFalse(executeSimpleRequest("_nodes/stats?pretty").contains("\"tx_size_in_bytes\" : 0")); Assert.assertFalse(executeSimpleRequest("_nodes/stats?pretty").contains("\"rx_count\" : 0")); Assert.assertFalse(executeSimpleRequest("_nodes/stats?pretty").contains("\"rx_size_in_bytes\" : 0")); Assert.assertFalse(executeSimpleRequest("_nodes/stats?pretty").contains("\"tx_count\" : 0")); }
Example #3
Source File: SSLTest.java From deprecated-security-ssl with Apache License 2.0 | 5 votes |
@Test public void testNodeClientSSLwithJavaTLSv13() throws Exception { //Java TLS 1.3 is available since Java 11 Assume.assumeTrue(!allowOpenSSL && PlatformDependent.javaVersion() >= 11); final Settings settings = Settings.builder().put("opendistro_security.ssl.transport.enabled", true) .put(SSLConfigConstants.OPENDISTRO_SECURITY_SSL_HTTP_ENABLE_OPENSSL_IF_AVAILABLE, allowOpenSSL) .put(SSLConfigConstants.OPENDISTRO_SECURITY_SSL_TRANSPORT_ENABLE_OPENSSL_IF_AVAILABLE, allowOpenSSL) .put(SSLConfigConstants.OPENDISTRO_SECURITY_SSL_TRANSPORT_KEYSTORE_ALIAS, "node-0") .put("opendistro_security.ssl.transport.keystore_filepath", getAbsoluteFilePathFromClassPath("node-0-keystore.jks")) .put("opendistro_security.ssl.transport.truststore_filepath", getAbsoluteFilePathFromClassPath("truststore.jks")) .put("opendistro_security.ssl.transport.enforce_hostname_verification", false) .put("opendistro_security.ssl.transport.resolve_hostname", false) .putList(SSLConfigConstants.OPENDISTRO_SECURITY_SSL_TRANSPORT_ENABLED_PROTOCOLS, "TLSv1.3") .putList(SSLConfigConstants.OPENDISTRO_SECURITY_SSL_TRANSPORT_ENABLED_CIPHERS, "TLS_AES_128_GCM_SHA256") .build(); startES(settings); final Settings tcSettings = Settings.builder().put("cluster.name", clustername).put("path.home", ".") .put("node.name", "client_node_" + new Random().nextInt()) .put(settings)// ----- .build(); try (Node node = new PluginAwareNode(tcSettings, Netty4Plugin.class, OpenDistroSecuritySSLPlugin.class).start()) { ClusterHealthResponse res = node.client().admin().cluster().health(new ClusterHealthRequest().waitForNodes("4").timeout(TimeValue.timeValueSeconds(5))).actionGet(); Assert.assertFalse(res.isTimedOut()); Assert.assertEquals(4, res.getNumberOfNodes()); Assert.assertEquals(4, node.client().admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet().getNodes().size()); } Assert.assertFalse(executeSimpleRequest("_nodes/stats?pretty").contains("\"tx_size_in_bytes\" : 0")); Assert.assertFalse(executeSimpleRequest("_nodes/stats?pretty").contains("\"rx_count\" : 0")); Assert.assertFalse(executeSimpleRequest("_nodes/stats?pretty").contains("\"rx_size_in_bytes\" : 0")); Assert.assertFalse(executeSimpleRequest("_nodes/stats?pretty").contains("\"tx_count\" : 0")); }
Example #4
Source File: OpenSSLTest.java From deprecated-security-ssl with Apache License 2.0 | 5 votes |
@Test public void testNodeClientSSLwithOpenSslTLSv13() throws Exception { Assume.assumeTrue(OpenSsl.isAvailable() && OpenSsl.version() > 0x10101009L); final Settings settings = Settings.builder().put("opendistro_security.ssl.transport.enabled", true) .put(SSLConfigConstants.OPENDISTRO_SECURITY_SSL_HTTP_ENABLE_OPENSSL_IF_AVAILABLE, allowOpenSSL) .put(SSLConfigConstants.OPENDISTRO_SECURITY_SSL_TRANSPORT_ENABLE_OPENSSL_IF_AVAILABLE, allowOpenSSL) .put(SSLConfigConstants.OPENDISTRO_SECURITY_SSL_TRANSPORT_KEYSTORE_ALIAS, "node-0") .put("opendistro_security.ssl.transport.keystore_filepath", getAbsoluteFilePathFromClassPath("node-0-keystore.jks")) .put("opendistro_security.ssl.transport.truststore_filepath", getAbsoluteFilePathFromClassPath("truststore.jks")) .put("opendistro_security.ssl.transport.enforce_hostname_verification", false) .put("opendistro_security.ssl.transport.resolve_hostname", false) .putList(SSLConfigConstants.OPENDISTRO_SECURITY_SSL_TRANSPORT_ENABLED_PROTOCOLS, "TLSv1.3") .putList(SSLConfigConstants.OPENDISTRO_SECURITY_SSL_TRANSPORT_ENABLED_CIPHERS, "TLS_CHACHA20_POLY1305_SHA256") .build(); startES(settings); final Settings tcSettings = Settings.builder().put("cluster.name", clustername).put("path.home", ".") .put("node.name", "client_node_" + new Random().nextInt()) .put(settings)// ----- .build(); try (Node node = new PluginAwareNode(tcSettings, Netty4Plugin.class, OpenDistroSecuritySSLPlugin.class).start()) { ClusterHealthResponse res = node.client().admin().cluster().health(new ClusterHealthRequest().waitForNodes("4").timeout(TimeValue.timeValueSeconds(5))).actionGet(); Assert.assertFalse(res.isTimedOut()); Assert.assertEquals(4, res.getNumberOfNodes()); Assert.assertEquals(4, node.client().admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet().getNodes().size()); } Assert.assertFalse(executeSimpleRequest("_nodes/stats?pretty").contains("\"tx_size_in_bytes\" : 0")); Assert.assertFalse(executeSimpleRequest("_nodes/stats?pretty").contains("\"rx_count\" : 0")); Assert.assertFalse(executeSimpleRequest("_nodes/stats?pretty").contains("\"rx_size_in_bytes\" : 0")); Assert.assertFalse(executeSimpleRequest("_nodes/stats?pretty").contains("\"tx_count\" : 0")); }
Example #5
Source File: ElasticsearchIntegrationTest.java From openshift-elasticsearch-plugin with Apache License 2.0 | 5 votes |
public final void startES(final Settings settings, int timeOutSec, int assertNodes) throws Exception { // setup api server final String masterUrl = apiServer.getMockServer().url("/").toString(); System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, masterUrl); System.setProperty("kubernetes.trust.certificates", "true"); System.setProperty("kubernetes.keystore.file", keyStore); System.setProperty("kubernetes.keystore.passphrase", password); System.setProperty("kubernetes.truststore.file", keyStore); System.setProperty("kubernetes.truststore.passphrase", password); System.setProperty("sg.display_lic_none", "true"); FileUtils.deleteDirectory(new File("data")); esNode1 = new PluginAwareNode( settings, OpenShiftElasticSearchPlugin.class); log.debug("--------- Starting ES Node ----------"); esNode1.start(); log.debug("--------- Waiting for the cluster to go green ----------"); waitForCluster(ClusterHealthStatus.GREEN, TimeValue.timeValueSeconds(timeOutSec), esNode1.client(), assertNodes); seedSearchGuardAcls(); // seed kibana index like kibana XContentBuilder contentBuilder = XContentFactory.jsonBuilder() .startObject() .field("defaultIndex",".all") .endObject(); givenDocumentIsIndexed(".kibana", "config", ConfigurationSettings.DEFAULT_KIBANA_VERSION, contentBuilder); // create ops user to avoid issue: // https://github.com/fabric8io/openshift-elasticsearch-plugin/issues/106 givenDocumentIsIndexed(".operations.1970.01.01", "test", "0", "operation0"); }
Example #6
Source File: IMAPImporterCl.java From elasticsearch-imap with Apache License 2.0 | 5 votes |
public static void start(Map<String, Object> settings, boolean embeddedMode) throws Exception { Settings.Builder builder = Settings.settingsBuilder(); for(String key: settings.keySet()) { builder.put(key, String.valueOf(settings.get(key))); } if(embeddedMode) { try { FileUtils.forceDelete(new File("./data")); } catch (Exception e) { //ignore } builder.put("path.home","."); builder.put("node.local", true); builder.put("http.cors.enabled", true); builder.put("http.cors.allow-origin", "*"); builder.put("cluster.name", "imap-embedded-"+System.currentTimeMillis()); node = new PluginAwareNode(builder.build(), (Collection) Lists.newArrayList(MapperAttachmentsPlugin.class)); node.start(); client = node.client(); }else { Settings eSettings = builder.build(); client = new TransportClient.Builder().settings(eSettings).build(); String[] hosts = eSettings.get("elasticsearch.hosts").split(","); for (int i = 0; i < hosts.length; i++) { String host = hosts[i]; String hostOnly = host.split(":")[0]; String portOnly = host.split(":")[1]; System.out.println("Adding "+hostOnly+":"+portOnly); ((TransportClient)client).addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(hostOnly), Integer.parseInt(portOnly))); } } imap = new IMAPImporter(settings, client); imap.start(); }
Example #7
Source File: AbstractIMAPRiverUnitTest.java From elasticsearch-imap with Apache License 2.0 | 4 votes |
@Before public void setUp() throws Exception { System.out.println("--------------------- SETUP " + name.getMethodName() + " -------------------------------------"); FileUtils.deleteQuietly(new File("target/data/")); MockMailbox.resetAll(); // Instantiates a local node & client esSetup = new PluginAwareNode(getSettingsBuilder(false, true).build(), (Collection) Lists.newArrayList(MapperAttachmentsPlugin.class)).start(); esSetup2 = new PluginAwareNode(getSettingsBuilder(true, false).build(), (Collection) Lists.newArrayList(MapperAttachmentsPlugin.class)).start(); esSetup3 = new PluginAwareNode(getSettingsBuilder(false, true).build(), (Collection) Lists.newArrayList(MapperAttachmentsPlugin.class)).start(); waitForGreenClusterState(esSetup.client()); }