Merge pull request #15354 from rjernst/just_node

Remove NodeBuilder
This commit is contained in:
Ryan Ernst 2015-12-10 19:19:55 -08:00
commit 93de1ed606
39 changed files with 126 additions and 357 deletions

View File

@ -37,7 +37,6 @@ import org.elasticsearch.monitor.jvm.JvmInfo;
import org.elasticsearch.monitor.os.OsProbe; import org.elasticsearch.monitor.os.OsProbe;
import org.elasticsearch.monitor.process.ProcessProbe; import org.elasticsearch.monitor.process.ProcessProbe;
import org.elasticsearch.node.Node; import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.elasticsearch.node.internal.InternalSettingsPreparer; import org.elasticsearch.node.internal.InternalSettingsPreparer;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -175,8 +174,7 @@ final class Bootstrap {
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true) .put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true)
.build(); .build();
NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().settings(nodeSettings); node = new Node(nodeSettings);
node = nodeBuilder.build();
} }
/** /**

View File

@ -108,8 +108,6 @@ import static org.elasticsearch.common.settings.Settings.settingsBuilder;
/** /**
* A node represent a node within a cluster (<tt>cluster.name</tt>). The {@link #client()} can be used * A node represent a node within a cluster (<tt>cluster.name</tt>). The {@link #client()} can be used
* in order to use a {@link Client} to perform actions/operations against the cluster. * in order to use a {@link Client} to perform actions/operations against the cluster.
* <p>In order to create a node, the {@link NodeBuilder} can be used. When done with it, make sure to
* call {@link #close()} on it.
*/ */
public class Node implements Releasable { public class Node implements Releasable {

View File

@ -1,152 +0,0 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.node;
import org.elasticsearch.common.settings.Settings;
/**
* A node builder is used to construct a {@link Node} instance.
* <p>
* Settings will be loaded relative to the ES home (with or without <tt>config/</tt> prefix) and if not found,
* within the classpath (with or without <tt>config/</tt> prefix). The settings file loaded can either be named
* <tt>elasticsearch.yml</tt> or <tt>elasticsearch.json</tt>).
* <p>
* Explicit settings can be passed by using the {@link #settings(org.elasticsearch.common.settings.Settings)} method.
* <p>
* In any case, settings will be resolved from system properties as well that are either prefixed with <tt>es.</tt>
* or <tt>elasticsearch.</tt>.
* <p>
* An example for creating a simple node with optional settings loaded from the classpath:
* <pre>
* Node node = NodeBuilder.nodeBuilder().node();
* </pre>
* <p>
* An example for creating a node with explicit settings (in this case, a node in the cluster that does not hold
* data):
* <pre>
* Node node = NodeBuilder.nodeBuilder()
* .settings(Settings.settingsBuilder().put("node.data", false)
* .node();
* </pre>
* <p>
* When done with the node, make sure you call {@link Node#close()} on it.
*
*
*/
public class NodeBuilder {
private final Settings.Builder settings = Settings.settingsBuilder();
/**
* A convenient factory method to create a {@link NodeBuilder}.
*/
public static NodeBuilder nodeBuilder() {
return new NodeBuilder();
}
/**
* Set addition settings simply by working directly against the settings builder.
*/
public Settings.Builder settings() {
return settings;
}
/**
* Set addition settings simply by working directly against the settings builder.
*/
public Settings.Builder getSettings() {
return settings;
}
/**
* Explicit node settings to set.
*/
public NodeBuilder settings(Settings.Builder settings) {
return settings(settings.build());
}
/**
* Explicit node settings to set.
*/
public NodeBuilder settings(Settings settings) {
this.settings.put(settings);
return this;
}
/**
* Is the node going to be a client node which means it will hold no data (<tt>node.data</tt> is
* set to <tt>false</tt>) and other optimizations by different modules.
*
* @param client Should the node be just a client node or not.
*/
public NodeBuilder client(boolean client) {
settings.put("node.client", client);
return this;
}
/**
* Is the node going to be allowed to allocate data (shards) to it or not. This setting map to
* the <tt>node.data</tt> setting. Note, when setting {@link #client(boolean)}, the node will
* not hold any data by default.
*
* @param data Should the node be allocated data to or not.
*/
public NodeBuilder data(boolean data) {
settings.put("node.data", data);
return this;
}
/**
* Is the node a local node. A local node is a node that uses a local (JVM level) discovery and
* transport. Other (local) nodes started within the same JVM (actually, class-loader) will be
* discovered and communicated with. Nodes outside of the JVM will not be discovered.
*
* @param local Should the node be local or not
*/
public NodeBuilder local(boolean local) {
settings.put("node.local", local);
return this;
}
/**
* The cluster name this node is part of (maps to the <tt>cluster.name</tt> setting). Defaults
* to <tt>elasticsearch</tt>.
*
* @param clusterName The cluster name this node is part of.
*/
public NodeBuilder clusterName(String clusterName) {
settings.put("cluster.name", clusterName);
return this;
}
/**
* Builds the node without starting it.
*/
public Node build() {
return new Node(settings.build());
}
/**
* {@link #build()}s and starts the node.
*/
public Node node() {
return build().start();
}
}

View File

@ -18,7 +18,7 @@
*/ */
/** /**
* Allow to build a {@link org.elasticsearch.node.Node} using {@link org.elasticsearch.node.NodeBuilder} which is a * Allow to build a {@link org.elasticsearch.node.Node} which is a
* node within the cluster. * node within the cluster.
*/ */
package org.elasticsearch.node; package org.elasticsearch.node;

View File

@ -20,7 +20,6 @@
package org.elasticsearch.tribe; package org.elasticsearch.tribe;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction; import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
import org.elasticsearch.cluster.ClusterChangedEvent; import org.elasticsearch.cluster.ClusterChangedEvent;
@ -46,8 +45,6 @@ import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
import org.elasticsearch.discovery.DiscoveryService; import org.elasticsearch.discovery.DiscoveryService;
import org.elasticsearch.gateway.GatewayService; import org.elasticsearch.gateway.GatewayService;
import org.elasticsearch.node.Node; import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.rest.RestStatus; import org.elasticsearch.rest.RestStatus;
import java.util.EnumSet; import java.util.EnumSet;

View File

@ -28,7 +28,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.indices.IndexAlreadyExistsException; import org.elasticsearch.indices.IndexAlreadyExistsException;
import org.elasticsearch.monitor.jvm.JvmStats; import org.elasticsearch.monitor.jvm.JvmStats;
import org.elasticsearch.node.Node; import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
@ -46,13 +45,13 @@ public class AliasesBenchmark {
Settings settings = Settings.settingsBuilder() Settings settings = Settings.settingsBuilder()
.put("node.master", false).build(); .put("node.master", false).build();
Node node1 = NodeBuilder.nodeBuilder().settings( Node node1 = new Node(
Settings.settingsBuilder().put(settings).put("node.master", true) Settings.settingsBuilder().put(settings).put("node.master", true).build()
).node(); ).start();
Node[] otherNodes = new Node[NUM_ADDITIONAL_NODES]; Node[] otherNodes = new Node[NUM_ADDITIONAL_NODES];
for (int i = 0; i < otherNodes.length; i++) { for (int i = 0; i < otherNodes.length; i++) {
otherNodes[i] = NodeBuilder.nodeBuilder().settings(settings).node(); otherNodes[i] = new Node(settings).start();
} }
Client client = node1.client(); Client client = node1.client();

View File

@ -27,7 +27,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.indices.IndexAlreadyExistsException; import org.elasticsearch.indices.IndexAlreadyExistsException;
import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService; import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService;
import org.elasticsearch.node.Node; import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import java.util.UUID; import java.util.UUID;
@ -123,7 +122,7 @@ public class CircuitBreakerBenchmark {
} }
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
Node node = NodeBuilder.nodeBuilder().settings(Settings.settingsBuilder()).node(); Node node = new Node(Settings.EMPTY);
final Client client = node.client(); final Client client = node.client();
try { try {
try { try {

View File

@ -21,9 +21,9 @@ package org.elasticsearch.benchmark.get;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.common.StopWatch; import org.elasticsearch.common.StopWatch;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.SizeValue; import org.elasticsearch.common.unit.SizeValue;
import org.elasticsearch.node.Node; import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
// simple test for embedded / single remote lookup // simple test for embedded / single remote lookup
public class SimpleGetActionBenchmark { public class SimpleGetActionBenchmark {
@ -31,11 +31,11 @@ public class SimpleGetActionBenchmark {
public static void main(String[] args) { public static void main(String[] args) {
long OPERATIONS = SizeValue.parseSizeValue("300k").singles(); long OPERATIONS = SizeValue.parseSizeValue("300k").singles();
Node node = NodeBuilder.nodeBuilder().node(); Node node = new Node(Settings.EMPTY);
Client client; Client client;
if (false) { if (false) {
client = NodeBuilder.nodeBuilder().client(true).node().client(); client = new Node(Settings.builder().put("node.client", true).build()).start().client();
} else { } else {
client = node.client(); client = node.client();
} }

View File

@ -33,7 +33,6 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
/** /**
*/ */
@ -92,16 +91,12 @@ public class ManyMappingsBenchmark {
.put("") .put("")
.put(SETTING_NUMBER_OF_SHARDS, 5) .put(SETTING_NUMBER_OF_SHARDS, 5)
.put(SETTING_NUMBER_OF_REPLICAS, 0) .put(SETTING_NUMBER_OF_REPLICAS, 0)
.put("cluster.name", ManyMappingsBenchmark.class.getSimpleName())
.build(); .build();
String clusterName = ManyMappingsBenchmark.class.getSimpleName(); Node node = new Node(settings).start();
Node node = nodeBuilder().clusterName(clusterName)
.settings(settingsBuilder().put(settings))
.node();
if (TWO_NODES) { if (TWO_NODES) {
Node node2 = nodeBuilder().clusterName(clusterName) Node node2 = new Node(settings).start();
.settings(settingsBuilder().put(settings))
.node();
} }
Client client = node.client(); Client client = node.client();

View File

@ -19,9 +19,9 @@
package org.elasticsearch.benchmark.percolator; package org.elasticsearch.benchmark.percolator;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.action.percolate.PercolateResponse; import org.elasticsearch.action.percolate.PercolateResponse;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.common.StopWatch; import org.elasticsearch.common.StopWatch;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
@ -37,7 +37,6 @@ import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.rangeQuery; import static org.elasticsearch.index.query.QueryBuilders.rangeQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery; import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
/** /**
* *
@ -52,10 +51,10 @@ public class PercolatorStressBenchmark {
Node[] nodes = new Node[1]; Node[] nodes = new Node[1];
for (int i = 0; i < nodes.length; i++) { for (int i = 0; i < nodes.length; i++) {
nodes[i] = nodeBuilder().settings(settingsBuilder().put(settings).put("name", "node" + i)).node(); nodes[i] = new Node(settingsBuilder().put(settings).put("name", "node" + i).build()).start();
} }
Node clientNode = nodeBuilder().settings(settingsBuilder().put(settings).put("name", "client")).client(true).node(); Node clientNode = new Node(settingsBuilder().put(settings).put("name", "client").put("node.client", true).build()).start();
Client client = clientNode.client(); Client client = clientNode.client();
client.admin().indices().create(createIndexRequest("test")).actionGet(); client.admin().indices().create(createIndexRequest("test")).actionGet();

View File

@ -42,7 +42,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
/** /**
* *
@ -66,12 +65,9 @@ public class ReplicaRecoveryBenchmark {
.put(SETTING_NUMBER_OF_SHARDS, 1) .put(SETTING_NUMBER_OF_SHARDS, 1)
.put(SETTING_NUMBER_OF_REPLICAS, 0) .put(SETTING_NUMBER_OF_REPLICAS, 0)
.put(TransportModule.TRANSPORT_TYPE_KEY, "local") .put(TransportModule.TRANSPORT_TYPE_KEY, "local")
.put("cluster.name", ReplicaRecoveryBenchmark.class.getSimpleName())
.build(); .build();
Node node1 = new Node(settings).start();
String clusterName = ReplicaRecoveryBenchmark.class.getSimpleName();
Node node1 = nodeBuilder().clusterName(clusterName)
.settings(settingsBuilder().put(settings))
.node();
final ESLogger logger = ESLoggerFactory.getLogger("benchmark"); final ESLogger logger = ESLoggerFactory.getLogger("benchmark");
@ -100,9 +96,7 @@ public class ReplicaRecoveryBenchmark {
logger.info("--> starting another node and allocating a shard on it"); logger.info("--> starting another node and allocating a shard on it");
Node node2 = nodeBuilder().clusterName(clusterName) Node node2 = new Node(settings).start();
.settings(settingsBuilder().put(settings))
.node();
client1.admin().indices().prepareUpdateSettings(INDEX_NAME).setSettings(IndexMetaData.SETTING_NUMBER_OF_REPLICAS + ": 1").get(); client1.admin().indices().prepareUpdateSettings(INDEX_NAME).setSettings(IndexMetaData.SETTING_NUMBER_OF_REPLICAS + ": 1").get();

View File

@ -38,13 +38,11 @@ import org.elasticsearch.search.sort.ScriptSortBuilder;
import org.elasticsearch.search.sort.SortBuilders; import org.elasticsearch.search.sort.SortBuilders;
import org.joda.time.PeriodType; import org.joda.time.PeriodType;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Random; import java.util.Random;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
public class ScriptComparisonBenchmark { public class ScriptComparisonBenchmark {

View File

@ -35,7 +35,6 @@ import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
/** /**
* *

View File

@ -34,7 +34,6 @@ import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
/** /**
* *

View File

@ -35,7 +35,6 @@ import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
/** /**
* *

View File

@ -45,7 +45,6 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.index.query.QueryBuilders.matchQuery; import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
import static org.elasticsearch.index.query.QueryBuilders.prefixQuery; import static org.elasticsearch.index.query.QueryBuilders.prefixQuery;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
/** /**
*/ */
@ -61,7 +60,7 @@ public class SuggestSearchBenchMark {
Node[] nodes = new Node[1]; Node[] nodes = new Node[1];
for (int i = 0; i < nodes.length; i++) { for (int i = 0; i < nodes.length; i++) {
nodes[i] = nodeBuilder().settings(settingsBuilder().put(settings).put("name", "node" + i)).node(); nodes[i] = new Node(settingsBuilder().put(settings).put("name", "node" + i).build()).start();
} }
Client client = nodes[0].client(); Client client = nodes[0].client();

View File

@ -39,7 +39,6 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
import static org.elasticsearch.search.aggregations.AggregationBuilders.cardinality; import static org.elasticsearch.search.aggregations.AggregationBuilders.cardinality;
public class CardinalityAggregationSearchBenchmark { public class CardinalityAggregationSearchBenchmark {
@ -59,19 +58,15 @@ public class CardinalityAggregationSearchBenchmark {
.put("index.refresh_interval", "-1") .put("index.refresh_interval", "-1")
.put(SETTING_NUMBER_OF_SHARDS, 5) .put(SETTING_NUMBER_OF_SHARDS, 5)
.put(SETTING_NUMBER_OF_REPLICAS, 0) .put(SETTING_NUMBER_OF_REPLICAS, 0)
.put("cluster.name", CLUSTER_NAME)
.build(); .build();
Node[] nodes = new Node[1]; Node[] nodes = new Node[1];
for (int i = 0; i < nodes.length; i++) { for (int i = 0; i < nodes.length; i++) {
nodes[i] = nodeBuilder().clusterName(CLUSTER_NAME) nodes[i] = new Node(settingsBuilder().put(settings).put("name", "node" + i).build()).start();
.settings(settingsBuilder().put(settings).put("name", "node" + i))
.node();
} }
Node clientNode = nodeBuilder() Node clientNode = new Node(settingsBuilder().put(settings).put("name", "client").put("node.client", true).build()).start();
.clusterName(CLUSTER_NAME)
.settings(settingsBuilder().put(settings).put("name", "client")).client(true).node();
Client client = clientNode.client(); Client client = clientNode.client();
try { try {

View File

@ -21,7 +21,6 @@ package org.elasticsearch.benchmark.search.aggregations;
import com.carrotsearch.hppc.IntIntHashMap; import com.carrotsearch.hppc.IntIntHashMap;
import com.carrotsearch.hppc.ObjectHashSet; import com.carrotsearch.hppc.ObjectHashSet;
import com.carrotsearch.randomizedtesting.generators.RandomStrings; import com.carrotsearch.randomizedtesting.generators.RandomStrings;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse; import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse;
import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.bulk.BulkRequestBuilder;
@ -40,14 +39,18 @@ import org.elasticsearch.node.Node;
import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.transport.TransportModule; import org.elasticsearch.transport.TransportModule;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
/** /**
* *
@ -77,13 +80,10 @@ public class GlobalOrdinalsBenchmark {
.put(SETTING_NUMBER_OF_SHARDS, 1) .put(SETTING_NUMBER_OF_SHARDS, 1)
.put(SETTING_NUMBER_OF_REPLICAS, 0) .put(SETTING_NUMBER_OF_REPLICAS, 0)
.put(TransportModule.TRANSPORT_TYPE_KEY, "local") .put(TransportModule.TRANSPORT_TYPE_KEY, "local")
.put("cluster.name", GlobalOrdinalsBenchmark.class.getSimpleName())
.build(); .build();
String clusterName = GlobalOrdinalsBenchmark.class.getSimpleName(); node = new Node(settings).start();
node = nodeBuilder().clusterName(clusterName)
.settings(settingsBuilder().put(settings))
.node();
client = node.client(); client = node.client();
try { try {

View File

@ -20,7 +20,6 @@
package org.elasticsearch.benchmark.search.aggregations; package org.elasticsearch.benchmark.search.aggregations;
import com.carrotsearch.randomizedtesting.generators.RandomInts; import com.carrotsearch.randomizedtesting.generators.RandomInts;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.bulk.BulkResponse;
@ -42,7 +41,6 @@ import java.util.concurrent.TimeUnit;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
import static org.elasticsearch.search.aggregations.AggregationBuilders.percentiles; import static org.elasticsearch.search.aggregations.AggregationBuilders.percentiles;
public class HDRPercentilesAggregationBenchmark { public class HDRPercentilesAggregationBenchmark {
@ -68,19 +66,15 @@ public class HDRPercentilesAggregationBenchmark {
.put("index.refresh_interval", "-1") .put("index.refresh_interval", "-1")
.put(SETTING_NUMBER_OF_SHARDS, 5) .put(SETTING_NUMBER_OF_SHARDS, 5)
.put(SETTING_NUMBER_OF_REPLICAS, 0) .put(SETTING_NUMBER_OF_REPLICAS, 0)
.put("cluster.name", CLUSTER_NAME)
.build(); .build();
Node[] nodes = new Node[1]; Node[] nodes = new Node[1];
for (int i = 0; i < nodes.length; i++) { for (int i = 0; i < nodes.length; i++) {
nodes[i] = nodeBuilder().clusterName(CLUSTER_NAME) nodes[i] = new Node(settingsBuilder().put(settings).put("name", "node" + i).build()).start();
.settings(settingsBuilder().put(settings).put("name", "node" + i))
.node();
} }
Node clientNode = nodeBuilder() Node clientNode = new Node(settingsBuilder().put(settings).put("name", "client").put("node.client", true).build()).start();
.clusterName(CLUSTER_NAME)
.settings(settingsBuilder().put(settings).put("name", "client")).client(true).node();
Client client = clientNode.client(); Client client = clientNode.client();
try { try {

View File

@ -39,8 +39,9 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder; import static org.elasticsearch.search.aggregations.AggregationBuilders.dateHistogram;
import static org.elasticsearch.search.aggregations.AggregationBuilders.*; import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
import static org.elasticsearch.search.aggregations.AggregationBuilders.stats;
/** /**
* *
@ -58,15 +59,12 @@ public class HistogramAggregationSearchBenchmark {
.put("refresh_interval", "-1") .put("refresh_interval", "-1")
.put(SETTING_NUMBER_OF_SHARDS, 1) .put(SETTING_NUMBER_OF_SHARDS, 1)
.put(SETTING_NUMBER_OF_REPLICAS, 0) .put(SETTING_NUMBER_OF_REPLICAS, 0)
.put("cluster.name", HistogramAggregationSearchBenchmark.class.getSimpleName())
.build(); .build();
String clusterName = HistogramAggregationSearchBenchmark.class.getSimpleName(); Node node1 = new Node(settingsBuilder().put(settings).put("name", "node1").build()).start();
Node node1 = nodeBuilder()
.clusterName(clusterName)
.settings(settingsBuilder().put(settings).put("name", "node1")).node();
//Node clientNode = nodeBuilder().clusterName(clusterName).settings(settingsBuilder().put(settings).put("name", "client")).client(true).node();
//Node clientNode = new Node(settingsBuilder().put(settings).put("name", "client").put("node.client", true).build()).start();
Client client = node1.client(); Client client = node1.client();
long[] lValues = new long[NUMBER_OF_TERMS]; long[] lValues = new long[NUMBER_OF_TERMS];

View File

@ -39,7 +39,6 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
public class IncludeExcludeAggregationSearchBenchmark { public class IncludeExcludeAggregationSearchBenchmark {
@ -57,19 +56,15 @@ public class IncludeExcludeAggregationSearchBenchmark {
.put("index.refresh_interval", "-1") .put("index.refresh_interval", "-1")
.put(SETTING_NUMBER_OF_SHARDS, 1) .put(SETTING_NUMBER_OF_SHARDS, 1)
.put(SETTING_NUMBER_OF_REPLICAS, 0) .put(SETTING_NUMBER_OF_REPLICAS, 0)
.put("cluster.name", CLUSTER_NAME)
.build(); .build();
Node[] nodes = new Node[1]; Node[] nodes = new Node[1];
for (int i = 0; i < nodes.length; i++) { for (int i = 0; i < nodes.length; i++) {
nodes[i] = nodeBuilder().clusterName(CLUSTER_NAME) nodes[i] = new Node(settingsBuilder().put(settings).put("name", "node" + i).build()).start();
.settings(settingsBuilder().put(settings).put("name", "node" + i))
.node();
} }
Node clientNode = nodeBuilder() Node clientNode = new Node(settingsBuilder().put(settings).put("name", "client").put("node.client", true).build()).start();
.clusterName(CLUSTER_NAME)
.settings(settingsBuilder().put(settings).put("name", "client")).client(true).node();
Client client = clientNode.client(); Client client = clientNode.client();
try { try {

View File

@ -49,7 +49,6 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
import static org.elasticsearch.search.aggregations.AggregationBuilders.percentiles; import static org.elasticsearch.search.aggregations.AggregationBuilders.percentiles;
public class PercentilesAggregationSearchBenchmark { public class PercentilesAggregationSearchBenchmark {
@ -106,19 +105,15 @@ public class PercentilesAggregationSearchBenchmark {
.put("index.refresh_interval", "-1") .put("index.refresh_interval", "-1")
.put(SETTING_NUMBER_OF_SHARDS, 100) // to also test performance and accuracy of the reduce phase .put(SETTING_NUMBER_OF_SHARDS, 100) // to also test performance and accuracy of the reduce phase
.put(SETTING_NUMBER_OF_REPLICAS, 0) .put(SETTING_NUMBER_OF_REPLICAS, 0)
.put("cluster.name", CLUSTER_NAME)
.build(); .build();
Node[] nodes = new Node[1]; Node[] nodes = new Node[1];
for (int i = 0; i < nodes.length; i++) { for (int i = 0; i < nodes.length; i++) {
nodes[i] = nodeBuilder().clusterName(CLUSTER_NAME) nodes[i] = new Node(settingsBuilder().put(settings).put("name", "node" + i).build()).start();
.settings(settingsBuilder().put(settings).put("name", "node" + i))
.node();
} }
Node clientNode = nodeBuilder() Node clientNode = new Node(settingsBuilder().put(settings).put("name", "client").put("node.client", true).build()).start();
.clusterName(CLUSTER_NAME)
.settings(settingsBuilder().put(settings).put("name", "client")).client(true).node();
Client client = clientNode.client(); Client client = clientNode.client();
for (Distribution d : Distribution.values()) { for (Distribution d : Distribution.values()) {

View File

@ -42,7 +42,6 @@ import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery; import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
public class QueryFilterAggregationSearchBenchmark { public class QueryFilterAggregationSearchBenchmark {
@ -58,12 +57,11 @@ public class QueryFilterAggregationSearchBenchmark {
.put("index.refresh_interval", "-1") .put("index.refresh_interval", "-1")
.put(SETTING_NUMBER_OF_SHARDS, 2) .put(SETTING_NUMBER_OF_SHARDS, 2)
.put(SETTING_NUMBER_OF_REPLICAS, 0) .put(SETTING_NUMBER_OF_REPLICAS, 0)
.put("name", "node1")
.put("cluster.name", QueryFilterAggregationSearchBenchmark.class.getSimpleName())
.build(); .build();
String clusterName = QueryFilterAggregationSearchBenchmark.class.getSimpleName(); Node node1 = new Node(settings).start();
Node node1 = nodeBuilder()
.clusterName(clusterName)
.settings(settingsBuilder().put(settings).put("name", "node1")).node();
client = node1.client(); client = node1.client();
long[] lValues = new long[NUMBER_OF_TERMS]; long[] lValues = new long[NUMBER_OF_TERMS];

View File

@ -51,7 +51,6 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
/** /**
* *
@ -77,20 +76,15 @@ public class SubAggregationSearchCollectModeBenchmark {
.put("index.refresh_interval", "-1") .put("index.refresh_interval", "-1")
.put(SETTING_NUMBER_OF_SHARDS, 1) .put(SETTING_NUMBER_OF_SHARDS, 1)
.put(SETTING_NUMBER_OF_REPLICAS, 0) .put(SETTING_NUMBER_OF_REPLICAS, 0)
.put("cluster.name", SubAggregationSearchCollectModeBenchmark.class.getSimpleName())
.build(); .build();
String clusterName = SubAggregationSearchCollectModeBenchmark.class.getSimpleName();
nodes = new Node[1]; nodes = new Node[1];
for (int i = 0; i < nodes.length; i++) { for (int i = 0; i < nodes.length; i++) {
nodes[i] = nodeBuilder().clusterName(clusterName) nodes[i] = new Node(settingsBuilder().put(settings).put("name", "node" + i).build()).start();
.settings(settingsBuilder().put(settings).put("name", "node" + i))
.node();
} }
Node clientNode = nodeBuilder() Node clientNode = new Node(settingsBuilder().put(settings).put("name", "client").put("node.client", true).build()).start();
.clusterName(clusterName)
.settings(settingsBuilder().put(settings).put("name", "client")).client(true).node();
client = clientNode.client(); client = clientNode.client();
Thread.sleep(10000); Thread.sleep(10000);

View File

@ -20,7 +20,6 @@ package org.elasticsearch.benchmark.search.aggregations;
import com.carrotsearch.hppc.ObjectScatterSet; import com.carrotsearch.hppc.ObjectScatterSet;
import com.carrotsearch.randomizedtesting.generators.RandomStrings; import com.carrotsearch.randomizedtesting.generators.RandomStrings;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse; import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse;
import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.bulk.BulkRequestBuilder;
@ -52,7 +51,6 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
/** /**
* *
@ -77,14 +75,12 @@ public class TermsAggregationSearchAndIndexingBenchmark {
.put("refresh_interval", "-1") .put("refresh_interval", "-1")
.put(SETTING_NUMBER_OF_SHARDS, 1) .put(SETTING_NUMBER_OF_SHARDS, 1)
.put(SETTING_NUMBER_OF_REPLICAS, 0) .put(SETTING_NUMBER_OF_REPLICAS, 0)
.put("cluster.name", TermsAggregationSearchAndIndexingBenchmark.class.getSimpleName())
.build(); .build();
String clusterName = TermsAggregationSearchAndIndexingBenchmark.class.getSimpleName();
nodes = new Node[1]; nodes = new Node[1];
for (int i = 0; i < nodes.length; i++) { for (int i = 0; i < nodes.length; i++) {
nodes[i] = nodeBuilder().settings(settingsBuilder().put(settings).put("name", "node1")) nodes[i] = new Node(settingsBuilder().put(settings).put("name", "node" + i).build()).start();
.clusterName(clusterName)
.node();
} }
Client client = nodes[0].client(); Client client = nodes[0].client();

View File

@ -52,7 +52,6 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
/** /**
* *
@ -105,22 +104,15 @@ public class TermsAggregationSearchBenchmark {
.put("index.refresh_interval", "-1") .put("index.refresh_interval", "-1")
.put(SETTING_NUMBER_OF_SHARDS, 1) .put(SETTING_NUMBER_OF_SHARDS, 1)
.put(SETTING_NUMBER_OF_REPLICAS, 0) .put(SETTING_NUMBER_OF_REPLICAS, 0)
.put("cluster.name", TermsAggregationSearchBenchmark.class.getSimpleName())
.build(); .build();
String clusterName = TermsAggregationSearchBenchmark.class.getSimpleName();
nodes = new Node[1]; nodes = new Node[1];
for (int i = 0; i < nodes.length; i++) { for (int i = 0; i < nodes.length; i++) {
nodes[i] = nodeBuilder().clusterName(clusterName) nodes[i] = new Node(settingsBuilder().put(settings).put("name", "node" + i).put("path.home", ".").build()).start();
.settings(settingsBuilder().put(settings).put("path.home", "."))
.settings(settingsBuilder().put(settings).put("name", "node" + i))
.node();
} }
Node clientNode = nodeBuilder() Node clientNode = new Node(settingsBuilder().put(settings).put("name", "client").put("node.client", true).build()).start();
.clusterName(clusterName)
.settings(settingsBuilder().put(settings).put("name", "client"))
.settings(settingsBuilder().put(settings).put("path.home", ".")).client(true).node();
client = clientNode.client(); client = clientNode.client();
Thread.sleep(10000); Thread.sleep(10000);

View File

@ -55,7 +55,6 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
/** /**
* *
@ -80,14 +79,12 @@ public class TimeDataHistogramAggregationBenchmark {
.put("node.local", true) .put("node.local", true)
.put(SETTING_NUMBER_OF_SHARDS, 1) .put(SETTING_NUMBER_OF_SHARDS, 1)
.put(SETTING_NUMBER_OF_REPLICAS, 0) .put(SETTING_NUMBER_OF_REPLICAS, 0)
.put("cluster.name", TimeDataHistogramAggregationBenchmark.class.getSimpleName())
.build(); .build();
String clusterName = TimeDataHistogramAggregationBenchmark.class.getSimpleName();
Node[] nodes = new Node[1]; Node[] nodes = new Node[1];
for (int i = 0; i < nodes.length; i++) { for (int i = 0; i < nodes.length; i++) {
nodes[i] = nodeBuilder().clusterName(clusterName) nodes[i] = new Node(settingsBuilder().put(settings).put("name", "node" + i).build()).start();
.settings(settingsBuilder().put(settings).put("name", "node" + i))
.node();
} }
client = nodes[0].client(); client = nodes[0].client();

View File

@ -40,7 +40,6 @@ import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
import static org.elasticsearch.index.query.QueryBuilders.hasChildQuery; import static org.elasticsearch.index.query.QueryBuilders.hasChildQuery;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery; import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
/** /**
* *
@ -59,12 +58,10 @@ public class ChildSearchAndIndexingBenchmark {
.put("refresh_interval", "-1") .put("refresh_interval", "-1")
.put(SETTING_NUMBER_OF_SHARDS, 1) .put(SETTING_NUMBER_OF_SHARDS, 1)
.put(SETTING_NUMBER_OF_REPLICAS, 0) .put(SETTING_NUMBER_OF_REPLICAS, 0)
.put("cluster.name", ChildSearchAndIndexingBenchmark.class.getSimpleName())
.build(); .build();
String clusterName = ChildSearchAndIndexingBenchmark.class.getSimpleName(); Node node1 = new Node(settingsBuilder().put(settings).put("name", "node1").build()).start();
Node node1 = nodeBuilder().settings(settingsBuilder().put(settings).put("name", "node1"))
.clusterName(clusterName)
.node();
Client client = node1.client(); Client client = node1.client();
client.admin().cluster().prepareHealth(indexName).setWaitForGreenStatus().setTimeout("10s").execute().actionGet(); client.admin().cluster().prepareHealth(indexName).setWaitForGreenStatus().setTimeout("10s").execute().actionGet();

View File

@ -38,8 +38,12 @@ import static org.elasticsearch.client.Requests.createIndexRequest;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.index.query.QueryBuilders.*; import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder; import static org.elasticsearch.index.query.QueryBuilders.hasChildQuery;
import static org.elasticsearch.index.query.QueryBuilders.hasParentQuery;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
/** /**
* *
@ -70,16 +74,15 @@ public class ChildSearchBenchmark {
Settings.Builder settings = settingsBuilder() Settings.Builder settings = settingsBuilder()
.put("index.refresh_interval", "-1") .put("index.refresh_interval", "-1")
.put(SETTING_NUMBER_OF_SHARDS, 1) .put(SETTING_NUMBER_OF_SHARDS, 1)
.put(SETTING_NUMBER_OF_REPLICAS, 0); .put(SETTING_NUMBER_OF_REPLICAS, 0)
.put("cluster.name", ChildSearchBenchmark.class.getSimpleName());
// enable bwc parent child mode: // enable bwc parent child mode:
if (bwcMode) { if (bwcMode) {
settings.put("tests.mock.version", Version.V_1_6_0); settings.put("tests.mock.version", Version.V_1_6_0);
} }
String clusterName = ChildSearchBenchmark.class.getSimpleName(); Node node1 = new Node(settingsBuilder().put(settings).put("name", "node1").build()).start();
Node node1 = nodeBuilder().clusterName(clusterName)
.settings(settingsBuilder().put(settings.build()).put("name", "node1")).node();
Client client = node1.client(); Client client = node1.client();
int CHILD_COUNT = 15; int CHILD_COUNT = 15;

View File

@ -45,7 +45,6 @@ import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
import static org.elasticsearch.index.query.QueryBuilders.hasChildQuery; import static org.elasticsearch.index.query.QueryBuilders.hasChildQuery;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.index.query.QueryBuilders.matchQuery; import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
/** /**
* *
@ -57,12 +56,10 @@ public class ChildSearchShortCircuitBenchmark {
.put("index.refresh_interval", "-1") .put("index.refresh_interval", "-1")
.put(SETTING_NUMBER_OF_SHARDS, 1) .put(SETTING_NUMBER_OF_SHARDS, 1)
.put(SETTING_NUMBER_OF_REPLICAS, 0) .put(SETTING_NUMBER_OF_REPLICAS, 0)
.put("cluster.name", ChildSearchShortCircuitBenchmark.class.getSimpleName())
.build(); .build();
String clusterName = ChildSearchShortCircuitBenchmark.class.getSimpleName(); Node node1 = new Node(settingsBuilder().put(settings).put("name", "node1").build()).start();
Node node1 = nodeBuilder().clusterName(clusterName)
.settings(settingsBuilder().put(settings).put("name", "node1"))
.node();
Client client = node1.client(); Client client = node1.client();
long PARENT_COUNT = SizeValue.parseSizeValue("10M").singles(); long PARENT_COUNT = SizeValue.parseSizeValue("10M").singles();

View File

@ -28,11 +28,10 @@ import org.elasticsearch.common.unit.SizeValue;
import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.node.Node; import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.geoDistanceQuery;
import static org.elasticsearch.index.query.QueryBuilders.boolQuery; import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
import static org.elasticsearch.index.query.QueryBuilders.geoDistanceQuery;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
/** /**
@ -41,7 +40,8 @@ public class GeoDistanceSearchBenchmark {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Node node = NodeBuilder.nodeBuilder().clusterName(GeoDistanceSearchBenchmark.class.getSimpleName()).node(); Settings settings = Settings.builder().put("cluste.name", GeoDistanceSearchBenchmark.class.getSimpleName()).build();
Node node = new Node(settings).start();
Client client = node.client(); Client client = node.client();
ClusterHealthResponse clusterHealthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); ClusterHealthResponse clusterHealthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();

View File

@ -39,7 +39,6 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
/** /**
*/ */
@ -52,9 +51,7 @@ public class NestedSearchBenchMark {
.put(SETTING_NUMBER_OF_REPLICAS, 0) .put(SETTING_NUMBER_OF_REPLICAS, 0)
.build(); .build();
Node node1 = nodeBuilder() Node node1 = new Node(settingsBuilder().put(settings).put("name", "node1").build()).start();
.settings(settingsBuilder().put(settings).put("name", "node1"))
.node();
Client client = node1.client(); Client client = node1.client();
int count = (int) SizeValue.parseSizeValue("1m").singles(); int count = (int) SizeValue.parseSizeValue("1m").singles();

View File

@ -36,7 +36,6 @@ import java.util.Locale;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
/** /**
*/ */
@ -46,21 +45,18 @@ public class ScrollSearchBenchmark {
public static void main(String[] args) { public static void main(String[] args) {
String indexName = "test"; String indexName = "test";
String typeName = "type"; String typeName = "type";
String clusterName = ScrollSearchBenchmark.class.getSimpleName();
long numDocs = SizeValue.parseSizeValue("300k").singles(); long numDocs = SizeValue.parseSizeValue("300k").singles();
int requestSize = 50; int requestSize = 50;
Settings settings = settingsBuilder() Settings settings = settingsBuilder()
.put(SETTING_NUMBER_OF_SHARDS, 3) .put(SETTING_NUMBER_OF_SHARDS, 3)
.put(SETTING_NUMBER_OF_REPLICAS, 0) .put(SETTING_NUMBER_OF_REPLICAS, 0)
.put("cluster.name", ScrollSearchBenchmark.class.getSimpleName())
.build(); .build();
Node[] nodes = new Node[3]; Node[] nodes = new Node[3];
for (int i = 0; i < nodes.length; i++) { for (int i = 0; i < nodes.length; i++) {
nodes[i] = nodeBuilder() nodes[i] = new Node(settingsBuilder().put(settings).put("name", "node" + i).build()).start();
.clusterName(clusterName)
.settings(settingsBuilder().put(settings).put("name", "node" + i))
.node();
} }
Client client = nodes[0].client(); Client client = nodes[0].client();

View File

@ -32,7 +32,6 @@ import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.transport.TransportService; import org.elasticsearch.transport.TransportService;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
@ -51,13 +50,15 @@ public class TransportClientIT extends ESIntegTestCase {
public void testNodeVersionIsUpdated() { public void testNodeVersionIsUpdated() {
TransportClient client = (TransportClient) internalCluster().client(); TransportClient client = (TransportClient) internalCluster().client();
TransportClientNodesService nodeService = client.nodeService(); TransportClientNodesService nodeService = client.nodeService();
Node node = nodeBuilder().data(false).settings(Settings.builder() Node node = new Node(Settings.builder()
.put(internalCluster().getDefaultSettings()) .put(internalCluster().getDefaultSettings())
.put("path.home", createTempDir()) .put("path.home", createTempDir())
.put("node.name", "testNodeVersionIsUpdated") .put("node.name", "testNodeVersionIsUpdated")
.put("http.enabled", false) .put("http.enabled", false)
.put("node.data", false)
.put("cluster.name", "foobar")
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true) // make sure we get what we set :) .put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true) // make sure we get what we set :)
.build()).clusterName("foobar").build(); .build());
node.start(); node.start();
try { try {
TransportAddress transportAddress = node.injector().getInstance(TransportService.class).boundAddress().publishAddress(); TransportAddress transportAddress = node.injector().getInstance(TransportService.class).boundAddress().publishAddress();

View File

@ -29,7 +29,7 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.node.NodeBuilder; import org.elasticsearch.node.Node;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope; import org.elasticsearch.test.ESIntegTestCase.Scope;
@ -46,13 +46,20 @@ import java.lang.management.ThreadMXBean;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.*; import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.sameInstance;
/** /**
*/ */
@ -185,7 +192,7 @@ public class SimpleThreadPoolIT extends ESIntegTestCase {
.put("tribe.t1.plugin.mandatory", "non_existing").build(); .put("tribe.t1.plugin.mandatory", "non_existing").build();
try { try {
NodeBuilder.nodeBuilder().settings(settings).build(); new Node(settings);
fail("The node startup is supposed to fail"); fail("The node startup is supposed to fail");
} catch(Throwable t) { } catch(Throwable t) {
//all good //all good

View File

@ -21,13 +21,13 @@ package org.elasticsearch.tribe;
import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.client.Requests; import org.elasticsearch.client.Requests;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException; import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.common.Priority; import org.elasticsearch.common.Priority;
@ -37,7 +37,6 @@ import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.discovery.MasterNotDiscoveredException; import org.elasticsearch.discovery.MasterNotDiscoveredException;
import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing; import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing;
import org.elasticsearch.node.Node; import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.InternalTestCluster; import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.NodeConfigurationSource; import org.elasticsearch.test.NodeConfigurationSource;
@ -143,9 +142,7 @@ public class TribeIT extends ESIntegTestCase {
.put("node.name", "tribe_node") // make sure we can identify threads from this node .put("node.name", "tribe_node") // make sure we can identify threads from this node
.build(); .build();
tribeNode = NodeBuilder.nodeBuilder() tribeNode = new Node(merged).start();
.settings(merged)
.node();
tribeClient = tribeNode.client(); tribeClient = tribeNode.client();
} }

View File

@ -37,11 +37,10 @@ that can execute operations against elasticsearch.
[source,java] [source,java]
-------------------------------------------------- --------------------------------------------------
import static org.elasticsearch.node.NodeBuilder.*;
// on startup // on startup
Node node = nodeBuilder().node(); Node node = new Node(Settings.EMPTY).start();
Client client = node.client(); Client client = node.client();
// on shutdown // on shutdown
@ -86,17 +85,15 @@ it):
[source,java] [source,java]
-------------------------------------------------- --------------------------------------------------
import static org.elasticsearch.node.NodeBuilder.*;
// on startup // on startup
// Embedded node clients behave just like standalone nodes, // Embedded node clients behave just like standalone nodes,
// which means that they will leave the HTTP port open! // which means that they will leave the HTTP port open!
Node node = Node node = new Node(Settings.settingsBuilder()
nodeBuilder() .put("http.enabled", false)
.settings(Settings.settingsBuilder().put("http.enabled", false)) .put("node.client", true).build())
.client(true) .start();
.node();
Client client = node.client(); Client client = node.client();
@ -115,11 +112,10 @@ and form a cluster.
[source,java] [source,java]
-------------------------------------------------- --------------------------------------------------
import static org.elasticsearch.node.NodeBuilder.*;
// on startup // on startup
Node node = nodeBuilder().local(true).node(); Node node = new Node(Settings.builder().put("node.local", true).build()).start();
Client client = node.client(); Client client = node.client();
// on shutdown // on shutdown

View File

@ -25,7 +25,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.SuppressForbidden; import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.Node; import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.elasticsearch.node.internal.InternalSettingsPreparer; import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
@ -97,7 +96,7 @@ public class TribeUnitTests extends ESTestCase {
.put("tribe.t1.node.mode", NODE_MODE).put("tribe.t2.node.mode", NODE_MODE) .put("tribe.t1.node.mode", NODE_MODE).put("tribe.t2.node.mode", NODE_MODE)
.put("path.home", createTempDir()).put(extraSettings).build(); .put("path.home", createTempDir()).put(extraSettings).build();
try (Node node = NodeBuilder.nodeBuilder().settings(settings).node()) { try (Node node = new Node(settings).start()) {
try (Client client = node.client()) { try (Client client = node.client()) {
assertBusy(new Runnable() { assertBusy(new Runnable() {
@Override @Override

View File

@ -19,12 +19,12 @@
package org.elasticsearch.test; package org.elasticsearch.test;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
import org.elasticsearch.cache.recycler.PageCacheRecycler; import org.elasticsearch.cache.recycler.PageCacheRecycler;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.client.Requests; import org.elasticsearch.client.Requests;
import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNode;
@ -38,7 +38,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.IndexService; import org.elasticsearch.index.IndexService;
import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.node.Node; import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.elasticsearch.node.internal.InternalSettingsPreparer; import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.script.ScriptService; import org.elasticsearch.script.ScriptService;
import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.search.internal.SearchContext;
@ -48,7 +47,9 @@ import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
/** /**
* A test that keep a singleton node started for all tests that can be used to get * A test that keep a singleton node started for all tests that can be used to get
@ -119,7 +120,7 @@ public abstract class ESSingleNodeTestCase extends ESTestCase {
} }
private static Node newNode() { private static Node newNode() {
Node build = NodeBuilder.nodeBuilder().local(true).data(true).settings(Settings.builder() Node build = new Node(Settings.builder()
.put(ClusterName.SETTING, InternalTestCluster.clusterName("single-node-cluster", randomLong())) .put(ClusterName.SETTING, InternalTestCluster.clusterName("single-node-cluster", randomLong()))
.put("path.home", createTempDir()) .put("path.home", createTempDir())
// TODO: use a consistent data path for custom paths // TODO: use a consistent data path for custom paths
@ -132,8 +133,11 @@ public abstract class ESSingleNodeTestCase extends ESTestCase {
.put("script.indexed", "on") .put("script.indexed", "on")
.put(EsExecutors.PROCESSORS, 1) // limit the number of threads created .put(EsExecutors.PROCESSORS, 1) // limit the number of threads created
.put("http.enabled", false) .put("http.enabled", false)
.put("node.local", true)
.put("node.data", true)
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true) // make sure we get what we set :) .put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true) // make sure we get what we set :)
).build(); .build()
);
build.start(); build.start();
assertThat(DiscoveryNode.localNode(build.settings()), is(true)); assertThat(DiscoveryNode.localNode(build.settings()), is(true));
return build; return build;