/** * Starts an ElasticSearch node. * @return the started node. */ public static Node startEsNode() { Node node = NodeBuilder.nodeBuilder().data(true).settings( Settings.settingsBuilder() .put(ClusterName.SETTING, EsConstants.CLUSTER_NAME) .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) .put(EsExecutors.PROCESSORS, 1) .put("http.enabled", true) .put("index.percolator.map_unmapped_fields_as_string", true) .put("index.store.type", "mmapfs") .put("path.home", "./data") ).build(); node.start(); return node; }
/** * create a elasticsearch node client (embedded elasticsearch) * @param settings */ public ElasticsearchClient(final Settings.Builder settings) { // create a node this.elasticsearchNode = NodeBuilder.nodeBuilder().local(false).settings(settings).node(); // create a client this.elasticsearchClient = elasticsearchNode.client(); }
node = nodeBuilder().clusterName(clusterName).settings(settings).node(); node.start(); client = node.client();
.settings(settings) .client(true) .data(false)
Node node = NodeBuilder.nodeBuilder().settings( settings ).client( true ).data( false ).node();
@Override public Connection connect(Configuration config) throws IOException { log.debug("Configuring Node Client"); ImmutableSettings.Builder settingsBuilder = settingsBuilder(config); if (config.has(ElasticSearchIndex.TTL_INTERVAL)) { String k = "indices.ttl.interval"; settingsBuilder.put(k, config.get(ElasticSearchIndex.TTL_INTERVAL)); log.debug("Set {}: {}", k, config.get(ElasticSearchIndex.TTL_INTERVAL)); } makeLocalDirsIfNecessary(settingsBuilder, config); NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().settings(settingsBuilder.build()); // Apply explicit Titan properties file overrides (otherwise conf-file or ES defaults apply) if (config.has(ElasticSearchIndex.CLIENT_ONLY)) { boolean clientOnly = config.get(ElasticSearchIndex.CLIENT_ONLY); nodeBuilder.client(clientOnly).data(!clientOnly); } if (config.has(ElasticSearchIndex.LOCAL_MODE)) nodeBuilder.local(config.get(ElasticSearchIndex.LOCAL_MODE)); if (config.has(ElasticSearchIndex.LOAD_DEFAULT_NODE_SETTINGS)) nodeBuilder.loadConfigSettings(config.get(ElasticSearchIndex.LOAD_DEFAULT_NODE_SETTINGS)); Node node = nodeBuilder.node(); Client client = node.client(); return new Connection(node, client); } };
@Test public void testIndexCreationOptions() throws InterruptedException, BackendException { final int shards = 77; ElasticsearchRunner esr = new ElasticsearchRunner(".", "indexCreationOptions.yml"); esr.start(); CommonsConfiguration cc = new CommonsConfiguration(new BaseConfiguration()); cc.set("index." + INDEX_NAME + ".elasticsearch.create.ext.number_of_shards", String.valueOf(shards)); cc.set("index." + INDEX_NAME + ".elasticsearch.ext.cluster.name", "indexCreationOptions"); ModifiableConfiguration config = new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS, cc, BasicConfiguration.Restriction.NONE); config.set(INTERFACE, ElasticSearchSetup.NODE.toString(), INDEX_NAME); Configuration indexConfig = config.restrictTo(INDEX_NAME); IndexProvider idx = new ElasticSearchIndex(indexConfig); simpleWriteAndQuery(idx); ImmutableSettings.Builder settingsBuilder = ImmutableSettings.settingsBuilder(); settingsBuilder.put("discovery.zen.ping.multicast.enabled", "false"); settingsBuilder.put("discovery.zen.ping.unicast.hosts", "localhost,127.0.0.1:9300"); settingsBuilder.put("cluster.name", "indexCreationOptions"); NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().settings(settingsBuilder.build()); nodeBuilder.client(true).data(false).local(false); Node n = nodeBuilder.build().start(); GetSettingsResponse response = n.client().admin().indices().getSettings(new GetSettingsRequest().indices("titan")).actionGet(); assertEquals(String.valueOf(shards), response.getSetting("titan", "index.number_of_shards")); idx.close(); n.stop(); esr.stop(); }
@Bean public ElasticsearchOperations elasticsearchTemplate() { NodeBuilder nodeBuilder = nodeBuilder(); nodeBuilder.settings().put("path.home",System.getenv("ES_HOME")); return new ElasticsearchTemplate(nodeBuilder().local(true).node().client()); }
@BeforeClass public static void setUpBeforeClass() throws Exception { Builder builder = Settings.settingsBuilder(); builder.put("path.home", "target/data"); node = new NodeBuilder().settings(builder).node(); }
/** * Sets the up before class. * * @throws Exception * the exception */ @BeforeClass public static void setUpBeforeClass() throws Exception { Builder builder = Settings.settingsBuilder(); builder.put("path.home", "target/data"); node = new NodeBuilder().settings(builder).node(); }
@BeforeClass public static void setUpBeforeClass() throws Exception { Builder builder = Settings.settingsBuilder(); builder.put("path.home", "target/data"); node = new NodeBuilder().settings(builder).node(); }
@BeforeClass public static void setUpBeforeClass() throws Exception { Builder builder = Settings.settingsBuilder(); builder.put("path.home", "target/data"); node = new NodeBuilder().settings(builder).node(); }
@BeforeClass public static void setUpBeforeClass() throws Exception { Builder builder = Settings.settingsBuilder(); builder.put("path.home", "target/data"); node = new NodeBuilder().settings(builder).node(); }
/** * Sets the up before class. * * @throws Exception * the exception */ @BeforeClass public static void setUpBeforeClass() throws Exception { Builder builder = Settings.settingsBuilder(); builder.put("path.home", "target/data"); node = new NodeBuilder().settings(builder).node(); }
/** * Sets the up before class. * * @throws Exception * the exception */ @BeforeClass public static void setUpBeforeClass() throws Exception { Builder builder = Settings.settingsBuilder(); builder.put("path.home", "target/data"); node = new NodeBuilder().settings(builder).node(); }
@Before public void setup() throws Exception { if (!checkIfServerRunning()) { Builder builder = Settings.settingsBuilder(); builder.put("path.home", "target/data"); node = new NodeBuilder().settings(builder).node(); } }
@Before public void setUp() throws Exception { if (!checkIfServerRunning()) { Builder builder = Settings.settingsBuilder(); builder.put("path.home", "target/data"); node = new NodeBuilder().settings(builder).node(); } _PU = "es-pu"; setUpInternal(); }
@Before public void setup() { if (!checkIfServerRunning()) { Builder builder = Settings.settingsBuilder(); builder.put("path.home", "target/data"); node = new NodeBuilder().settings(builder).node(); } persistenceUnit = "esMappedSuperClass-pu"; setupInternal(); }
@Before public void setup() throws Exception { if (!checkIfServerRunning()) { Builder builder = Settings.settingsBuilder(); builder.put("path.home", "target/data"); node = new NodeBuilder().settings(builder).node(); } emf = getEntityManagerFactory(); }