Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove LocalTransport in favor of MockTcpTransport #20695

Merged
merged 22 commits into from
Oct 7, 2016
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions TESTING.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,6 @@ following:
gradle assemble
-----------------------------

== Other test options

To disable and enable network transport, set the `tests.es.node.mode` system property.

Use network transport:

------------------------------------
-Dtests.es.node.mode=network
------------------------------------

Use local transport (default since 1.3):

-------------------------------------
-Dtests.es.node.mode=local
-------------------------------------

=== Running Elasticsearch from a checkout

In order to run Elasticsearch from source without building a package, you can
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@
import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.LocalTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.gateway.GatewayAllocator;

import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

public final class Allocators {
private static class NoopGatewayAllocator extends GatewayAllocator {
Expand Down Expand Up @@ -91,8 +94,11 @@ public static AllocationDeciders defaultAllocationDeciders(Settings settings, Cl

}

private static final AtomicInteger portGenerator = new AtomicInteger();

public static DiscoveryNode newNode(String nodeId, Map<String, String> attributes) {
return new DiscoveryNode("", nodeId, LocalTransportAddress.buildUnique(), attributes, Sets.newHashSet(DiscoveryNode.Role.MASTER,
return new DiscoveryNode("", nodeId, new TransportAddress(TransportAddress.META_ADDRESS,
portGenerator.incrementAndGet()), attributes, Sets.newHashSet(DiscoveryNode.Role.MASTER,
DiscoveryNode.Role.DATA), Version.CURRENT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.elasticsearch.client.benchmark.ops.search.SearchRequestExecutor;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.plugin.noop.NoopPlugin;
import org.elasticsearch.plugin.noop.action.bulk.NoopBulkAction;
Expand All @@ -51,7 +51,7 @@ public static void main(String[] args) throws Exception {
@Override
protected TransportClient client(String benchmarkTargetHost) throws Exception {
TransportClient client = new PreBuiltTransportClient(Settings.EMPTY, NoopPlugin.class);
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(benchmarkTargetHost), 9300));
client.addTransportAddress(new TransportAddress(InetAddress.getByName(benchmarkTargetHost), 9300));
return client;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
Expand Down Expand Up @@ -75,10 +74,7 @@ public class ClusterStatsNodes implements ToXContent {

// now do the stats that should be deduped by hardware (implemented by ip deduping)
TransportAddress publishAddress = nodeResponse.nodeInfo().getTransport().address().publishAddress();
InetAddress inetAddress = null;
if (publishAddress.uniqueAddressTypeId() == 1) {
inetAddress = ((InetSocketTransportAddress) publishAddress).address().getAddress();
}
final InetAddress inetAddress = publishAddress.address().getAddress();
if (!seenAddresses.add(inetAddress)) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.common.transport.TransportAddressSerializers;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.node.Node;
Expand All @@ -40,7 +39,6 @@
import java.util.Set;
import java.util.function.Predicate;

import static org.elasticsearch.common.transport.TransportAddressSerializers.addressToStream;

/**
* A discovery node represents a node that is part of the cluster.
Expand Down Expand Up @@ -217,7 +215,7 @@ public DiscoveryNode(StreamInput in) throws IOException {
this.ephemeralId = in.readString().intern();
this.hostName = in.readString().intern();
this.hostAddress = in.readString().intern();
this.address = TransportAddressSerializers.addressFromStream(in);
this.address = new TransportAddress(in);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

int size = in.readVInt();
this.attributes = new HashMap<>(size);
for (int i = 0; i < size; i++) {
Expand All @@ -242,7 +240,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeString(ephemeralId);
out.writeString(hostName);
out.writeString(hostAddress);
addressToStream(out, address);
address.writeTo(out);
out.writeVInt(attributes.size());
for (Map.Entry<String, String> entry : attributes.entrySet()) {
out.writeString(entry.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.elasticsearch.common.network.NetworkAddress;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -82,8 +82,8 @@ public boolean match(DiscoveryNode node) {
if ("_ip".equals(attr)) {
// We check both the host_ip or the publish_ip
String publishAddress = null;
if (node.getAddress() instanceof InetSocketTransportAddress) {
publishAddress = NetworkAddress.format(((InetSocketTransportAddress) node.getAddress()).address().getAddress());
if (node.getAddress() instanceof TransportAddress) {
publishAddress = NetworkAddress.format(node.getAddress().address().getAddress());
}

boolean match = matchByIP(values, node.getHostAddress(), publishAddress);
Expand Down Expand Up @@ -116,8 +116,8 @@ public boolean match(DiscoveryNode node) {
} else if ("_publish_ip".equals(attr)) {
// We check explicitly only the publish_ip
String address = null;
if (node.getAddress() instanceof InetSocketTransportAddress) {
address = NetworkAddress.format(((InetSocketTransportAddress) node.getAddress()).address().getAddress());
if (node.getAddress() instanceof TransportAddress) {
address = NetworkAddress.format(node.getAddress().address().getAddress());
}

boolean match = matchByIP(values, address, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@
import org.elasticsearch.transport.TransportInterceptor;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.TransportRequestHandler;
import org.elasticsearch.transport.local.LocalTransport;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -112,7 +110,6 @@ public NetworkModule(Settings settings, boolean transportClient, List<NetworkPlu
NetworkService networkService) {
this.settings = settings;
this.transportClient = transportClient;
registerTransport(LOCAL_TRANSPORT, () -> new LocalTransport(settings, threadPool, namedWriteableRegistry, circuitBreakerService));
for (NetworkPlugin plugin : plugins) {
if (transportClient == false && HTTP_ENABLED.get(settings)) {
Map<String, Supplier<HttpServerTransport>> httpTransportFactory = plugin.getHttpTransports(settings, threadPool, bigArrays,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,18 @@ public void readFrom(StreamInput in) throws IOException {
int boundAddressLength = in.readInt();
boundAddresses = new TransportAddress[boundAddressLength];
for (int i = 0; i < boundAddressLength; i++) {
boundAddresses[i] = TransportAddressSerializers.addressFromStream(in);
boundAddresses[i] = new TransportAddress(in);
}
publishAddress = TransportAddressSerializers.addressFromStream(in);
publishAddress = new TransportAddress(in);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeInt(boundAddresses.length);
for (TransportAddress address : boundAddresses) {
TransportAddressSerializers.addressToStream(out, address);
address.writeTo(out);
}
TransportAddressSerializers.addressToStream(out, publishAddress);
publishAddress.writeTo(out);
}

@Override
Expand Down

This file was deleted.

Loading