pl.allegro.tech.embeddedelasticsearch.PopularProperties Java Examples
The following examples show how to use
pl.allegro.tech.embeddedelasticsearch.PopularProperties.
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 |
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 #6
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 #7
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 #8
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 #9
Source File: ESMetricsAccessorTest.java From apiman with Apache License 2.0 | 5 votes |
@BeforeClass public static void setup() throws Exception { File esDownloadCache = new File(System.getenv("HOME") + "/.cache/apiman/elasticsearch"); esDownloadCache.getParentFile().mkdirs(); locale = Locale.getDefault(); Locale.setDefault(Locale.US); node = ApimanEmbeddedElastic.builder() .withPort(19250) .withElasticVersion(ApimanEmbeddedElastic.getEsBuildVersion()) .withDownloadDirectory(esDownloadCache) .withSetting(PopularProperties.CLUSTER_NAME, "apiman") .withStartTimeout(1, TimeUnit.MINUTES) .withCleanInstallationDirectoryOnStop(true) .build() .start(); // Delete, refresh and create new client client = createJestClient(); client.execute(new DeleteIndex.Builder("apiman_metrics").build()); client.execute(new Flush.Builder().force().build()); DefaultEsClientFactory.clearClientCache(); // Because of the delete above, the metrics fields need reinitialising with the index // mappings otherwise everything will screw up. See apiman_metrics-settings.json client = createJestClient(); // Load test loadTestData(); client.execute(new Flush.Builder().force().build()); DefaultEsClientFactory.clearClientCache(); }
Example #10
Source File: ApimanEmbeddedElastic.java From apiman with Apache License 2.0 | 5 votes |
public Builder withPort(String portRange) { wrappedBuilder.withSetting(PopularProperties.HTTP_PORT, portRange); if (portRange.contains("-")) { this.port = Integer.valueOf(portRange.split("-")[0].trim()); } else { this.port = Integer.valueOf(portRange); } return this; }
Example #11
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 #12
Source File: Bootstrapper.java From apiman with Apache License 2.0 | 4 votes |
/** * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) */ @Override public void contextInitialized(ServletContextEvent sce) { DistroESConfig config = new DistroESConfig(); File esHome = getDataDir(); if (esHome == null) { System.out.println("--------------------------------------------------------------"); System.err.println("No apiman-es data directory found. Embedded ES *not* started."); System.out.println("--------------------------------------------------------------"); return; } if (!esHome.exists()) { esHome.mkdirs(); } System.out.println("------------------------------------------------------------"); System.out.println("Starting apiman-es."); System.out.println(" HTTP Ports: " + config.getHttpPortRange()); System.out.println(" Transport Ports: " + config.getTransportPortRange()); System.out.println(" Bind Host: " + config.getBindHost()); System.out.println(" ES Data Dir: " + esHome); System.out.println("------------------------------------------------------------"); String clusterName = "apiman"; try { URL esDistroUrl = resolveEsDistro(sce); File tmpDir = new File(getTempDir()); Builder builder = ApimanEmbeddedElastic.builder() .withPort(config.getHttpPortRange()) .withDownloadUrl(esDistroUrl) .withDownloadDirectory(tmpDir) .withInstallationDirectory(tmpDir) .withSetting("path.data", esHome) .withCleanInstallationDirectoryOnStop(false) .withSetting(PopularProperties.TRANSPORT_TCP_PORT, config.getTransportPortRange()) .withSetting(PopularProperties.CLUSTER_NAME, clusterName) .withStartTimeout(1, TimeUnit.MINUTES); if (config.getBindHost() != null) { builder.withSetting("network.bind_host", config.getBindHost()); } node = builder.build().start(); } catch (IOException | InterruptedException e) { throw new RuntimeException(e); } System.out.println("-----------------------------"); System.out.println("apiman-es started!"); System.out.println("-----------------------------"); }
Example #13
Source File: ApimanEmbeddedElastic.java From apiman with Apache License 2.0 | 4 votes |
public Builder withPort(Integer port) { wrappedBuilder.withSetting(PopularProperties.HTTP_PORT, port); this.port = port; return this; }