Skip to content

Commit

Permalink
Remove InternalNode interface
Browse files Browse the repository at this point in the history
  • Loading branch information
s1monw committed Feb 24, 2015
1 parent 028f379 commit 3e1c7b5
Show file tree
Hide file tree
Showing 27 changed files with 447 additions and 518 deletions.
396 changes: 381 additions & 15 deletions src/main/java/org/elasticsearch/node/Node.java

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/main/java/org/elasticsearch/node/NodeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.internal.InternalNode;

/**
* A node builder is used to construct a {@link Node} instance.
Expand Down Expand Up @@ -156,7 +155,7 @@ public NodeBuilder clusterName(String clusterName) {
* Builds the node without starting it.
*/
public Node build() {
return new InternalNode(settings.build(), loadConfigSettings);
return new Node(settings.build(), loadConfigSettings);
}

/**
Expand Down
422 changes: 0 additions & 422 deletions src/main/java/org/elasticsearch/node/internal/InternalNode.java

This file was deleted.

20 changes: 10 additions & 10 deletions src/main/java/org/elasticsearch/tribe/TribeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
import org.elasticsearch.discovery.DiscoveryService;
import org.elasticsearch.gateway.GatewayService;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.rest.RestStatus;

import java.util.EnumSet;
Expand Down Expand Up @@ -115,7 +115,7 @@ public static Settings processSettings(Settings settings) {
private final String onConflict;
private final Set<String> droppedIndices = ConcurrentCollections.newConcurrentSet();

private final List<InternalNode> nodes = Lists.newCopyOnWriteArrayList();
private final List<Node> nodes = Lists.newCopyOnWriteArrayList();

@Inject
public TribeService(Settings settings, ClusterService clusterService, DiscoveryService discoveryService) {
Expand All @@ -131,7 +131,7 @@ public TribeService(Settings settings, ClusterService clusterService, DiscoveryS
if (sb.get("http.enabled") == null) {
sb.put("http.enabled", false);
}
nodes.add((InternalNode) NodeBuilder.nodeBuilder().settings(sb).client(true).build());
nodes.add(NodeBuilder.nodeBuilder().settings(sb).client(true).build());
}

String[] blockIndicesWrite = Strings.EMPTY_ARRAY;
Expand All @@ -151,7 +151,7 @@ public TribeService(Settings settings, ClusterService clusterService, DiscoveryS
}
blockIndicesMetadata = settings.getAsArray("tribe.blocks.metadata.indices", Strings.EMPTY_ARRAY);
blockIndicesRead = settings.getAsArray("tribe.blocks.read.indices", Strings.EMPTY_ARRAY);
for (InternalNode node : nodes) {
for (Node node : nodes) {
node.injector().getInstance(ClusterService.class).add(new TribeClusterStateListener(node));
}
}
Expand All @@ -164,12 +164,12 @@ public TribeService(Settings settings, ClusterService clusterService, DiscoveryS

@Override
protected void doStart() throws ElasticsearchException {
for (InternalNode node : nodes) {
for (Node node : nodes) {
try {
node.start();
} catch (Throwable e) {
// calling close is safe for non started nodes, we can just iterate over all
for (InternalNode otherNode : nodes) {
for (Node otherNode : nodes) {
try {
otherNode.close();
} catch (Throwable t) {
Expand All @@ -186,7 +186,7 @@ protected void doStart() throws ElasticsearchException {

@Override
protected void doStop() throws ElasticsearchException {
for (InternalNode node : nodes) {
for (Node node : nodes) {
try {
node.stop();
} catch (Throwable t) {
Expand All @@ -197,7 +197,7 @@ protected void doStop() throws ElasticsearchException {

@Override
protected void doClose() throws ElasticsearchException {
for (InternalNode node : nodes) {
for (Node node : nodes) {
try {
node.close();
} catch (Throwable t) {
Expand All @@ -208,10 +208,10 @@ protected void doClose() throws ElasticsearchException {

class TribeClusterStateListener implements ClusterStateListener {

private final InternalNode tribeNode;
private final Node tribeNode;
private final String tribeName;

TribeClusterStateListener(InternalNode tribeNode) {
TribeClusterStateListener(Node tribeNode) {
this.tribeNode = tribeNode;
this.tribeName = tribeNode.settings().get(TRIBE_NAME);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.discovery.Discovery;
import org.elasticsearch.indices.IndexAlreadyExistsException;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.node.Node;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.transport.TransportModule;

Expand All @@ -63,7 +63,7 @@ public class GlobalOrdinalsBenchmark {
private static final boolean USE_DOC_VALUES = false;

static long COUNT = SizeValue.parseSizeValue("5m").singles();
static InternalNode node;
static Node node;
static Client client;

public static void main(String[] args) throws Exception {
Expand All @@ -79,7 +79,7 @@ public static void main(String[] args) throws Exception {
.build();

String clusterName = GlobalOrdinalsBenchmark.class.getSimpleName();
node = (InternalNode) nodeBuilder().clusterName(clusterName)
node = nodeBuilder().clusterName(clusterName)
.settings(settingsBuilder().put(settings))
.node();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.discovery.Discovery;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;

Expand Down Expand Up @@ -70,7 +69,7 @@ public class SubAggregationSearchCollectModeBenchmark {
static int STRING_TERM_SIZE = 5;

static Client client;
static InternalNode[] nodes;
static Node[] nodes;

public static void main(String[] args) throws Exception {
Natives.tryMlockall();
Expand All @@ -83,9 +82,9 @@ public static void main(String[] args) throws Exception {
.build();

String clusterName = SubAggregationSearchCollectModeBenchmark.class.getSimpleName();
nodes = new InternalNode[1];
nodes = new Node[1];
for (int i = 0; i < nodes.length; i++) {
nodes[i] = (InternalNode) nodeBuilder().clusterName(clusterName)
nodes[i] = nodeBuilder().clusterName(clusterName)
.settings(settingsBuilder().put(settings).put("name", "node" + i))
.node();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.discovery.Discovery;
import org.elasticsearch.indices.IndexAlreadyExistsException;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.node.Node;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -69,7 +69,7 @@ public class TermsAggregationSearchAndIndexingBenchmark {
static int NUMBER_OF_MULTI_VALUE_TERMS = 10;
static int STRING_TERM_SIZE = 5;

static InternalNode[] nodes;
static Node[] nodes;

public static void main(String[] args) throws Exception {
Natives.tryMlockall();
Expand All @@ -80,9 +80,9 @@ public static void main(String[] args) throws Exception {
.build();

String clusterName = TermsAggregationSearchAndIndexingBenchmark.class.getSimpleName();
nodes = new InternalNode[1];
nodes = new Node[1];
for (int i = 0; i < nodes.length; i++) {
nodes[i] = (InternalNode) nodeBuilder().settings(settingsBuilder().put(settings).put("name", "node1"))
nodes[i] = nodeBuilder().settings(settingsBuilder().put(settings).put("name", "node1"))
.clusterName(clusterName)
.node();
}
Expand Down Expand Up @@ -197,7 +197,7 @@ public static void main(String[] args) throws Exception {
System.out.println("----------------------------------------- SUMMARY ----------------------------------------------");

client.close();
for (InternalNode node : nodes) {
for (Node node : nodes) {
node.close();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.discovery.Discovery;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;

Expand Down Expand Up @@ -71,7 +70,7 @@ public class TermsAggregationSearchBenchmark {
static int STRING_TERM_SIZE = 5;

static Client client;
static InternalNode[] nodes;
static Node[] nodes;

public enum Method {
AGGREGATION {
Expand Down Expand Up @@ -111,9 +110,9 @@ public static void main(String[] args) throws Exception {
.build();

String clusterName = TermsAggregationSearchBenchmark.class.getSimpleName();
nodes = new InternalNode[1];
nodes = new Node[1];
for (int i = 0; i < nodes.length; i++) {
nodes[i] = (InternalNode) nodeBuilder().clusterName(clusterName)
nodes[i] = nodeBuilder().clusterName(clusterName)
.settings(settingsBuilder().put(settings).put("name", "node" + i))
.node();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.index.merge.policy.MergePolicyModule;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.node.Node;
import org.elasticsearch.rest.action.admin.indices.upgrade.UpgradeTest;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.sort.SortOrder;
Expand Down Expand Up @@ -134,7 +134,7 @@ public void testOldIndexes() throws Exception {

void assertOldIndexWorks(String index) throws Exception {
Settings settings = ImmutableSettings.builder()
.put(InternalNode.HTTP_ENABLED, true) // for _upgrade
.put(Node.HTTP_ENABLED, true) // for _upgrade
.put(MergePolicyModule.MERGE_POLICY_TYPE_KEY, NoMergePolicyProvider.class) // disable merging so no segments will be upgraded
.build();
loadIndex(index, settings);
Expand Down Expand Up @@ -192,7 +192,7 @@ void assertNewReplicasWork() throws Exception {
internalCluster().startNode(ImmutableSettings.builder()
.put("data.node", true)
.put("master.node", false)
.put(InternalNode.HTTP_ENABLED, true) // for _upgrade
.put(Node.HTTP_ENABLED, true) // for _upgrade
.build());
}
client().admin().cluster().prepareHealth("test").setWaitForNodes("" + (numReplicas + 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope;
import org.elasticsearch.transport.TransportService;
Expand Down Expand Up @@ -62,7 +61,7 @@ public void testNodeVersionIsUpdated() {
.build()).clusterName("foobar").build();
node.start();
try {
TransportAddress transportAddress = ((InternalNode) node).injector().getInstance(TransportService.class).boundAddress().publishAddress();
TransportAddress transportAddress = node.injector().getInstance(TransportService.class).boundAddress().publishAddress();
client.addTransportAddress(transportAddress);
assertThat(nodeService.connectedNodes().size(), greaterThanOrEqualTo(1)); // since we force transport clients there has to be one node started that we connect to.
for (DiscoveryNode discoveryNode : nodeService.connectedNodes()) { // connected nodes have updated version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.routing.OperationRouting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.ElasticsearchTestCase;

import java.io.BufferedReader;
Expand All @@ -37,7 +36,7 @@
public class RoutingBackwardCompatibilityTests extends ElasticsearchTestCase {

public void testBackwardCompatibility() throws Exception {
InternalNode node = new InternalNode();
Node node = new Node();
try {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(RoutingBackwardCompatibilityTests.class.getResourceAsStream("/org/elasticsearch/cluster/routing/shard_routes.txt"), "UTF-8"))) {
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.node.Node;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.test.ElasticsearchIntegrationTest;

Expand All @@ -52,7 +52,7 @@ private void test(String name, Class<? extends HashFunction> expectedHashFunctio
Settings baseSettings = prepareBackwardsDataDir(zippedIndexDir);
internalCluster().startNode(ImmutableSettings.builder()
.put(baseSettings)
.put(InternalNode.HTTP_ENABLED, true)
.put(Node.HTTP_ENABLED, true)
.build());
ensureYellow("test");
GetIndexResponse getIndexResponse = client().admin().indices().prepareGetIndex().get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.BoundTransportAddress;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.junit.Test;

Expand All @@ -40,7 +40,7 @@ public class HttpPublishPortTests extends ElasticsearchIntegrationTest {
protected Settings nodeSettings(int nodeOrdinal) {
return ImmutableSettings.settingsBuilder()
.put(super.nodeSettings(nodeOrdinal))
.put(InternalNode.HTTP_ENABLED, true)
.put(Node.HTTP_ENABLED, true)
.put("http.publish_port", 9080)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.http.HttpServerTransport;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.jboss.netty.handler.codec.http.HttpResponse;
import org.junit.Test;
Expand All @@ -46,7 +46,7 @@ public class NettyPipeliningDisabledIntegrationTest extends ElasticsearchIntegra

@Override
protected Settings nodeSettings(int nodeOrdinal) {
return settingsBuilder().put(super.nodeSettings(nodeOrdinal)).put(InternalNode.HTTP_ENABLED, true).put("http.pipelining", false).build();
return settingsBuilder().put(super.nodeSettings(nodeOrdinal)).put(Node.HTTP_ENABLED, true).put("http.pipelining", false).build();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.http.HttpServerTransport;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.jboss.netty.handler.codec.http.HttpResponse;
import org.junit.Test;
Expand All @@ -44,7 +44,7 @@ public class NettyPipeliningEnabledIntegrationTest extends ElasticsearchIntegrat

@Override
protected Settings nodeSettings(int nodeOrdinal) {
return settingsBuilder().put(super.nodeSettings(nodeOrdinal)).put(InternalNode.HTTP_ENABLED, true).put("http.pipelining", true).build();
return settingsBuilder().put(super.nodeSettings(nodeOrdinal)).put(Node.HTTP_ENABLED, true).put("http.pipelining", true).build();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@
package org.elasticsearch.network;

import org.apache.http.impl.client.HttpClients;
import org.apache.lucene.util.TestUtil;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.http.HttpServerTransport;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.test.rest.client.http.HttpRequestBuilder;
import org.hamcrest.Matchers;
Expand All @@ -50,7 +48,7 @@ public class DirectBufferNetworkTests extends ElasticsearchIntegrationTest {
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return ImmutableSettings.builder()
.put(InternalNode.HTTP_ENABLED, true)
.put(Node.HTTP_ENABLED, true)
.put(super.nodeSettings(nodeOrdinal)).build();
}

Expand Down
Loading

0 comments on commit 3e1c7b5

Please sign in to comment.