pl.allegro.tech.embeddedelasticsearch.EmbeddedElastic Java Examples
The following examples show how to use
pl.allegro.tech.embeddedelasticsearch.EmbeddedElastic.
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: 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 #2
Source File: TestHelpers.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static EmbeddedElastic startElasticsearch(File installLocation) throws IOException, InterruptedException { EmbeddedElastic embeddedElastic = EmbeddedElastic.builder() .withElasticVersion(VERSION) .withSetting(PopularProperties.TRANSPORT_TCP_PORT, random.nextInt(10000) + 10000) .withSetting(PopularProperties.HTTP_PORT, random.nextInt(10000) + 10000) .withSetting(PopularProperties.CLUSTER_NAME, "cluster1") .withInstallationDirectory(installLocation) .withDownloadDirectory(new File("tempElasticsearchDownload")) // .withPlugin("analysis-stempel") .withStartTimeout(5, TimeUnit.MINUTES) .build(); embeddedElastic.start(); logger.info("Elasticearch using transport port: " + embeddedElastic.getTransportTcpPort()); logger.info("Elasticearch using http port: " + embeddedElastic.getHttpPort()); return embeddedElastic; }
Example #3
Source File: TestHelpers.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static EmbeddedElastic startElasticsearch(File installLocation, String javaHomePath) throws IOException, InterruptedException { EmbeddedElastic embeddedElastic = EmbeddedElastic.builder() .withElasticVersion(VERSION) .withSetting(PopularProperties.TRANSPORT_TCP_PORT, random.nextInt(10000) + 10000) .withSetting(PopularProperties.HTTP_PORT, random.nextInt(10000) + 10000) .withSetting(PopularProperties.CLUSTER_NAME, CLUSTER) .withInstallationDirectory(installLocation) .withJavaHome(JavaHomeOption.path(javaHomePath)) .withDownloadDirectory(new File(ELASTICSEARCH_DOWNLOAD_DIRECTORY)) // .withPlugin("analysis-stempel") .withStartTimeout(5, TimeUnit.MINUTES) .build(); embeddedElastic.start(); return embeddedElastic; }
Example #4
Source File: EmbeddedElasticsearchManager.java From c2mon with GNU Lesser General Public License v3.0 | 6 votes |
/** * Starts embedded Elasticsearch server (if it is not already running, does nothing otherwise). * * @param properties to setup the instance. */ public static void start(ElasticsearchProperties properties) { synchronized (EmbeddedElasticsearchManager.class) { if (embeddedNode == null) { log.info("********** TESTING PURPOSE ONLY *********"); log.info("Starting embedded Elasticsearch instance!"); embeddedNode = EmbeddedElastic.builder() .withElasticVersion(ELASTICSEARCH_VERSION) .withSetting(PopularProperties.HTTP_PORT, ElasticsearchClientType.REST.getDefaultPort()) .withSetting(PopularProperties.TRANSPORT_TCP_PORT, ElasticsearchClientType.TRANSPORT.getDefaultPort()) .withSetting(PopularProperties.CLUSTER_NAME, properties.getClusterName()) .withStartTimeout(2, TimeUnit.MINUTES) .build(); try { embeddedNode.start(); } catch (IOException | InterruptedException e) { log.error("An error occurred starting embedded Elasticsearch instance!", e); } } } }
Example #5
Source File: DashboardEmbeddedElastic.java From micronaut-microservices-poc with Apache License 2.0 | 5 votes |
static EmbeddedElastic getInstance() { if (embeddedElastic == null) { try { embeddedElastic = createAndRun(); } catch (IOException | InterruptedException e) { throw new RuntimeException("Cannot start embedded Elastic", e); } } return embeddedElastic; }
Example #6
Source File: DashboardEmbeddedElastic.java From micronaut-microservices-poc with Apache License 2.0 | 5 votes |
private static EmbeddedElastic createAndRun() throws IOException, InterruptedException { return EmbeddedElastic.builder() .withElasticVersion("6.6.2") .withSetting(PopularProperties.TRANSPORT_TCP_PORT, 9350) .withSetting(PopularProperties.HTTP_PORT, 9351) .withSetting(PopularProperties.CLUSTER_NAME, "my_cluster") .build() .start(); }
Example #7
Source File: TestHelpers.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void stopElasticsearch(EmbeddedElastic embeddedElastic, File installLocation) { embeddedElastic.stop(); try { FileUtils.deleteDirectory(installLocation); } catch (IOException e) { throw new RuntimeException(e); } }
Example #8
Source File: EmbeddedElasticsearchManager.java From c2mon with GNU Lesser General Public License v3.0 | 5 votes |
/** * @return an instance of running embedded Elasticsearch server. */ public static EmbeddedElastic getEmbeddedNode() { if (embeddedNode == null) { throw new IllegalStateException("Embedded Elasticsearh instance must be started first!"); } return embeddedNode; }
Example #9
Source File: EmbeddedElasticConfig.java From spring-content with Apache License 2.0 | 5 votes |
@Bean public EmbeddedElastic embeddedElastic() throws IOException, InterruptedException { return EmbeddedElastic.builder() .withElasticVersion("6.4.3") .withSetting(CLUSTER_NAME, "testCluster") .withSetting("discovery.zen.ping_timeout", 0) .withPlugin("ingest-attachment") .withEsJavaOpts("-Xms128m -Xmx512m") .withStartTimeout(1, MINUTES) .build() .start(); }
Example #10
Source File: ElasticsearchLockProviderTest.java From ShedLock with Apache License 2.0 | 5 votes |
@BeforeAll public static void startEmbeddedElastic() throws IOException, InterruptedException { embeddedElastic = EmbeddedElastic.builder() .withElasticVersion("6.4.0") .withSetting(PopularProperties.HTTP_PORT, EMBEDDED_ELASTIC_PORT) .withSetting(PopularProperties.CLUSTER_NAME, "my_cluster") .withStartTimeout(2, MINUTES) .withIndex(SCHEDLOCK_DEFAULT_INDEX, IndexSettings.builder() .withType(SCHEDLOCK_DEFAULT_TYPE, getSystemResourceAsStream("shedlock.mapping.json")) .withSettings(getSystemResourceAsStream("shedlock.settings.json")) .build()) .build() .start(); }
Example #11
Source File: ElasticsearchITBase.java From pinpoint with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpBeforeClass() throws Exception { embeddedElastic = EmbeddedElastic.builder() .withElasticVersion("6.8.0") .withSetting(PopularProperties.HTTP_PORT, 9200) .withEsJavaOpts("-Xms128m -Xmx512m") .withStartTimeout(2, MINUTES) .build() .start(); restHighLevelClient = new RestHighLevelClient( RestClient.builder( new HttpHost("127.0.0.1", 9200, "http"))); }
Example #12
Source File: ElasticsearchExecutorIT.java From pinpoint with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpBeforeClass() throws Exception { // BBoss support elasticsearch 1.x,2.x,5.x,6.x,7.x,+ // and we use elasticsearch 6.3.0 to test the Elasticsearch BBoss client plugin. // BBoss connect elasticsearch use localhost and http port 9200 default. // Here is a bboss web demo base spring boot and elasticsearch 5.x,6.x,7.x,8.x: // https://github.com/bbossgroups/es_bboss_web // // Here is a quickstart tutorial: // https://esdoc.bbossgroups.com/#/quickstart embeddedElastic = EmbeddedElastic.builder() .withElasticVersion("6.8.0") .withSetting(PopularProperties.HTTP_PORT, 9200) .withEsJavaOpts("-Xms128m -Xmx512m") .withStartTimeout(2, MINUTES) .build() .start(); //Build a elasticsearch client instance(Return a single instance but multithreaded security) with dsl config file elasticsearchbboss/car-mapping.xml. configRestClientInterface = ElasticSearchHelper.getConfigRestClientUtil("elasticsearchbboss/car-mapping.xml"); // Create an elasticsearch client interface instance with a specific Elasticserch datasource name and with dsl config file elasticsearchbboss/car-mapping.xml. //configRestClientInterface = ElasticSearchHelper.getConfigRestClientUtil("esdatasourceName","elasticsearchbboss/car-mapping.xml"); //build a elasticsearch client instance(Return a single instance but multithreaded security) for do not need dsl or direct dsl operations. clientInterface = ElasticSearchHelper.getRestClientUtil(); // Create an elasticsearch client interface instance with a specific Elasticserch datasource name //clientInterface = ElasticSearchHelper.getRestClientUtil("esdatasourceName"); // A multidatasource spring boot demo: https://github.com/bbossgroups/es_bboss_web/tree/multiesdatasource }
Example #13
Source File: ElasticsearchTransactionManagerTestCase.java From jstarcraft-core with Apache License 2.0 | 4 votes |
@BeforeClass public static void startEmbeddedElastic() throws IOException, InterruptedException { elasticServer = EmbeddedElastic.builder().withElasticVersion("6.8.8") .withSetting(PopularProperties.HTTP_PORT, EMBEDDED_ELASTIC_PORT) .withStartTimeout(2, TimeUnit.MINUTES) .withIndex(ElasticsearchTransactionManager.DEFAULT_INDEX, IndexSettings.builder() .withType(ElasticsearchTransactionManager.DEFAULT_TYPE, ClassLoader.getSystemResourceAsStream("ElasticsearchTransactionDefinition.mapping.json")) .build()) .build() .start(); }
Example #14
Source File: ApimanEmbeddedElastic.java From apiman with Apache License 2.0 | 4 votes |
private ApimanEmbeddedElastic(EmbeddedElastic embeddedElastic, long port) { this.elastic = embeddedElastic; this.pidPath = Paths.get(System.getenv("HOME"), "/.cache/apiman/embedded-es-pid-" + port); }
Example #15
Source File: ApimanEmbeddedElastic.java From apiman with Apache License 2.0 | 4 votes |
public Builder() { wrappedBuilder = pl.allegro.tech.embeddedelasticsearch.EmbeddedElastic.builder(); }