org.elasticsearch.node.NodeValidationException Java Examples
The following examples show how to use
org.elasticsearch.node.NodeValidationException.
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: ElasticsearchRestClientTest.java From java-specialagent with Apache License 2.0 | 6 votes |
@BeforeClass @SuppressWarnings({"rawtypes", "unchecked"}) public static void startElasticsearch() throws NodeValidationException { final Settings settings = Settings.builder() .put("path.home", ES_WORKING_DIR) .put("path.data", ES_WORKING_DIR + "/data") .put("path.logs", ES_WORKING_DIR + "/logs") .put("transport.type", "netty4") .put("http.type", "netty4") .put("cluster.name", clusterName) .put("http.port", HTTP_PORT) .put("transport.tcp.port", HTTP_TRANSPORT_PORT) .put("network.host", "127.0.0.1") .build(); final Collection plugins = Collections.singletonList(Netty4Plugin.class); node = new PluginConfigurableNode(settings, plugins); node.start(); }
Example #2
Source File: ElasticsearchAwareTest.java From arctic-sea with Apache License 2.0 | 6 votes |
@BeforeAll public static void init() throws IOException, InterruptedException, NodeValidationException { logger.debug("Starting embedded node"); String resource = "elasticsearch_embedded.yml"; Settings.Builder settings = Settings.builder().loadFromStream(resource, ElasticsearchAwareTest.class.getResourceAsStream(resource), false); embeddedNode = EmbeddedElastic.builder().withElasticVersion("5.0.0") .withSetting(PopularProperties.TRANSPORT_TCP_PORT, 9300) .withSetting(PopularProperties.CLUSTER_NAME, "elasticsearch").build(); embeddedNode.start(); logger.debug("Started embedded node"); }
Example #3
Source File: EmbeddedElasticsearchServer.java From fast-elasticsearch-vector-scoring with Apache License 2.0 | 6 votes |
private EmbeddedElasticsearchServer(String defaultDataDirectory, int port) throws NodeValidationException { this.dataDirectory = defaultDataDirectory; this.port = port; Settings.Builder settings = Settings.builder() .put("http.enabled", "true") .put("transport.type", "local") .put("http.type", "netty3") .put("path.data", dataDirectory) .put("path.home", DEFAULT_HOME_DIRECTORY) .put("script.inline", "on") .put("node.max_local_storage_nodes", 10000) .put("script.stored", "on"); startNodeInAvailablePort(settings); }
Example #4
Source File: EmbeddedElasticsearchServer.java From fast-elasticsearch-vector-scoring with Apache License 2.0 | 6 votes |
private void startNodeInAvailablePort(Settings.Builder settings) throws NodeValidationException { int findFreePortRetries = MAX_PORT_RETRIES; boolean success = false; while(!success) { try { settings.put("http.port", String.valueOf(this.port)); // this a hack in order to load Groovy plug in since we want to enable the usage of scripts node = new NodeExt(settings.build() , Arrays.asList(Netty3Plugin.class, PainlessPlugin.class, ReindexPlugin.class, VectorScoringPlugin.class)); node.start(); success = true; System.out.println(EmbeddedElasticsearchServer.class.getName() + ": Using port: " + this.port); } catch (BindHttpException exception) { if(findFreePortRetries == 0) { System.out.println("Could not find any free port in range: [" + (this.port - MAX_PORT_RETRIES) + " - " + this.port+"]"); throw exception; } findFreePortRetries--; System.out.println("Port already in use (" + this.port + "). Trying another port..."); this.port = randomPort(); } } }
Example #5
Source File: NodeTestConfig.java From elastic-crud with Apache License 2.0 | 6 votes |
@Bean(destroyMethod="close") Node newNode() throws NodeValidationException { final Path tempDir = createTempDir().toPath(); final Settings settings = Settings.builder() .put(ClusterName.CLUSTER_NAME_SETTING.getKey(), new ClusterName("single-node-cluster" + System.nanoTime())) .put(Environment.PATH_HOME_SETTING.getKey(), tempDir) .put(Environment.PATH_REPO_SETTING.getKey(), tempDir.resolve("repo")) .put(Environment.PATH_SHARED_DATA_SETTING.getKey(), createTempDir().getParent()) .put("node.name", "single-node") .put("script.inline", "true") .put("script.stored", "true") .put(ScriptService.SCRIPT_MAX_COMPILATIONS_PER_MINUTE.getKey(), 1000) .put(EsExecutors.PROCESSORS_SETTING.getKey(), 1) .put(NetworkModule.HTTP_ENABLED.getKey(), false) .put("discovery.type", "zen") .put("transport.type", "local") .put(Node.NODE_DATA_SETTING.getKey(), true) .put(NODE_ID_SEED_SETTING.getKey(), System.nanoTime()) .build(); return new Node(settings).start(); // NOSONAR }
Example #6
Source File: HadoopFormatIOElasticTest.java From beam with Apache License 2.0 | 6 votes |
static void startElasticEmbeddedServer() throws NodeValidationException { Settings settings = Settings.builder() .put("node.data", TRUE) .put("network.host", ELASTIC_IN_MEM_HOSTNAME) .put("http.port", port) .put("path.data", elasticTempFolder.getRoot().getPath()) .put("path.home", elasticTempFolder.getRoot().getPath()) .put("transport.type", "local") .put("http.enabled", TRUE) .put("node.ingest", TRUE) .build(); node = new PluginNode(settings); node.start(); LOG.info("Elastic in memory server started."); prepareElasticIndex(); LOG.info( "Prepared index " + ELASTIC_INDEX_NAME + "and populated data on elastic in memory server."); }
Example #7
Source File: LocalElasticSearch.java From core-ng-project with Apache License 2.0 | 6 votes |
public HttpHost start() { var watch = new StopWatch(); this.dataPath = Files.tempDir(); try { Settings.Builder settings = Settings.builder(); settings.put(ClusterName.CLUSTER_NAME_SETTING.getKey(), "test") .put(Node.NODE_NAME_SETTING.getKey(), "test") .put(Environment.PATH_HOME_SETTING.getKey(), dataPath) .put(NetworkService.GLOBAL_NETWORK_BIND_HOST_SETTING.getKey(), "_local_") .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE); node = new LocalNode(settings.build()); node.start(); // on same local server, there may be multiple es started, e.g. multiple test jobs on shared build server, this is to retrieve actual http port return new HttpHost("localhost", node.injector().getInstance(HttpServerTransport.class).boundAddress().publishAddress().getPort()); } catch (NodeValidationException e) { throw new Error(e); } finally { logger.info("create local elasticsearch node, dataPath={}, elapsed={}", dataPath, watch.elapsed()); } }
Example #8
Source File: EmbeddedElasticsearch5.java From baleen with Apache License 2.0 | 6 votes |
public EmbeddedElasticsearch5(Path dataPath, String clusterName, int httpPort, int transportPort) throws NodeValidationException { this.clusterName = clusterName; this.httpPort = httpPort; this.transportPort = transportPort; this.dataPath = dataPath; // NB 'transport.type' is not 'local' as connecting via separate transport client Settings settings = Settings.builder() .put("path.home", dataPath.toString()) .put("cluster.name", clusterName) .put("http.port", Integer.toString(httpPort)) .put("transport.tcp.port", Integer.toString(transportPort)) .put("http.enabled", true) .build(); Collection<Class<? extends Plugin>> plugins = Collections.singletonList(Netty4Plugin.class); node = new PluginConfigurableNode(settings, plugins); node.start(); }
Example #9
Source File: ElasticsearchServerServlet.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Override public void init() throws ServletException { System.setProperty("es.set.netty.runtime.available.processors", "false"); Settings settings = Settings.builder() .put("http.port", AvailablePortFinder.getAndStoreNextAvailable("es-port.txt")) .put("http.cors.enabled", true) .put("http.cors.allow-origin", "*") .put("path.data", DATA_PATH) .put("path.home", HOME_PATH) .build(); List<Class<? extends Plugin>> plugins = new ArrayList<>(); plugins.add(Netty4Plugin.class); node = new ElasticsearchNode(settings, plugins); try { node.start(); } catch (NodeValidationException e) { throw new ServletException(e); } }
Example #10
Source File: ElasticsearchClusterRunner.java From elasticsearch-cluster-runner with Apache License 2.0 | 6 votes |
/** * Start a closed node. * * @param i the number of nodes * @return true if the node is started. */ @SuppressWarnings("resource") public boolean startNode(final int i) { if (i >= nodeList.size()) { return false; } if (!nodeList.get(i).isClosed()) { return false; } final Node node = new ClusterRunnerNode(envList.get(i), pluginList); try { node.start(); nodeList.set(i, node); return true; } catch (final NodeValidationException e) { print(e.getLocalizedMessage()); } return false; }
Example #11
Source File: InternalTestCluster.java From crate with Apache License 2.0 | 5 votes |
void startNode() { try { node.start(); } catch (NodeValidationException e) { throw new RuntimeException(e); } }
Example #12
Source File: EmbeddedElasticsearchNode.java From Quicksql with MIT License | 5 votes |
/** * Starts current node */ public void start() { Preconditions.checkState(!isStarted, "already started"); try { node.start(); this.isStarted = true; } catch (NodeValidationException e) { throw new RuntimeException(e); } }
Example #13
Source File: BootstrapChecks.java From crate with Apache License 2.0 | 5 votes |
/** * Executes the bootstrap checks if the node has the transport protocol bound to a non-loopback interface. If the system property * {@code es.enforce.bootstrap.checks} is set to {@code true} then the bootstrap checks will be enforced regardless of whether or not * the transport protocol is bound to a non-loopback interface. * * @param boundTransportAddress the node network bindings */ static void check(final Settings settings, final BoundTransportAddress boundTransportAddress, List<BootstrapCheck> additionalChecks) throws NodeValidationException { final List<BootstrapCheck> builtInChecks = checks(); final List<BootstrapCheck> combinedChecks = new ArrayList<>(builtInChecks); combinedChecks.addAll(additionalChecks); check(settings, enforceLimits(boundTransportAddress, DiscoveryModule.DISCOVERY_TYPE_SETTING.get(settings)), Collections.unmodifiableList(combinedChecks)); }
Example #14
Source File: CrateDB.java From crate with Apache License 2.0 | 5 votes |
private void init(final boolean daemonize, final boolean quiet, Environment env) throws NodeValidationException, UserException { try { BootstrapProxy.init(!daemonize, quiet, env); } catch (BootstrapException | RuntimeException e) { // format exceptions to the console in a special way // to avoid 2MB stacktraces from guice, etc. throw new StartupExceptionProxy(e); } }
Example #15
Source File: CrateDB.java From crate with Apache License 2.0 | 5 votes |
@Override protected void execute(Terminal terminal, OptionSet options, Environment env) throws Exception { if (options.nonOptionArguments().isEmpty() == false) { throw new UserException(ExitCodes.USAGE, "Positional arguments not allowed, found " + options.nonOptionArguments()); } if (options.has(versionOption)) { if (options.has(daemonizeOption) || options.has(pidfileOption)) { throw new UserException(ExitCodes.USAGE, "CrateDB version option is mutually exclusive with any other option"); } terminal.println("Version: " + Version.CURRENT + ", Build: " + Build.CURRENT.hashShort() + "/" + Build.CURRENT.timestamp() + ", JVM: " + JvmInfo.jvmInfo().version()); return; } final boolean daemonize = options.has(daemonizeOption); final Path pidFile = pidfileOption.value(options); env = addPidFileSetting(pidFile, env); final boolean quiet = options.has(quietOption); try { init(daemonize, quiet, env); } catch (NodeValidationException e) { throw new UserException(ExitCodes.CONFIG, e.getMessage()); } }
Example #16
Source File: EmbeddedElasticsearchNode.java From immutables with Apache License 2.0 | 5 votes |
/** * Starts current node */ void start() { Preconditions.checkState(!isStarted, "already started"); try { node.start(); this.isStarted = true; } catch (NodeValidationException e) { throw new RuntimeException(e); } }
Example #17
Source File: MockElasticsearchServer.java From foxtrot with Apache License 2.0 | 5 votes |
public MockElasticsearchServer(String directory) throws NodeValidationException { this.DATA_DIRECTORY = UUID.randomUUID() .toString() + "/" + directory; Settings settings = Settings.builder() .put("http.enabled", "false") .put("path.home", "target/" + DATA_DIRECTORY) .put("transport.type", "local") .build(); Stopwatch stopwatch = Stopwatch.createStarted(); node = new Node(settings).start(); System.out.printf("TimeTakenForEstart: %d%n", stopwatch.elapsed(TimeUnit.MILLISECONDS)); }
Example #18
Source File: EmbeddedElasticsearchNode.java From calcite with Apache License 2.0 | 5 votes |
/** * Starts current node */ public void start() { Preconditions.checkState(!isStarted, "already started"); try { node.start(); this.isStarted = true; } catch (NodeValidationException e) { throw TestUtil.rethrow(e); } }
Example #19
Source File: EmbeddedElasticsearch5.java From baleen with Apache License 2.0 | 5 votes |
public EmbeddedElasticsearch5() throws NodeValidationException, IOException { this( Files.createTempDirectory("elasticsearch"), "test-cluster", RandomPort.generate(), RandomPort.generate()); }
Example #20
Source File: EmbeddedElasticsearchNode.java From Quicksql with MIT License | 5 votes |
/** * Starts current node. */ public void start() { Preconditions.checkState(! isStarted, "already started"); try { node.start(); this.isStarted = true; } catch (NodeValidationException ex) { throw new RuntimeException(ex); } }
Example #21
Source File: BootstrapProxy.java From crate with Apache License 2.0 | 4 votes |
private void setup(boolean addShutdownHook, Environment environment) throws BootstrapException { Settings settings = environment.settings(); initializeNatives( BootstrapSettings.MEMORY_LOCK_SETTING.get(settings), BootstrapSettings.CTRLHANDLER_SETTING.get(settings)); // initialize probes before the security manager is installed initializeProbes(); if (addShutdownHook) { Runtime.getRuntime().addShutdownHook(new Thread(() -> { try { IOUtils.close(node); LoggerContext context = (LoggerContext) LogManager.getContext(false); Configurator.shutdown(context); } catch (IOException ex) { throw new ElasticsearchException("failed to stop node", ex); } })); } try { // look for jar hell final Logger logger = LogManager.getLogger(JarHell.class); JarHell.checkJarHell(logger::debug); } catch (IOException | URISyntaxException e) { throw new BootstrapException(e); } IfConfig.logIfNecessary(); node = new CrateNode(environment) { @Override protected void validateNodeBeforeAcceptingRequests(BoundTransportAddress boundTransportAddress, List<BootstrapCheck> bootstrapChecks) throws NodeValidationException { BootstrapChecks.check(settings, boundTransportAddress, bootstrapChecks); } }; }
Example #22
Source File: BootstrapProxy.java From crate with Apache License 2.0 | 4 votes |
private void start() throws NodeValidationException { node.start(); keepAliveThread.start(); }
Example #23
Source File: HadoopFormatIOElasticTest.java From beam with Apache License 2.0 | 4 votes |
@BeforeClass public static void startServer() throws NodeValidationException, IOException { port = NetworkTestHelper.getAvailableLocalPort(); ElasticEmbeddedServer.startElasticEmbeddedServer(); }
Example #24
Source File: EmbeddedElasticsearchServer.java From fast-elasticsearch-vector-scoring with Apache License 2.0 | 4 votes |
private EmbeddedElasticsearchServer(String dataDirectory) throws NodeValidationException { this(dataDirectory, randomPort()); }
Example #25
Source File: EmbeddedElasticsearchServer.java From fast-elasticsearch-vector-scoring with Apache License 2.0 | 4 votes |
public EmbeddedElasticsearchServer() throws NodeValidationException { this(DEFAULT_DATA_DIRECTORY); }
Example #26
Source File: BootstrapChecks.java From crate with Apache License 2.0 | 3 votes |
/** * Executes the provided checks and fails the node if {@code enforceLimits} is {@code true}, otherwise logs warnings. If the system * property {@code es.enforce.bootstrap.checks} is set to {@code true} then the bootstrap checks will be enforced regardless of whether * or not the transport protocol is bound to a non-loopback interface. * * @param enforceLimits {@code true} if the checks should be enforced or otherwise warned * @param checks the checks to execute */ static void check( final Settings settings, final boolean enforceLimits, final List<BootstrapCheck> checks) throws NodeValidationException { check(settings, enforceLimits, checks, Loggers.getLogger(BootstrapChecks.class)); }