Remove LocalTransport in favor of MockTcpTransport (#20695)
This change proposes the removal of all non-tcp transport implementations. The mock transport can be used by default to run tests instead of local transport that has roughly the same performance compared to TCP or at least not noticeably slower. This is a master only change, deprecation notice in 5.x will be committed as a separate change.
This commit is contained in:
parent
eba60ee63c
commit
194a6b1df0
|
@ -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
|
||||
|
|
|
@ -31,15 +31,18 @@ import org.elasticsearch.cluster.routing.allocation.decider.AllocationDecider;
|
|||
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 {
|
||||
|
@ -91,8 +94,11 @@ public final class Allocators {
|
|||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.elasticsearch.client.benchmark.ops.bulk.BulkRequestExecutor;
|
|||
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;
|
||||
|
@ -51,7 +51,7 @@ public final class TransportClientBenchmark extends AbstractBenchmark<TransportC
|
|||
@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;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
|
|||
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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|||
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;
|
||||
|
@ -40,7 +39,6 @@ import java.util.Map;
|
|||
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.
|
||||
|
@ -217,7 +215,7 @@ public class DiscoveryNode implements Writeable, ToXContent {
|
|||
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);
|
||||
int size = in.readVInt();
|
||||
this.attributes = new HashMap<>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
|
@ -242,7 +240,7 @@ public class DiscoveryNode implements Writeable, ToXContent {
|
|||
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());
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.elasticsearch.common.Strings;
|
|||
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;
|
||||
|
@ -82,8 +82,8 @@ public class DiscoveryNodeFilters {
|
|||
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);
|
||||
|
@ -116,8 +116,8 @@ public class DiscoveryNodeFilters {
|
|||
} 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);
|
||||
|
|
|
@ -45,10 +45,8 @@ import org.elasticsearch.transport.Transport;
|
|||
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;
|
||||
|
@ -112,7 +110,6 @@ public final class NetworkModule {
|
|||
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,
|
||||
|
@ -126,7 +123,7 @@ public final class NetworkModule {
|
|||
for (Map.Entry<String, Supplier<Transport>> entry : httpTransportFactory.entrySet()) {
|
||||
registerTransport(entry.getKey(), entry.getValue());
|
||||
}
|
||||
List<TransportInterceptor> transportInterceptors = plugin.getTransportInterceptors();
|
||||
List<TransportInterceptor> transportInterceptors = plugin.getTransportInterceptors(namedWriteableRegistry);
|
||||
for (TransportInterceptor interceptor : transportInterceptors) {
|
||||
registerTransportInterceptor(interceptor);
|
||||
}
|
||||
|
|
|
@ -68,18 +68,18 @@ public class BoundTransportAddress implements Streamable {
|
|||
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
|
||||
|
|
|
@ -1,127 +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.common.transport;
|
||||
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.network.NetworkAddress;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
/**
|
||||
* A transport address used for IP socket address (wraps {@link java.net.InetSocketAddress}).
|
||||
*/
|
||||
public final class InetSocketTransportAddress implements TransportAddress {
|
||||
public static final short TYPE_ID = 1;
|
||||
|
||||
private final InetSocketAddress address;
|
||||
|
||||
public InetSocketTransportAddress(InetAddress address, int port) {
|
||||
this(new InetSocketAddress(address, port));
|
||||
}
|
||||
|
||||
public InetSocketTransportAddress(InetSocketAddress address) {
|
||||
if (address == null) {
|
||||
throw new IllegalArgumentException("InetSocketAddress must not be null");
|
||||
}
|
||||
if (address.getAddress() == null) {
|
||||
throw new IllegalArgumentException("Address must be resolved but wasn't - InetSocketAddress#getAddress() returned null");
|
||||
}
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from a stream.
|
||||
*/
|
||||
public InetSocketTransportAddress(StreamInput in) throws IOException {
|
||||
final int len = in.readByte();
|
||||
final byte[] a = new byte[len]; // 4 bytes (IPv4) or 16 bytes (IPv6)
|
||||
in.readFully(a);
|
||||
InetAddress inetAddress = InetAddress.getByAddress(a);
|
||||
int port = in.readInt();
|
||||
this.address = new InetSocketAddress(inetAddress, port);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
byte[] bytes = address().getAddress().getAddress(); // 4 bytes (IPv4) or 16 bytes (IPv6)
|
||||
out.writeByte((byte) bytes.length); // 1 byte
|
||||
out.write(bytes, 0, bytes.length);
|
||||
// don't serialize scope ids over the network!!!!
|
||||
// these only make sense with respect to the local machine, and will only formulate
|
||||
// the address incorrectly remotely.
|
||||
out.writeInt(address.getPort());
|
||||
}
|
||||
|
||||
@Override
|
||||
public short uniqueAddressTypeId() {
|
||||
return TYPE_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameHost(TransportAddress other) {
|
||||
return other instanceof InetSocketTransportAddress &&
|
||||
address.getAddress().equals(((InetSocketTransportAddress) other).address.getAddress());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoopbackOrLinkLocalAddress() {
|
||||
return address.getAddress().isLinkLocalAddress() || address.getAddress().isLoopbackAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost() {
|
||||
return getAddress(); // just delegate no resolving
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAddress() {
|
||||
return NetworkAddress.format(address.getAddress());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return address.getPort();
|
||||
}
|
||||
|
||||
public InetSocketAddress address() {
|
||||
return this.address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
InetSocketTransportAddress address1 = (InetSocketTransportAddress) o;
|
||||
return address.equals(address1.address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return address != null ? address.hashCode() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return NetworkAddress.format(address);
|
||||
}
|
||||
}
|
|
@ -1,116 +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.common.transport;
|
||||
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final class LocalTransportAddress implements TransportAddress {
|
||||
public static final short TYPE_ID = 2;
|
||||
|
||||
private static final AtomicLong transportAddressIdGenerator = new AtomicLong();
|
||||
|
||||
/**
|
||||
* generates a new unique address
|
||||
*/
|
||||
public static LocalTransportAddress buildUnique() {
|
||||
return new LocalTransportAddress(Long.toString(transportAddressIdGenerator.incrementAndGet()));
|
||||
}
|
||||
|
||||
private String id;
|
||||
|
||||
public LocalTransportAddress(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from a stream.
|
||||
*/
|
||||
public LocalTransportAddress(StreamInput in) throws IOException {
|
||||
id = in.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeString(id);
|
||||
}
|
||||
|
||||
public String id() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short uniqueAddressTypeId() {
|
||||
return TYPE_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameHost(TransportAddress other) {
|
||||
return other instanceof LocalTransportAddress && id.equals(((LocalTransportAddress) other).id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoopbackOrLinkLocalAddress() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost() {
|
||||
return "local";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAddress() {
|
||||
return "0.0.0.0"; // see https://en.wikipedia.org/wiki/0.0.0.0
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
LocalTransportAddress that = (LocalTransportAddress) o;
|
||||
|
||||
if (id != null ? !id.equals(that.id) : that.id != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id != null ? id.hashCode() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "local[" + id + "]";
|
||||
}
|
||||
}
|
|
@ -19,34 +19,113 @@
|
|||
|
||||
package org.elasticsearch.common.transport;
|
||||
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.common.network.NetworkAddress;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
*
|
||||
* A transport address used for IP socket address (wraps {@link java.net.InetSocketAddress}).
|
||||
*/
|
||||
public interface TransportAddress extends Writeable {
|
||||
public final class TransportAddress implements Writeable {
|
||||
|
||||
/**
|
||||
* Returns the host string for this transport address
|
||||
* A <a href="https://en.wikipedia.org/wiki/0.0.0.0">non-routeable v4 meta transport address</a> that can be used for
|
||||
* testing or in scenarios where targets should be marked as non-applicable from a transport perspective.
|
||||
*/
|
||||
String getHost();
|
||||
public static final InetAddress META_ADDRESS;
|
||||
|
||||
static {
|
||||
try {
|
||||
META_ADDRESS = InetAddress.getByName("0.0.0.0");
|
||||
} catch (UnknownHostException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private final InetSocketAddress address;
|
||||
|
||||
public TransportAddress(InetAddress address, int port) {
|
||||
this(new InetSocketAddress(address, port));
|
||||
}
|
||||
|
||||
public TransportAddress(InetSocketAddress address) {
|
||||
if (address == null) {
|
||||
throw new IllegalArgumentException("InetSocketAddress must not be null");
|
||||
}
|
||||
if (address.getAddress() == null) {
|
||||
throw new IllegalArgumentException("Address must be resolved but wasn't - InetSocketAddress#getAddress() returned null");
|
||||
}
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the address string for this transport address
|
||||
* Read from a stream.
|
||||
*/
|
||||
String getAddress();
|
||||
public TransportAddress(StreamInput in) throws IOException {
|
||||
final int len = in.readByte();
|
||||
final byte[] a = new byte[len]; // 4 bytes (IPv4) or 16 bytes (IPv6)
|
||||
in.readFully(a);
|
||||
InetAddress inetAddress = InetAddress.getByAddress(a);
|
||||
int port = in.readInt();
|
||||
this.address = new InetSocketAddress(inetAddress, port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the port of this transport address if applicable
|
||||
*/
|
||||
int getPort();
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
byte[] bytes = address().getAddress().getAddress(); // 4 bytes (IPv4) or 16 bytes (IPv6)
|
||||
out.writeByte((byte) bytes.length); // 1 byte
|
||||
out.write(bytes, 0, bytes.length);
|
||||
// don't serialize scope ids over the network!!!!
|
||||
// these only make sense with respect to the local machine, and will only formulate
|
||||
// the address incorrectly remotely.
|
||||
out.writeInt(address.getPort());
|
||||
}
|
||||
|
||||
short uniqueAddressTypeId();
|
||||
public boolean sameHost(TransportAddress other) {
|
||||
return address.getAddress().equals(other.address.getAddress());
|
||||
}
|
||||
|
||||
boolean sameHost(TransportAddress other);
|
||||
public boolean isLoopbackOrLinkLocalAddress() {
|
||||
return address.getAddress().isLinkLocalAddress() || address.getAddress().isLoopbackAddress();
|
||||
}
|
||||
|
||||
boolean isLoopbackOrLinkLocalAddress();
|
||||
public String getHost() {
|
||||
return getAddress(); // just delegate no resolving
|
||||
}
|
||||
|
||||
String toString();
|
||||
public String getAddress() {
|
||||
return NetworkAddress.format(address.getAddress());
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return address.getPort();
|
||||
}
|
||||
|
||||
public InetSocketAddress address() {
|
||||
return this.address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
TransportAddress address1 = (TransportAddress) o;
|
||||
return address.equals(address1.address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return address != null ? address.hashCode() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return NetworkAddress.format(address);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,67 +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.common.transport;
|
||||
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Collections.unmodifiableMap;
|
||||
|
||||
/**
|
||||
* A global registry of all supported types of {@link TransportAddress}s. This registry is not open for modification by plugins.
|
||||
*/
|
||||
public abstract class TransportAddressSerializers {
|
||||
private static final Map<Short, Writeable.Reader<TransportAddress>> ADDRESS_REGISTRY;
|
||||
|
||||
static {
|
||||
Map<Short, Writeable.Reader<TransportAddress>> registry = new HashMap<>();
|
||||
addAddressType(registry, InetSocketTransportAddress.TYPE_ID, InetSocketTransportAddress::new);
|
||||
addAddressType(registry, LocalTransportAddress.TYPE_ID, LocalTransportAddress::new);
|
||||
ADDRESS_REGISTRY = unmodifiableMap(registry);
|
||||
}
|
||||
|
||||
private static void addAddressType(Map<Short, Writeable.Reader<TransportAddress>> registry, short uniqueAddressTypeId,
|
||||
Writeable.Reader<TransportAddress> address) {
|
||||
if (registry.containsKey(uniqueAddressTypeId)) {
|
||||
throw new IllegalStateException("Address [" + uniqueAddressTypeId + "] already bound");
|
||||
}
|
||||
registry.put(uniqueAddressTypeId, address);
|
||||
}
|
||||
|
||||
public static TransportAddress addressFromStream(StreamInput input) throws IOException {
|
||||
// TODO why don't we just use named writeables here?
|
||||
short addressUniqueId = input.readShort();
|
||||
Writeable.Reader<TransportAddress> addressType = ADDRESS_REGISTRY.get(addressUniqueId);
|
||||
if (addressType == null) {
|
||||
throw new IOException("No transport address mapped to [" + addressUniqueId + "]");
|
||||
}
|
||||
return addressType.read(input);
|
||||
}
|
||||
|
||||
public static void addressToStream(StreamOutput out, TransportAddress address) throws IOException {
|
||||
out.writeShort(address.uniqueAddressTypeId());
|
||||
address.writeTo(out);
|
||||
}
|
||||
}
|
|
@ -37,7 +37,7 @@ import org.elasticsearch.cluster.service.ClusterService;
|
|||
import org.elasticsearch.common.Priority;
|
||||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.discovery.DiscoverySettings;
|
||||
import org.elasticsearch.discovery.zen.membership.MembershipAction;
|
||||
|
@ -385,7 +385,8 @@ public class NodeJoinController extends AbstractComponent {
|
|||
/**
|
||||
* a task indicated that the current node should become master, if no current master is known
|
||||
*/
|
||||
private static final DiscoveryNode BECOME_MASTER_TASK = new DiscoveryNode("_BECOME_MASTER_TASK_", LocalTransportAddress.buildUnique(),
|
||||
private static final DiscoveryNode BECOME_MASTER_TASK = new DiscoveryNode("_BECOME_MASTER_TASK_",
|
||||
new TransportAddress(TransportAddress.META_ADDRESS, 0),
|
||||
Collections.emptyMap(), Collections.emptySet(), Version.CURRENT) {
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -398,7 +399,7 @@ public class NodeJoinController extends AbstractComponent {
|
|||
* it may be use in combination with {@link #BECOME_MASTER_TASK}
|
||||
*/
|
||||
private static final DiscoveryNode FINISH_ELECTION_TASK = new DiscoveryNode("_FINISH_ELECTION_",
|
||||
LocalTransportAddress.buildUnique(), Collections.emptyMap(), Collections.emptySet(), Version.CURRENT) {
|
||||
new TransportAddress(TransportAddress.META_ADDRESS, 0), Collections.emptyMap(), Collections.emptySet(), Version.CURRENT) {
|
||||
@Override
|
||||
public String toString() {
|
||||
return ""; // this is not really task , so don't log anything about it...
|
||||
|
|
|
@ -42,7 +42,7 @@ public interface NetworkPlugin {
|
|||
* Returns a list of {@link TransportInterceptor} instances that are used to intercept incoming and outgoing
|
||||
* transport (inter-node) requests. This must not return <code>null</code>
|
||||
*/
|
||||
default List<TransportInterceptor> getTransportInterceptors() {
|
||||
default List<TransportInterceptor> getTransportInterceptors(NamedWriteableRegistry namedWriteableRegistry) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.Table;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.RestResponse;
|
||||
|
@ -108,11 +108,7 @@ public class RestNodeAttrsAction extends AbstractCatAction {
|
|||
table.addCell(info == null ? null : info.getProcess().getId());
|
||||
table.addCell(node.getHostName());
|
||||
table.addCell(node.getHostAddress());
|
||||
if (node.getAddress() instanceof InetSocketTransportAddress) {
|
||||
table.addCell(((InetSocketTransportAddress) node.getAddress()).address().getPort());
|
||||
} else {
|
||||
table.addCell("-");
|
||||
}
|
||||
table.addCell(node.getAddress().address().getPort());
|
||||
table.addCell(attrEntry.getKey());
|
||||
table.addCell(attrEntry.getValue());
|
||||
table.endRow();
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.elasticsearch.common.Table;
|
|||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.network.NetworkAddress;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.http.HttpInfo;
|
||||
import org.elasticsearch.index.cache.query.QueryCacheStats;
|
||||
|
@ -236,19 +235,11 @@ public class RestNodesAction extends AbstractCatAction {
|
|||
table.addCell(fullId ? node.getId() : Strings.substring(node.getId(), 0, 4));
|
||||
table.addCell(info == null ? null : info.getProcess().getId());
|
||||
table.addCell(node.getHostAddress());
|
||||
if (node.getAddress() instanceof InetSocketTransportAddress) {
|
||||
table.addCell(((InetSocketTransportAddress) node.getAddress()).address().getPort());
|
||||
} else {
|
||||
table.addCell("-");
|
||||
}
|
||||
table.addCell(node.getAddress().address().getPort());
|
||||
final HttpInfo httpInfo = info == null ? null : info.getHttp();
|
||||
if (httpInfo != null) {
|
||||
TransportAddress transportAddress = httpInfo.getAddress().publishAddress();
|
||||
if (transportAddress instanceof InetSocketTransportAddress) {
|
||||
table.addCell(NetworkAddress.format(((InetSocketTransportAddress)transportAddress).address()));
|
||||
} else {
|
||||
table.addCell(transportAddress.toString());
|
||||
}
|
||||
table.addCell(NetworkAddress.format(transportAddress.address()));
|
||||
} else {
|
||||
table.addCell("-");
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.Table;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
|
@ -144,11 +144,7 @@ public class RestTasksAction extends AbstractCatAction {
|
|||
// Node information. Note that the node may be null because it has left the cluster between when we got this response and now.
|
||||
table.addCell(fullId ? nodeId : Strings.substring(nodeId, 0, 4));
|
||||
table.addCell(node == null ? "-" : node.getHostAddress());
|
||||
if (node != null && node.getAddress() instanceof InetSocketTransportAddress) {
|
||||
table.addCell(((InetSocketTransportAddress) node.getAddress()).address().getPort());
|
||||
} else {
|
||||
table.addCell("-");
|
||||
}
|
||||
table.addCell(node.getAddress().address().getPort());
|
||||
table.addCell(node == null ? "-" : node.getName());
|
||||
table.addCell(node == null ? "-" : node.getVersion().toString());
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.elasticsearch.common.Table;
|
|||
import org.elasticsearch.common.inject.Inject;
|
||||
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 org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.RestResponse;
|
||||
|
@ -195,11 +195,7 @@ public class RestThreadPoolAction extends AbstractCatAction {
|
|||
table.addCell(info == null ? null : info.getProcess().getId());
|
||||
table.addCell(node.getHostName());
|
||||
table.addCell(node.getHostAddress());
|
||||
if (node.getAddress() instanceof InetSocketTransportAddress) {
|
||||
table.addCell(((InetSocketTransportAddress) node.getAddress()).address().getPort());
|
||||
} else {
|
||||
table.addCell("-");
|
||||
}
|
||||
table.addCell(node.getAddress().address().getPort());
|
||||
final ThreadPoolStats.Stats poolStats = entry.getValue();
|
||||
final ThreadPool.Info poolInfo = poolThreadInfo.get(entry.getKey());
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.elasticsearch.transport;
|
|||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.common.transport.TransportAddressSerializers;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -39,11 +38,7 @@ public class ActionTransportException extends TransportException {
|
|||
|
||||
public ActionTransportException(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
if (in.readBoolean()) {
|
||||
address = TransportAddressSerializers.addressFromStream(in);
|
||||
} else {
|
||||
address = null;
|
||||
}
|
||||
address = in.readOptionalWriteable(TransportAddress::new);
|
||||
action = in.readOptionalString();
|
||||
}
|
||||
|
||||
|
@ -62,12 +57,7 @@ public class ActionTransportException extends TransportException {
|
|||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
if (address != null) {
|
||||
out.writeBoolean(true);
|
||||
TransportAddressSerializers.addressToStream(out, address);
|
||||
} else {
|
||||
out.writeBoolean(false);
|
||||
}
|
||||
out.writeOptionalWriteable(address);
|
||||
out.writeOptionalString(action);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,9 +53,8 @@ import org.elasticsearch.common.network.NetworkUtils;
|
|||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.BoundTransportAddress;
|
||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
||||
import org.elasticsearch.common.transport.PortsRange;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.common.transport.PortsRange;
|
||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
|
@ -506,7 +505,7 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
|
|||
|
||||
@Override
|
||||
public boolean addressSupported(Class<? extends TransportAddress> address) {
|
||||
return InetSocketTransportAddress.class.equals(address);
|
||||
return TransportAddress.class.equals(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -640,7 +639,7 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
|
|||
for (int i = 0; i < boundAddresses.size(); i++) {
|
||||
InetSocketAddress boundAddress = boundAddresses.get(i);
|
||||
boundAddressesHostStrings[i] = boundAddress.getHostString();
|
||||
transportBoundAddresses[i] = new InetSocketTransportAddress(boundAddress);
|
||||
transportBoundAddresses[i] = new TransportAddress(boundAddress);
|
||||
}
|
||||
|
||||
final String[] publishHosts;
|
||||
|
@ -658,7 +657,7 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
|
|||
}
|
||||
|
||||
final int publishPort = resolvePublishPort(name, settings, profileSettings, boundAddresses, publishInetAddress);
|
||||
final TransportAddress publishAddress = new InetSocketTransportAddress(new InetSocketAddress(publishInetAddress, publishPort));
|
||||
final TransportAddress publishAddress = new TransportAddress(new InetSocketAddress(publishInetAddress, publishPort));
|
||||
return new BoundTransportAddress(transportBoundAddresses, publishAddress);
|
||||
}
|
||||
|
||||
|
@ -757,7 +756,7 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
|
|||
int limit = Math.min(ports.length, perAddressLimit);
|
||||
for (int i = 0; i < limit; i++) {
|
||||
for (InetAddress address : addresses) {
|
||||
transportAddresses.add(new InetSocketTransportAddress(address, ports[i]));
|
||||
transportAddresses.add(new TransportAddress(address, ports[i]));
|
||||
}
|
||||
}
|
||||
return transportAddresses.toArray(new TransportAddress[transportAddresses.size()]);
|
||||
|
@ -967,7 +966,7 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
|
|||
try (BytesStreamOutput stream = new BytesStreamOutput()) {
|
||||
stream.setVersion(nodeVersion);
|
||||
RemoteTransportException tx = new RemoteTransportException(
|
||||
nodeName(), new InetSocketTransportAddress(getLocalAddress(channel)), action, error);
|
||||
nodeName(), new TransportAddress(getLocalAddress(channel)), action, error);
|
||||
threadPool.getThreadContext().writeTo(stream);
|
||||
stream.writeException(tx);
|
||||
byte status = 0;
|
||||
|
@ -1194,9 +1193,10 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
|
|||
}
|
||||
streamIn = compressor.streamInput(streamIn);
|
||||
}
|
||||
if (version.onOrAfter(Version.CURRENT.minimumCompatibilityVersion()) == false || version.major != Version.CURRENT.major) {
|
||||
if (version.onOrAfter(getCurrentVersion().minimumCompatibilityVersion()) == false
|
||||
|| version.major != getCurrentVersion().major) {
|
||||
throw new IllegalStateException("Received message from unsupported version: [" + version
|
||||
+ "] minimal compatible version is: [" +Version.CURRENT.minimumCompatibilityVersion() + "]");
|
||||
+ "] minimal compatible version is: [" + getCurrentVersion().minimumCompatibilityVersion() + "]");
|
||||
}
|
||||
streamIn = new NamedWriteableAwareStreamInput(streamIn, namedWriteableRegistry);
|
||||
streamIn.setVersion(version);
|
||||
|
@ -1233,7 +1233,7 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
|
|||
|
||||
private void handleResponse(InetSocketAddress remoteAddress, final StreamInput stream, final TransportResponseHandler handler) {
|
||||
final TransportResponse response = handler.newInstance();
|
||||
response.remoteAddress(new InetSocketTransportAddress(remoteAddress));
|
||||
response.remoteAddress(new TransportAddress(remoteAddress));
|
||||
try {
|
||||
response.readFrom(stream);
|
||||
} catch (Exception e) {
|
||||
|
@ -1299,7 +1299,7 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
|
|||
transportChannel = new TcpTransportChannel<>(this, channel, transportName, action, requestId, version, profileName,
|
||||
messageLengthBytes);
|
||||
final TransportRequest request = reg.newRequest();
|
||||
request.remoteAddress(new InetSocketTransportAddress(remoteAddress));
|
||||
request.remoteAddress(new TransportAddress(remoteAddress));
|
||||
request.readFrom(stream);
|
||||
// in case we throw an exception, i.e. when the limit is hit, we don't want to verify
|
||||
validateRequest(stream, requestId, action);
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package org.elasticsearch.transport;
|
||||
|
||||
import org.elasticsearch.http.HttpServerTransport;
|
||||
import org.elasticsearch.transport.local.LocalTransport;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
@ -38,7 +37,6 @@ public enum Transports {
|
|||
public static final boolean isTransportThread(Thread t) {
|
||||
final String threadName = t.getName();
|
||||
for (String s : Arrays.asList(
|
||||
LocalTransport.LOCAL_TRANSPORT_THREAD_NAME_PREFIX,
|
||||
HttpServerTransport.HTTP_SERVER_BOSS_THREAD_NAME_PREFIX,
|
||||
HttpServerTransport.HTTP_SERVER_WORKER_THREAD_NAME_PREFIX,
|
||||
TcpTransport.TRANSPORT_SERVER_BOSS_THREAD_NAME_PREFIX,
|
||||
|
|
|
@ -1,430 +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.transport.local;
|
||||
|
||||
import org.apache.logging.log4j.message.ParameterizedMessage;
|
||||
import org.apache.logging.log4j.util.Supplier;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.breaker.CircuitBreaker;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.component.AbstractLifecycleComponent;
|
||||
import org.elasticsearch.common.component.Lifecycle;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.BoundTransportAddress;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
||||
import org.elasticsearch.common.util.concurrent.EsExecutors;
|
||||
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.ActionNotFoundTransportException;
|
||||
import org.elasticsearch.transport.ConnectTransportException;
|
||||
import org.elasticsearch.transport.NodeNotConnectedException;
|
||||
import org.elasticsearch.transport.RemoteTransportException;
|
||||
import org.elasticsearch.transport.RequestHandlerRegistry;
|
||||
import org.elasticsearch.transport.ResponseHandlerFailureTransportException;
|
||||
import org.elasticsearch.transport.Transport;
|
||||
import org.elasticsearch.transport.TransportException;
|
||||
import org.elasticsearch.transport.TransportRequest;
|
||||
import org.elasticsearch.transport.TransportRequestOptions;
|
||||
import org.elasticsearch.transport.TransportResponse;
|
||||
import org.elasticsearch.transport.TransportResponseHandler;
|
||||
import org.elasticsearch.transport.TransportSerializationException;
|
||||
import org.elasticsearch.transport.TransportServiceAdapter;
|
||||
import org.elasticsearch.transport.Transports;
|
||||
import org.elasticsearch.transport.support.TransportStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.newConcurrentMap;
|
||||
|
||||
public class LocalTransport extends AbstractLifecycleComponent implements Transport {
|
||||
|
||||
public static final String LOCAL_TRANSPORT_THREAD_NAME_PREFIX = "local_transport";
|
||||
final ThreadPool threadPool;
|
||||
private final ThreadPoolExecutor workers;
|
||||
private volatile TransportServiceAdapter transportServiceAdapter;
|
||||
private volatile BoundTransportAddress boundAddress;
|
||||
private volatile LocalTransportAddress localAddress;
|
||||
private static final ConcurrentMap<LocalTransportAddress, LocalTransport> transports = newConcurrentMap();
|
||||
private static final AtomicLong transportAddressIdGenerator = new AtomicLong();
|
||||
private final ConcurrentMap<DiscoveryNode, LocalTransport> connectedNodes = newConcurrentMap();
|
||||
protected final NamedWriteableRegistry namedWriteableRegistry;
|
||||
private final CircuitBreakerService circuitBreakerService;
|
||||
|
||||
public static final String TRANSPORT_LOCAL_ADDRESS = "transport.local.address";
|
||||
public static final String TRANSPORT_LOCAL_WORKERS = "transport.local.workers";
|
||||
public static final String TRANSPORT_LOCAL_QUEUE = "transport.local.queue";
|
||||
|
||||
public LocalTransport(Settings settings, ThreadPool threadPool,
|
||||
NamedWriteableRegistry namedWriteableRegistry, CircuitBreakerService circuitBreakerService) {
|
||||
super(settings);
|
||||
this.threadPool = threadPool;
|
||||
int workerCount = this.settings.getAsInt(TRANSPORT_LOCAL_WORKERS, EsExecutors.boundedNumberOfProcessors(settings));
|
||||
int queueSize = this.settings.getAsInt(TRANSPORT_LOCAL_QUEUE, -1);
|
||||
logger.debug("creating [{}] workers, queue_size [{}]", workerCount, queueSize);
|
||||
final ThreadFactory threadFactory = EsExecutors.daemonThreadFactory(this.settings, LOCAL_TRANSPORT_THREAD_NAME_PREFIX);
|
||||
this.workers = EsExecutors.newFixed(LOCAL_TRANSPORT_THREAD_NAME_PREFIX, workerCount, queueSize, threadFactory,
|
||||
threadPool.getThreadContext());
|
||||
this.namedWriteableRegistry = namedWriteableRegistry;
|
||||
this.circuitBreakerService = circuitBreakerService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransportAddress[] addressesFromString(String address, int perAddressLimit) {
|
||||
return new TransportAddress[]{new LocalTransportAddress(address)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addressSupported(Class<? extends TransportAddress> address) {
|
||||
return LocalTransportAddress.class.equals(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() {
|
||||
String address = settings.get(TRANSPORT_LOCAL_ADDRESS);
|
||||
if (address == null) {
|
||||
address = Long.toString(transportAddressIdGenerator.incrementAndGet());
|
||||
}
|
||||
localAddress = new LocalTransportAddress(address);
|
||||
LocalTransport previous = transports.put(localAddress, this);
|
||||
if (previous != null) {
|
||||
throw new ElasticsearchException("local address [" + address + "] is already bound");
|
||||
}
|
||||
boundAddress = new BoundTransportAddress(new TransportAddress[] { localAddress }, localAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() {
|
||||
transports.remove(localAddress);
|
||||
// now, go over all the transports connected to me, and raise disconnected event
|
||||
for (final LocalTransport targetTransport : transports.values()) {
|
||||
for (final Map.Entry<DiscoveryNode, LocalTransport> entry : targetTransport.connectedNodes.entrySet()) {
|
||||
if (entry.getValue() == this) {
|
||||
targetTransport.disconnectFromNode(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClose() {
|
||||
ThreadPool.terminate(workers, 10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transportServiceAdapter(TransportServiceAdapter transportServiceAdapter) {
|
||||
this.transportServiceAdapter = transportServiceAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundTransportAddress boundAddress() {
|
||||
return boundAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, BoundTransportAddress> profileBoundAddresses() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nodeConnected(DiscoveryNode node) {
|
||||
return connectedNodes.containsKey(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectToNodeLight(DiscoveryNode node) throws ConnectTransportException {
|
||||
connectToNode(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectToNode(DiscoveryNode node) throws ConnectTransportException {
|
||||
synchronized (this) {
|
||||
if (connectedNodes.containsKey(node)) {
|
||||
return;
|
||||
}
|
||||
final LocalTransport targetTransport = transports.get(node.getAddress());
|
||||
if (targetTransport == null) {
|
||||
throw new ConnectTransportException(node, "Failed to connect");
|
||||
}
|
||||
connectedNodes.put(node, targetTransport);
|
||||
transportServiceAdapter.raiseNodeConnected(node);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnectFromNode(DiscoveryNode node) {
|
||||
synchronized (this) {
|
||||
LocalTransport removed = connectedNodes.remove(node);
|
||||
if (removed != null) {
|
||||
transportServiceAdapter.raiseNodeDisconnected(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long serverOpen() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequest(final DiscoveryNode node, final long requestId, final String action, final TransportRequest request,
|
||||
TransportRequestOptions options) throws IOException, TransportException {
|
||||
final Version version = Version.smallest(node.getVersion(), getVersion());
|
||||
|
||||
try (BytesStreamOutput stream = new BytesStreamOutput()) {
|
||||
stream.setVersion(version);
|
||||
|
||||
stream.writeLong(requestId);
|
||||
byte status = 0;
|
||||
status = TransportStatus.setRequest(status);
|
||||
stream.writeByte(status); // 0 for request, 1 for response.
|
||||
|
||||
threadPool.getThreadContext().writeTo(stream);
|
||||
stream.writeString(action);
|
||||
request.writeTo(stream);
|
||||
|
||||
stream.close();
|
||||
|
||||
final LocalTransport targetTransport = connectedNodes.get(node);
|
||||
if (targetTransport == null) {
|
||||
throw new NodeNotConnectedException(node, "Node not connected");
|
||||
}
|
||||
|
||||
final byte[] data = BytesReference.toBytes(stream.bytes());
|
||||
transportServiceAdapter.addBytesSent(data.length);
|
||||
transportServiceAdapter.onRequestSent(node, requestId, action, request, options);
|
||||
targetTransport.receiveMessage(version, data, action, requestId, this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* entry point for incoming messages
|
||||
*
|
||||
* @param version the version used to serialize the message
|
||||
* @param data message data
|
||||
* @param action the action associated with this message (only used for error handling when data is not parsable)
|
||||
* @param requestId requestId if the message is request (only used for error handling when data is not parsable)
|
||||
* @param sourceTransport the source transport to respond to.
|
||||
*/
|
||||
public void receiveMessage(Version version, byte[] data, String action, @Nullable Long requestId, LocalTransport sourceTransport) {
|
||||
try {
|
||||
workers().execute(() -> {
|
||||
ThreadContext threadContext = threadPool.getThreadContext();
|
||||
try (ThreadContext.StoredContext context = threadContext.stashContext()) {
|
||||
processReceivedMessage(data, action, sourceTransport, version, requestId);
|
||||
}
|
||||
});
|
||||
} catch (EsRejectedExecutionException e) {
|
||||
assert lifecycle.started() == false;
|
||||
logger.trace("received request but shutting down. ignoring. action [{}], request id [{}]", action, requestId);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadPoolExecutor workers() {
|
||||
return this.workers;
|
||||
}
|
||||
|
||||
CircuitBreaker inFlightRequestsBreaker() {
|
||||
// We always obtain a fresh breaker to reflect changes to the breaker configuration.
|
||||
return circuitBreakerService.getBreaker(CircuitBreaker.IN_FLIGHT_REQUESTS);
|
||||
}
|
||||
|
||||
/** processes received messages, assuming thread passing and thread context have all been dealt with */
|
||||
protected void processReceivedMessage(byte[] data, String action, LocalTransport sourceTransport, Version version,
|
||||
@Nullable final Long sendRequestId) {
|
||||
Transports.assertTransportThread();
|
||||
try {
|
||||
transportServiceAdapter.addBytesReceived(data.length);
|
||||
StreamInput stream = StreamInput.wrap(data);
|
||||
stream.setVersion(version);
|
||||
|
||||
long requestId = stream.readLong();
|
||||
byte status = stream.readByte();
|
||||
boolean isRequest = TransportStatus.isRequest(status);
|
||||
threadPool.getThreadContext().readHeaders(stream);
|
||||
if (isRequest) {
|
||||
handleRequest(stream, requestId, data.length, sourceTransport, version);
|
||||
} else {
|
||||
final TransportResponseHandler handler = transportServiceAdapter.onResponseReceived(requestId);
|
||||
// ignore if its null, the adapter logs it
|
||||
if (handler != null) {
|
||||
if (TransportStatus.isError(status)) {
|
||||
handleResponseError(stream, handler);
|
||||
} else {
|
||||
handleResponse(stream, sourceTransport, handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (sendRequestId != null) {
|
||||
TransportResponseHandler handler = sourceTransport.transportServiceAdapter.onResponseReceived(sendRequestId);
|
||||
if (handler != null) {
|
||||
RemoteTransportException error = new RemoteTransportException(nodeName(), localAddress, action, e);
|
||||
sourceTransport.workers().execute(() -> {
|
||||
ThreadContext threadContext = sourceTransport.threadPool.getThreadContext();
|
||||
try (ThreadContext.StoredContext ignore = threadContext.stashContext()) {
|
||||
sourceTransport.handleException(handler, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
logger.warn((Supplier<?>) () -> new ParameterizedMessage("Failed to receive message for action [{}]", action), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleRequest(StreamInput stream, long requestId, int messageLengthBytes, LocalTransport sourceTransport,
|
||||
Version version) throws Exception {
|
||||
stream = new NamedWriteableAwareStreamInput(stream, namedWriteableRegistry);
|
||||
final String action = stream.readString();
|
||||
final RequestHandlerRegistry reg = transportServiceAdapter.getRequestHandler(action);
|
||||
transportServiceAdapter.onRequestReceived(requestId, action);
|
||||
if (reg != null && reg.canTripCircuitBreaker()) {
|
||||
inFlightRequestsBreaker().addEstimateBytesAndMaybeBreak(messageLengthBytes, "<transport_request>");
|
||||
} else {
|
||||
inFlightRequestsBreaker().addWithoutBreaking(messageLengthBytes);
|
||||
}
|
||||
final LocalTransportChannel transportChannel = new LocalTransportChannel(this, transportServiceAdapter, sourceTransport, action,
|
||||
requestId, version, messageLengthBytes, threadPool.getThreadContext());
|
||||
try {
|
||||
if (reg == null) {
|
||||
throw new ActionNotFoundTransportException("Action [" + action + "] not found");
|
||||
}
|
||||
final TransportRequest request = reg.newRequest();
|
||||
request.remoteAddress(sourceTransport.boundAddress.publishAddress());
|
||||
request.readFrom(stream);
|
||||
if (ThreadPool.Names.SAME.equals(reg.getExecutor())) {
|
||||
//noinspection unchecked
|
||||
reg.processMessageReceived(request, transportChannel);
|
||||
} else {
|
||||
threadPool.executor(reg.getExecutor()).execute(new AbstractRunnable() {
|
||||
@Override
|
||||
protected void doRun() throws Exception {
|
||||
//noinspection unchecked
|
||||
reg.processMessageReceived(request, transportChannel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForceExecution() {
|
||||
return reg.isForceExecution();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
if (lifecycleState() == Lifecycle.State.STARTED) {
|
||||
// we can only send a response transport is started....
|
||||
try {
|
||||
transportChannel.sendResponse(e);
|
||||
} catch (Exception inner) {
|
||||
inner.addSuppressed(e);
|
||||
logger.warn(
|
||||
(Supplier<?>) () -> new ParameterizedMessage(
|
||||
"Failed to send error message back to client for action [{}]", action), inner);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
transportChannel.sendResponse(e);
|
||||
} catch (Exception inner) {
|
||||
inner.addSuppressed(e);
|
||||
logger.warn(
|
||||
(Supplier<?>) () -> new ParameterizedMessage(
|
||||
"Failed to send error message back to client for action [{}]", action), inner);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleResponse(StreamInput buffer, LocalTransport sourceTransport, final TransportResponseHandler handler) {
|
||||
buffer = new NamedWriteableAwareStreamInput(buffer, namedWriteableRegistry);
|
||||
final TransportResponse response = handler.newInstance();
|
||||
response.remoteAddress(sourceTransport.boundAddress.publishAddress());
|
||||
try {
|
||||
response.readFrom(buffer);
|
||||
} catch (Exception e) {
|
||||
handleException(handler, new TransportSerializationException(
|
||||
"Failed to deserialize response of type [" + response.getClass().getName() + "]", e));
|
||||
return;
|
||||
}
|
||||
handleParsedResponse(response, handler);
|
||||
}
|
||||
|
||||
protected void handleParsedResponse(final TransportResponse response, final TransportResponseHandler handler) {
|
||||
threadPool.executor(handler.executor()).execute(() -> {
|
||||
try {
|
||||
handler.handleResponse(response);
|
||||
} catch (Exception e) {
|
||||
handleException(handler, new ResponseHandlerFailureTransportException(e));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void handleResponseError(StreamInput buffer, final TransportResponseHandler handler) {
|
||||
Exception exception;
|
||||
try {
|
||||
exception = buffer.readException();
|
||||
} catch (Exception e) {
|
||||
exception = new TransportSerializationException("Failed to deserialize exception response from stream", e);
|
||||
}
|
||||
handleException(handler, exception);
|
||||
}
|
||||
|
||||
private void handleException(final TransportResponseHandler handler, Exception exception) {
|
||||
if (!(exception instanceof RemoteTransportException)) {
|
||||
exception = new RemoteTransportException("Not a remote transport exception", null, null, exception);
|
||||
}
|
||||
final RemoteTransportException rtx = (RemoteTransportException) exception;
|
||||
try {
|
||||
handler.handleException(rtx);
|
||||
} catch (Exception e) {
|
||||
logger.error((Supplier<?>) () -> new ParameterizedMessage("failed to handle exception response [{}]", handler), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLocalAddresses() {
|
||||
return Collections.singletonList("0.0.0.0");
|
||||
}
|
||||
|
||||
protected Version getVersion() { // for tests
|
||||
return Version.CURRENT;
|
||||
}
|
||||
}
|
|
@ -1,139 +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.transport.local;
|
||||
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||
import org.elasticsearch.transport.RemoteTransportException;
|
||||
import org.elasticsearch.transport.TransportChannel;
|
||||
import org.elasticsearch.transport.TransportResponse;
|
||||
import org.elasticsearch.transport.TransportResponseOptions;
|
||||
import org.elasticsearch.transport.TransportServiceAdapter;
|
||||
import org.elasticsearch.transport.support.TransportStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class LocalTransportChannel implements TransportChannel {
|
||||
|
||||
private static final String LOCAL_TRANSPORT_PROFILE = "default";
|
||||
|
||||
private final LocalTransport sourceTransport;
|
||||
private final TransportServiceAdapter sourceTransportServiceAdapter;
|
||||
// the transport we will *send to*
|
||||
private final LocalTransport targetTransport;
|
||||
private final String action;
|
||||
private final long requestId;
|
||||
private final Version version;
|
||||
private final long reservedBytes;
|
||||
private final ThreadContext threadContext;
|
||||
private final AtomicBoolean closed = new AtomicBoolean();
|
||||
|
||||
public LocalTransportChannel(LocalTransport sourceTransport, TransportServiceAdapter sourceTransportServiceAdapter,
|
||||
LocalTransport targetTransport, String action, long requestId, Version version, long reservedBytes,
|
||||
ThreadContext threadContext) {
|
||||
this.sourceTransport = sourceTransport;
|
||||
this.sourceTransportServiceAdapter = sourceTransportServiceAdapter;
|
||||
this.targetTransport = targetTransport;
|
||||
this.action = action;
|
||||
this.requestId = requestId;
|
||||
this.version = version;
|
||||
this.reservedBytes = reservedBytes;
|
||||
this.threadContext = threadContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String action() {
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProfileName() {
|
||||
return LOCAL_TRANSPORT_PROFILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendResponse(TransportResponse response) throws IOException {
|
||||
sendResponse(response, TransportResponseOptions.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendResponse(TransportResponse response, TransportResponseOptions options) throws IOException {
|
||||
try (BytesStreamOutput stream = new BytesStreamOutput()) {
|
||||
stream.setVersion(version);
|
||||
stream.writeLong(requestId);
|
||||
byte status = 0;
|
||||
status = TransportStatus.setResponse(status);
|
||||
stream.writeByte(status); // 0 for request, 1 for response.
|
||||
threadContext.writeTo(stream);
|
||||
response.writeTo(stream);
|
||||
sendResponseData(BytesReference.toBytes(stream.bytes()));
|
||||
sourceTransportServiceAdapter.onResponseSent(requestId, action, response, options);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendResponse(Exception exception) throws IOException {
|
||||
BytesStreamOutput stream = new BytesStreamOutput();
|
||||
writeResponseExceptionHeader(stream);
|
||||
RemoteTransportException tx = new RemoteTransportException(targetTransport.nodeName(),
|
||||
targetTransport.boundAddress().boundAddresses()[0], action, exception);
|
||||
stream.writeException(tx);
|
||||
sendResponseData(BytesReference.toBytes(stream.bytes()));
|
||||
sourceTransportServiceAdapter.onResponseSent(requestId, action, exception);
|
||||
}
|
||||
|
||||
private void sendResponseData(byte[] data) {
|
||||
close();
|
||||
targetTransport.receiveMessage(version, data, action, null, sourceTransport);
|
||||
}
|
||||
|
||||
private void close() {
|
||||
// attempt to close once atomically
|
||||
if (closed.compareAndSet(false, true) == false) {
|
||||
throw new IllegalStateException("Channel is already closed");
|
||||
}
|
||||
sourceTransport.inFlightRequestsBreaker().addWithoutBreaking(-reservedBytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRequestId() {
|
||||
return requestId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChannelType() {
|
||||
return "local";
|
||||
}
|
||||
|
||||
private void writeResponseExceptionHeader(BytesStreamOutput stream) throws IOException {
|
||||
stream.writeLong(requestId);
|
||||
byte status = 0;
|
||||
status = TransportStatus.setResponse(status);
|
||||
status = TransportStatus.setError(status);
|
||||
stream.writeByte(status);
|
||||
threadContext.writeTo(stream);
|
||||
}
|
||||
}
|
|
@ -40,7 +40,7 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
|||
import org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.util.CancellableThreadsTests;
|
||||
import org.elasticsearch.common.util.set.Sets;
|
||||
|
@ -373,11 +373,12 @@ public class ExceptionSerializationTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testActionTransportException() throws IOException {
|
||||
TransportAddress transportAddress = buildNewFakeTransportAddress();
|
||||
ActionTransportException ex = serialize(
|
||||
new ActionTransportException("name?", new LocalTransportAddress("dead.end:666"), "ACTION BABY!", "message?", null));
|
||||
new ActionTransportException("name?", transportAddress, "ACTION BABY!", "message?", null));
|
||||
assertEquals("ACTION BABY!", ex.action());
|
||||
assertEquals(new LocalTransportAddress("dead.end:666"), ex.address());
|
||||
assertEquals("[name?][local[dead.end:666]][ACTION BABY!] message?", ex.getMessage());
|
||||
assertEquals(transportAddress, ex.address());
|
||||
assertEquals("[name?][" + transportAddress.toString() +"][ACTION BABY!] message?", ex.getMessage());
|
||||
}
|
||||
|
||||
public void testSearchContextMissingException() throws IOException {
|
||||
|
@ -440,16 +441,17 @@ public class ExceptionSerializationTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testConnectTransportException() throws IOException {
|
||||
DiscoveryNode node = new DiscoveryNode("thenode", new LocalTransportAddress("dead.end:666"),
|
||||
TransportAddress transportAddress = buildNewFakeTransportAddress();
|
||||
DiscoveryNode node = new DiscoveryNode("thenode", transportAddress,
|
||||
emptyMap(), emptySet(), Version.CURRENT);
|
||||
ConnectTransportException ex = serialize(new ConnectTransportException(node, "msg", "action", null));
|
||||
assertEquals("[][local[dead.end:666]][action] msg", ex.getMessage());
|
||||
assertEquals("[][" + transportAddress.toString() + "][action] msg", ex.getMessage());
|
||||
assertEquals(node, ex.node());
|
||||
assertEquals("action", ex.action());
|
||||
assertNull(ex.getCause());
|
||||
|
||||
ex = serialize(new ConnectTransportException(node, "msg", "action", new NullPointerException()));
|
||||
assertEquals("[][local[dead.end:666]][action] msg", ex.getMessage());
|
||||
assertEquals("[]["+ transportAddress+ "][action] msg", ex.getMessage());
|
||||
assertEquals(node, ex.node());
|
||||
assertEquals("action", ex.action());
|
||||
assertTrue(ex.getCause() instanceof NullPointerException);
|
||||
|
|
|
@ -78,6 +78,7 @@ import org.elasticsearch.action.update.UpdateAction;
|
|||
import org.elasticsearch.action.update.UpdateRequest;
|
||||
import org.elasticsearch.action.update.UpdateResponse;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.plugins.NetworkPlugin;
|
||||
|
@ -742,7 +743,7 @@ public class IndicesRequestIT extends ESIntegTestCase {
|
|||
public static class TestPlugin extends Plugin implements NetworkPlugin {
|
||||
public final InterceptingTransportService instance = new InterceptingTransportService();
|
||||
@Override
|
||||
public List<TransportInterceptor> getTransportInterceptors() {
|
||||
public List<TransportInterceptor> getTransportInterceptors(NamedWriteableRegistry namedWriteableRegistry) {
|
||||
return Collections.singletonList(instance);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.elasticsearch.cluster.routing.allocation.decider.Decision;
|
|||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.util.set.Sets;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -67,7 +66,7 @@ public final class ClusterAllocationExplanationTests extends ESTestCase {
|
|||
.numberOfShards(1)
|
||||
.numberOfReplicas(1)
|
||||
.build();
|
||||
private DiscoveryNode node = new DiscoveryNode("node-0", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
private DiscoveryNode node = new DiscoveryNode("node-0", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
private static Decision.Multi yesDecision = new Decision.Multi();
|
||||
private static Decision.Multi noDecision = new Decision.Multi();
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.elasticsearch.action.admin.cluster.node.stats;
|
|||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.discovery.DiscoveryStats;
|
||||
import org.elasticsearch.discovery.zen.publish.PendingClusterStateStats;
|
||||
import org.elasticsearch.http.HttpStats;
|
||||
|
@ -255,7 +254,7 @@ public class NodeStatsTests extends ESTestCase {
|
|||
}
|
||||
|
||||
private static NodeStats createNodeStats() {
|
||||
DiscoveryNode node = new DiscoveryNode("test_node", LocalTransportAddress.buildUnique(),
|
||||
DiscoveryNode node = new DiscoveryNode("test_node", buildNewFakeTransportAddress(),
|
||||
emptyMap(), emptySet(), VersionUtils.randomVersion(random()));
|
||||
OsStats osStats = null;
|
||||
if (frequently()) {
|
||||
|
|
|
@ -44,15 +44,17 @@ import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
|||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.lease.Releasable;
|
||||
import org.elasticsearch.common.network.NetworkService;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
||||
import org.elasticsearch.tasks.TaskManager;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.tasks.MockTaskManager;
|
||||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.MockTcpTransport;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.transport.local.LocalTransport;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -168,8 +170,9 @@ public abstract class TaskManagerTestCase extends ESTestCase {
|
|||
public TestNode(String name, ThreadPool threadPool, Settings settings) {
|
||||
clusterService = createClusterService(threadPool);
|
||||
transportService = new TransportService(settings,
|
||||
new LocalTransport(settings, threadPool, new NamedWriteableRegistry(Collections.emptyList()),
|
||||
new NoneCircuitBreakerService()), threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR) {
|
||||
new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE, new NoneCircuitBreakerService(),
|
||||
new NamedWriteableRegistry(Collections.emptyList()), new NetworkService(settings, Collections.emptyList())),
|
||||
threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR) {
|
||||
@Override
|
||||
protected TaskManager createTaskManager() {
|
||||
if (MockTaskManager.USE_MOCK_TASK_MANAGER_SETTING.get(settings)) {
|
||||
|
|
|
@ -58,6 +58,7 @@ import org.elasticsearch.test.ESIntegTestCase;
|
|||
import org.elasticsearch.test.tasks.MockTaskManager;
|
||||
import org.elasticsearch.test.tasks.MockTaskManagerListener;
|
||||
import org.elasticsearch.test.transport.MockTransportService;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
import org.elasticsearch.transport.ReceiveTimeoutTransportException;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
|
@ -102,8 +103,10 @@ public class TasksIT extends ESIntegTestCase {
|
|||
private Map<Tuple<String, String>, RecordingTaskManagerListener> listeners = new HashMap<>();
|
||||
|
||||
@Override
|
||||
protected boolean addMockTransportService() {
|
||||
return false;
|
||||
protected Collection<Class<? extends Plugin>> getMockPlugins() {
|
||||
Collection<Class<? extends Plugin>> mockPlugins = new ArrayList<>(super.getMockPlugins());
|
||||
mockPlugins.remove(MockTransportService.TestPlugin.class);
|
||||
return mockPlugins;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.elasticsearch.common.UUIDs;
|
|||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenIntMap;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
|
@ -53,8 +52,8 @@ public class IndicesShardStoreResponseTests extends ESTestCase {
|
|||
List<IndicesShardStoresResponse.Failure> failures = new ArrayList<>();
|
||||
ImmutableOpenIntMap.Builder<List<IndicesShardStoresResponse.StoreStatus>> storeStatuses = ImmutableOpenIntMap.builder();
|
||||
|
||||
DiscoveryNode node1 = new DiscoveryNode("node1", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNode node2 = new DiscoveryNode("node2", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNode node1 = new DiscoveryNode("node1", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNode node2 = new DiscoveryNode("node2", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
List<IndicesShardStoresResponse.StoreStatus> storeStatusList = new ArrayList<>();
|
||||
storeStatusList.add(new IndicesShardStoresResponse.StoreStatus(node1, 3, null, IndicesShardStoresResponse.StoreStatus.AllocationStatus.PRIMARY, null));
|
||||
storeStatusList.add(new IndicesShardStoresResponse.StoreStatus(node2, ShardStateMetaData.NO_VERSION, UUIDs.randomBase64UUID(), IndicesShardStoresResponse.StoreStatus.AllocationStatus.REPLICA, null));
|
||||
|
@ -122,7 +121,7 @@ public class IndicesShardStoreResponseTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testStoreStatusOrdering() throws Exception {
|
||||
DiscoveryNode node1 = new DiscoveryNode("node1", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNode node1 = new DiscoveryNode("node1", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
List<IndicesShardStoresResponse.StoreStatus> orderedStoreStatuses = new ArrayList<>();
|
||||
orderedStoreStatuses.add(new IndicesShardStoresResponse.StoreStatus(node1, ShardStateMetaData.NO_VERSION, UUIDs.randomBase64UUID(), IndicesShardStoresResponse.StoreStatus.AllocationStatus.PRIMARY, null));
|
||||
orderedStoreStatuses.add(new IndicesShardStoresResponse.StoreStatus(node1, ShardStateMetaData.NO_VERSION, UUIDs.randomBase64UUID(), IndicesShardStoresResponse.StoreStatus.AllocationStatus.REPLICA, null));
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllo
|
|||
import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders;
|
||||
import org.elasticsearch.cluster.routing.allocation.decider.MaxRetryAllocationDecider;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.index.shard.DocsStats;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.gateway.TestGatewayAllocator;
|
||||
|
@ -144,7 +143,7 @@ public class TransportShrinkActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
private DiscoveryNode newNode(String nodeId) {
|
||||
return new DiscoveryNode(nodeId, LocalTransportAddress.buildUnique(), emptyMap(),
|
||||
return new DiscoveryNode(nodeId, buildNewFakeTransportAddress(), emptyMap(),
|
||||
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(DiscoveryNode.Role.MASTER, DiscoveryNode.Role.DATA))), Version.CURRENT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
|
|||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.tasks.Task;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.VersionUtils;
|
||||
|
@ -79,7 +78,7 @@ public class IngestProxyActionFilterTests extends ESTestCase {
|
|||
if (i < ingestNodes) {
|
||||
roles.add(DiscoveryNode.Role.INGEST);
|
||||
}
|
||||
DiscoveryNode node = new DiscoveryNode(nodeId, nodeId, LocalTransportAddress.buildUnique(), attributes, roles, VersionUtils.randomVersion(random()));
|
||||
DiscoveryNode node = new DiscoveryNode(nodeId, nodeId, buildNewFakeTransportAddress(), attributes, roles, VersionUtils.randomVersion(random()));
|
||||
builder.add(node);
|
||||
if (i == totalNodes - 1) {
|
||||
localNode = node;
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
|
|||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.tasks.TaskManager;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
@ -117,12 +116,12 @@ public class TransportMultiSearchActionTests extends ESTestCase {
|
|||
int numDataNodes = randomIntBetween(1, 10);
|
||||
DiscoveryNodes.Builder builder = DiscoveryNodes.builder();
|
||||
for (int i = 0; i < numDataNodes; i++) {
|
||||
builder.add(new DiscoveryNode("_id" + i, new LocalTransportAddress("_id" + i), Collections.emptyMap(),
|
||||
builder.add(new DiscoveryNode("_id" + i, buildNewFakeTransportAddress(), Collections.emptyMap(),
|
||||
Collections.singleton(DiscoveryNode.Role.DATA), Version.CURRENT));
|
||||
}
|
||||
builder.add(new DiscoveryNode("master", new LocalTransportAddress("mater"), Collections.emptyMap(),
|
||||
builder.add(new DiscoveryNode("master", buildNewFakeTransportAddress(), Collections.emptyMap(),
|
||||
Collections.singleton(DiscoveryNode.Role.MASTER), Version.CURRENT));
|
||||
builder.add(new DiscoveryNode("ingest", new LocalTransportAddress("ingest"), Collections.emptyMap(),
|
||||
builder.add(new DiscoveryNode("ingest", buildNewFakeTransportAddress(), Collections.emptyMap(),
|
||||
Collections.singleton(DiscoveryNode.Role.INGEST), Version.CURRENT));
|
||||
|
||||
ClusterState state = ClusterState.builder(new ClusterName("_name")).nodes(builder).build();
|
||||
|
|
|
@ -49,7 +49,6 @@ import org.elasticsearch.cluster.routing.TestShardRouting;
|
|||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
@ -248,7 +247,7 @@ public class TransportBroadcastByNodeActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
static DiscoveryNode newNode(int nodeId) {
|
||||
return new DiscoveryNode("node_" + nodeId, LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
return new DiscoveryNode("node_" + nodeId, buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.action.support.master;
|
|||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.discovery.DiscoveryModule;
|
||||
import org.elasticsearch.discovery.DiscoverySettings;
|
||||
import org.elasticsearch.discovery.zen.ElectMasterService;
|
||||
import org.elasticsearch.discovery.zen.fd.FaultDetection;
|
||||
|
@ -43,7 +44,6 @@ import java.util.concurrent.CyclicBarrier;
|
|||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0)
|
||||
@ESIntegTestCase.SuppressLocalMode
|
||||
public class IndexingMasterFailoverIT extends ESIntegTestCase {
|
||||
|
||||
@Override
|
||||
|
@ -62,6 +62,7 @@ public class IndexingMasterFailoverIT extends ESIntegTestCase {
|
|||
logger.info("--> start 4 nodes, 3 master, 1 data");
|
||||
|
||||
final Settings sharedSettings = Settings.builder()
|
||||
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "zen")
|
||||
.put(FaultDetection.PING_TIMEOUT_SETTING.getKey(), "1s") // for hitting simulated network failures quickly
|
||||
.put(FaultDetection.PING_RETRIES_SETTING.getKey(), "1") // for hitting simulated network failures quickly
|
||||
.put("discovery.zen.join_timeout", "10s") // still long to induce failures but to long so test won't time out
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
|||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.discovery.Discovery;
|
||||
import org.elasticsearch.discovery.MasterNotDiscoveredException;
|
||||
|
@ -90,9 +89,9 @@ public class TransportMasterNodeActionTests extends ESTestCase {
|
|||
transportService = new TransportService(clusterService.getSettings(), transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR);
|
||||
transportService.start();
|
||||
transportService.acceptIncomingRequests();
|
||||
localNode = new DiscoveryNode("local_node", LocalTransportAddress.buildUnique(), Collections.emptyMap(),
|
||||
localNode = new DiscoveryNode("local_node", buildNewFakeTransportAddress(), Collections.emptyMap(),
|
||||
Collections.singleton(DiscoveryNode.Role.MASTER), Version.CURRENT);
|
||||
remoteNode = new DiscoveryNode("remote_node", LocalTransportAddress.buildUnique(), Collections.emptyMap(),
|
||||
remoteNode = new DiscoveryNode("remote_node", buildNewFakeTransportAddress(), Collections.emptyMap(),
|
||||
Collections.singleton(DiscoveryNode.Role.MASTER), Version.CURRENT);
|
||||
allNodes = new DiscoveryNode[]{localNode, remoteNode};
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.elasticsearch.cluster.service.ClusterService;
|
|||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.transport.CapturingTransport;
|
||||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
|
@ -237,7 +236,7 @@ public class TransportNodesActionTests extends ESTestCase {
|
|||
|
||||
private static DiscoveryNode newNode(int nodeId, Map<String, String> attributes, Set<DiscoveryNode.Role> roles) {
|
||||
String node = "node_" + nodeId;
|
||||
return new DiscoveryNode(node, node, LocalTransportAddress.buildUnique(), attributes, roles, Version.CURRENT);
|
||||
return new DiscoveryNode(node, node, buildNewFakeTransportAddress(), attributes, roles, Version.CURRENT);
|
||||
}
|
||||
|
||||
private static class TestTransportNodesAction
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.elasticsearch.action.support.replication;
|
||||
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.NoShardAvailableActionException;
|
||||
import org.elasticsearch.action.ShardOperationFailedException;
|
||||
|
@ -35,7 +36,9 @@ import org.elasticsearch.cluster.routing.ShardRoutingState;
|
|||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.network.NetworkService;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
|
@ -45,8 +48,8 @@ import org.elasticsearch.tasks.Task;
|
|||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.MockTcpTransport;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.transport.local.LocalTransport;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
|
@ -89,7 +92,9 @@ public class BroadcastReplicationTests extends ESTestCase {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
LocalTransport transport = new LocalTransport(Settings.EMPTY, threadPool, new NamedWriteableRegistry(Collections.emptyList()), circuitBreakerService);
|
||||
MockTcpTransport transport = new MockTcpTransport(Settings.EMPTY,
|
||||
threadPool, BigArrays.NON_RECYCLING_INSTANCE, circuitBreakerService, new NamedWriteableRegistry(Collections.emptyList()),
|
||||
new NetworkService(Settings.EMPTY, Collections.emptyList()));
|
||||
clusterService = createClusterService(threadPool);
|
||||
transportService = new TransportService(clusterService.getSettings(), transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR);
|
||||
transportService.start();
|
||||
|
@ -100,8 +105,7 @@ public class BroadcastReplicationTests extends ESTestCase {
|
|||
@After
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
clusterService.close();
|
||||
transportService.close();
|
||||
IOUtils.close(clusterService, transportService);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
|
|
@ -34,8 +34,8 @@ import org.elasticsearch.cluster.routing.ShardRoutingState;
|
|||
import org.elasticsearch.cluster.routing.TestShardRouting;
|
||||
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -255,7 +255,7 @@ public class ClusterStateCreationUtils {
|
|||
}
|
||||
|
||||
private static DiscoveryNode newNode(int nodeId) {
|
||||
return new DiscoveryNode("node_" + nodeId, LocalTransportAddress.buildUnique(), Collections.emptyMap(),
|
||||
return new DiscoveryNode("node_" + nodeId, ESTestCase.buildNewFakeTransportAddress(), Collections.emptyMap(),
|
||||
new HashSet<>(Arrays.asList(DiscoveryNode.Role.values())), Version.CURRENT);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.monitor.jvm.JvmInfo;
|
|||
import org.elasticsearch.node.NodeValidationException;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -55,13 +56,11 @@ public class BootstrapCheckTests extends ESTestCase {
|
|||
// nothing should happen since we are in non-production mode
|
||||
final List<TransportAddress> transportAddresses = new ArrayList<>();
|
||||
for (int i = 0; i < randomIntBetween(1, 8); i++) {
|
||||
TransportAddress localTransportAddress = mock(TransportAddress.class);
|
||||
when(localTransportAddress.isLoopbackOrLinkLocalAddress()).thenReturn(true);
|
||||
TransportAddress localTransportAddress = new TransportAddress(InetAddress.getLoopbackAddress(), i);
|
||||
transportAddresses.add(localTransportAddress);
|
||||
}
|
||||
|
||||
TransportAddress publishAddress = mock(TransportAddress.class);
|
||||
when(publishAddress.isLoopbackOrLinkLocalAddress()).thenReturn(true);
|
||||
TransportAddress publishAddress = new TransportAddress(InetAddress.getLoopbackAddress(), 0);
|
||||
BoundTransportAddress boundTransportAddress = mock(BoundTransportAddress.class);
|
||||
when(boundTransportAddress.boundAddresses()).thenReturn(transportAddresses.toArray(new TransportAddress[0]));
|
||||
when(boundTransportAddress.publishAddress()).thenReturn(publishAddress);
|
||||
|
@ -83,18 +82,17 @@ public class BootstrapCheckTests extends ESTestCase {
|
|||
|
||||
public void testEnforceLimitsWhenBoundToNonLocalAddress() {
|
||||
final List<TransportAddress> transportAddresses = new ArrayList<>();
|
||||
final TransportAddress nonLocalTransportAddress = mock(TransportAddress.class);
|
||||
when(nonLocalTransportAddress.isLoopbackOrLinkLocalAddress()).thenReturn(false);
|
||||
final TransportAddress nonLocalTransportAddress = buildNewFakeTransportAddress();
|
||||
transportAddresses.add(nonLocalTransportAddress);
|
||||
|
||||
for (int i = 0; i < randomIntBetween(0, 7); i++) {
|
||||
final TransportAddress randomTransportAddress = mock(TransportAddress.class);
|
||||
when(randomTransportAddress.isLoopbackOrLinkLocalAddress()).thenReturn(randomBoolean());
|
||||
final TransportAddress randomTransportAddress = randomBoolean() ? buildNewFakeTransportAddress() :
|
||||
new TransportAddress(InetAddress.getLoopbackAddress(), i);
|
||||
transportAddresses.add(randomTransportAddress);
|
||||
}
|
||||
|
||||
final TransportAddress publishAddress = mock(TransportAddress.class);
|
||||
when(publishAddress.isLoopbackOrLinkLocalAddress()).thenReturn(randomBoolean());
|
||||
final TransportAddress publishAddress = randomBoolean() ? buildNewFakeTransportAddress() :
|
||||
new TransportAddress(InetAddress.getLoopbackAddress(), 0);
|
||||
|
||||
final BoundTransportAddress boundTransportAddress = mock(BoundTransportAddress.class);
|
||||
Collections.shuffle(transportAddresses, random());
|
||||
|
@ -108,14 +106,11 @@ public class BootstrapCheckTests extends ESTestCase {
|
|||
final List<TransportAddress> transportAddresses = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < randomIntBetween(1, 8); i++) {
|
||||
final TransportAddress randomTransportAddress = mock(TransportAddress.class);
|
||||
when(randomTransportAddress.isLoopbackOrLinkLocalAddress()).thenReturn(false);
|
||||
final TransportAddress randomTransportAddress = buildNewFakeTransportAddress();
|
||||
transportAddresses.add(randomTransportAddress);
|
||||
}
|
||||
|
||||
final TransportAddress publishAddress = mock(TransportAddress.class);
|
||||
when(publishAddress.isLoopbackOrLinkLocalAddress()).thenReturn(true);
|
||||
|
||||
final TransportAddress publishAddress = new TransportAddress(InetAddress.getLoopbackAddress(), 0);
|
||||
final BoundTransportAddress boundTransportAddress = mock(BoundTransportAddress.class);
|
||||
when(boundTransportAddress.boundAddresses()).thenReturn(transportAddresses.toArray(new TransportAddress[0]));
|
||||
when(boundTransportAddress.publishAddress()).thenReturn(publishAddress);
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.cluster.ClusterName;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.env.Environment;
|
||||
|
@ -61,14 +62,20 @@ public class TransportClientHeadersTests extends AbstractClientHeadersTestCase {
|
|||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
transportService.stop();
|
||||
transportService.close();
|
||||
try {
|
||||
// stop this first before we bubble up since
|
||||
// transportService uses the threadpool that super.tearDown will close
|
||||
transportService.stop();
|
||||
transportService.close();
|
||||
} finally {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Client buildClient(Settings headersSettings, GenericAction[] testedActions) {
|
||||
transportService = MockTransportService.local(Settings.EMPTY, Version.CURRENT, threadPool);
|
||||
transportService = MockTransportService.createNewService(Settings.EMPTY, Version.CURRENT, threadPool);
|
||||
transportService.start();
|
||||
transportService.acceptIncomingRequests();
|
||||
TransportClient client = new MockTransportClient(Settings.builder()
|
||||
|
@ -120,7 +127,7 @@ public class TransportClientHeadersTests extends AbstractClientHeadersTestCase {
|
|||
private InternalTransportServiceInterceptor instance = new InternalTransportServiceInterceptor();
|
||||
|
||||
@Override
|
||||
public List<TransportInterceptor> getTransportInterceptors() {
|
||||
public List<TransportInterceptor> getTransportInterceptors(NamedWriteableRegistry namedWriteableRegistry) {
|
||||
return Collections.singletonList(new TransportInterceptor() {
|
||||
@Override
|
||||
public <T extends TransportRequest> TransportRequestHandler<T> interceptHandler(String action,
|
||||
|
|
|
@ -26,15 +26,18 @@ import org.elasticsearch.common.network.NetworkModule;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.node.MockNode;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.elasticsearch.node.NodeValidationException;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
import org.elasticsearch.transport.MockTransportClient;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
|
@ -54,15 +57,15 @@ public class TransportClientIT extends ESIntegTestCase {
|
|||
|
||||
public void testNodeVersionIsUpdated() throws IOException, NodeValidationException {
|
||||
TransportClient client = (TransportClient) internalCluster().client();
|
||||
try (Node node = new Node(Settings.builder()
|
||||
try (Node node = new MockNode(Settings.builder()
|
||||
.put(internalCluster().getDefaultSettings())
|
||||
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
|
||||
.put("node.name", "testNodeVersionIsUpdated")
|
||||
.put("transport.type", "local")
|
||||
.put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
|
||||
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
|
||||
.put(Node.NODE_DATA_SETTING.getKey(), false)
|
||||
.put("cluster.name", "foobar")
|
||||
.build()).start()) {
|
||||
.build(), Collections.singleton(MockTcpTransportPlugin.class)).start()) {
|
||||
TransportAddress transportAddress = node.injector().getInstance(TransportService.class).boundAddress().publishAddress();
|
||||
client.addTransportAddress(transportAddress);
|
||||
// since we force transport clients there has to be one node started that we connect to.
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.elasticsearch.action.admin.cluster.node.liveness.TransportLivenessAct
|
|||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
@ -39,13 +39,16 @@ import org.elasticsearch.transport.TransportService;
|
|||
|
||||
import java.io.Closeable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.hasItem;
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.hamcrest.CoreMatchers.startsWith;
|
||||
|
@ -60,6 +63,9 @@ public class TransportClientNodesServiceTests extends ESTestCase {
|
|||
private final TransportService transportService;
|
||||
private final TransportClientNodesService transportClientNodesService;
|
||||
private final int nodesCount;
|
||||
private TransportAddress livenessAddress = buildNewFakeTransportAddress();
|
||||
public Set<TransportAddress> nodeAddresses = new HashSet<>();
|
||||
|
||||
|
||||
TestIteration() {
|
||||
Settings settings = Settings.builder().put("cluster.name", "test").build();
|
||||
|
@ -98,7 +104,9 @@ public class TransportClientNodesServiceTests extends ESTestCase {
|
|||
new TransportClientNodesService(settings, transportService, threadPool);
|
||||
this.nodesCount = randomIntBetween(1, 10);
|
||||
for (int i = 0; i < nodesCount; i++) {
|
||||
transportClientNodesService.addTransportAddresses(new LocalTransportAddress("node" + i));
|
||||
TransportAddress transportAddress = buildNewFakeTransportAddress();
|
||||
nodeAddresses.add(transportAddress);
|
||||
transportClientNodesService.addTransportAddresses(transportAddress);
|
||||
}
|
||||
transport.endConnectMode();
|
||||
}
|
||||
|
@ -118,7 +126,7 @@ public class TransportClientNodesServiceTests extends ESTestCase {
|
|||
LivenessResponse livenessResponse = new LivenessResponse(clusterName,
|
||||
new DiscoveryNode(node.getName(), node.getId(), node.getEphemeralId(), "liveness-hostname" + node.getId(),
|
||||
"liveness-hostaddress" + node.getId(),
|
||||
new LocalTransportAddress("liveness-address-" + node.getId()), node.getAttributes(), node.getRoles(),
|
||||
livenessAddress, node.getAttributes(), node.getRoles(),
|
||||
node.getVersion()));
|
||||
handler.handleResponse((T)livenessResponse);
|
||||
}
|
||||
|
@ -237,10 +245,8 @@ public class TransportClientNodesServiceTests extends ESTestCase {
|
|||
for (DiscoveryNode discoveryNode : iteration.transportClientNodesService.connectedNodes()) {
|
||||
assertThat(discoveryNode.getHostName(), startsWith("liveness-"));
|
||||
assertThat(discoveryNode.getHostAddress(), startsWith("liveness-"));
|
||||
assertThat(discoveryNode.getAddress(), instanceOf(LocalTransportAddress.class));
|
||||
LocalTransportAddress localTransportAddress = (LocalTransportAddress) discoveryNode.getAddress();
|
||||
//the original listed transport address is kept rather than the one returned from the liveness api
|
||||
assertThat(localTransportAddress.id(), startsWith("node"));
|
||||
assertNotEquals(discoveryNode.getAddress(), iteration.livenessAddress);
|
||||
assertThat(iteration.nodeAddresses, hasItem(discoveryNode.getAddress()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import org.elasticsearch.cluster.node.DiscoveryNodes;
|
|||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.common.UUIDs;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.gateway.GatewayService;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
@ -320,7 +319,7 @@ public class ClusterChangedEventTests extends ESTestCase {
|
|||
|
||||
// Create a new DiscoveryNode
|
||||
private static DiscoveryNode newNode(final String nodeId, Set<DiscoveryNode.Role> roles) {
|
||||
return new DiscoveryNode(nodeId, nodeId, nodeId, "host", "host_address", new LocalTransportAddress("_test_" + nodeId),
|
||||
return new DiscoveryNode(nodeId, nodeId, nodeId, "host", "host_address", buildNewFakeTransportAddress(),
|
||||
Collections.emptyMap(), roles, Version.CURRENT);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ import org.elasticsearch.common.collect.ImmutableOpenMap;
|
|||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.discovery.DiscoverySettings;
|
||||
import org.elasticsearch.gateway.GatewayService;
|
||||
import org.elasticsearch.index.Index;
|
||||
|
@ -74,9 +73,9 @@ import static org.hamcrest.Matchers.is;
|
|||
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 0, numClientNodes = 0)
|
||||
public class ClusterStateDiffIT extends ESIntegTestCase {
|
||||
public void testClusterStateDiffSerialization() throws Exception {
|
||||
DiscoveryNode masterNode = new DiscoveryNode("master", new LocalTransportAddress("master"),
|
||||
DiscoveryNode masterNode = new DiscoveryNode("master", buildNewFakeTransportAddress(),
|
||||
emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNode otherNode = new DiscoveryNode("other", new LocalTransportAddress("other"),
|
||||
DiscoveryNode otherNode = new DiscoveryNode("other", buildNewFakeTransportAddress(),
|
||||
emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNodes discoveryNodes = DiscoveryNodes.builder().add(masterNode).add(otherNode).localNodeId(masterNode.getId()).build();
|
||||
ClusterState clusterState = ClusterState.builder(new ClusterName("test")).nodes(discoveryNodes).build();
|
||||
|
@ -193,14 +192,14 @@ public class ClusterStateDiffIT extends ESIntegTestCase {
|
|||
if (nodeId.startsWith("node-")) {
|
||||
nodes.remove(nodeId);
|
||||
if (randomBoolean()) {
|
||||
nodes.add(new DiscoveryNode(nodeId, new LocalTransportAddress(randomAsciiOfLength(10)), emptyMap(),
|
||||
nodes.add(new DiscoveryNode(nodeId, buildNewFakeTransportAddress(), emptyMap(),
|
||||
emptySet(), randomVersion(random())));
|
||||
}
|
||||
}
|
||||
}
|
||||
int additionalNodeCount = randomIntBetween(1, 20);
|
||||
for (int i = 0; i < additionalNodeCount; i++) {
|
||||
nodes.add(new DiscoveryNode("node-" + randomAsciiOfLength(10), new LocalTransportAddress(randomAsciiOfLength(10)),
|
||||
nodes.add(new DiscoveryNode("node-" + randomAsciiOfLength(10), buildNewFakeTransportAddress(),
|
||||
emptyMap(), emptySet(), randomVersion(random())));
|
||||
}
|
||||
return ClusterState.builder(clusterState).nodes(nodes);
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.elasticsearch.Version;
|
|||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
@ -33,8 +32,8 @@ public class ClusterStateTests extends ESTestCase {
|
|||
|
||||
public void testSupersedes() {
|
||||
final Version version = Version.CURRENT;
|
||||
final DiscoveryNode node1 = new DiscoveryNode("node1", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), version);
|
||||
final DiscoveryNode node2 = new DiscoveryNode("node2", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), version);
|
||||
final DiscoveryNode node1 = new DiscoveryNode("node1", buildNewFakeTransportAddress(), emptyMap(), emptySet(), version);
|
||||
final DiscoveryNode node2 = new DiscoveryNode("node2", buildNewFakeTransportAddress(), emptyMap(), emptySet(), version);
|
||||
final DiscoveryNodes nodes = DiscoveryNodes.builder().add(node1).add(node2).build();
|
||||
ClusterName name = ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY);
|
||||
ClusterState noMaster1 = ClusterState.builder(name).version(randomInt(5)).nodes(nodes).build();
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.elasticsearch.cluster.routing.ShardRoutingHelper;
|
|||
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.index.shard.ShardPath;
|
||||
|
@ -199,11 +198,11 @@ public class DiskUsageTests extends ESTestCase {
|
|||
new FsInfo.Path("/most", "/dev/sda", 100, 90, 80),
|
||||
};
|
||||
List<NodeStats> nodeStats = Arrays.asList(
|
||||
new NodeStats(new DiscoveryNode("node_1", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT), 0,
|
||||
new NodeStats(new DiscoveryNode("node_1", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), 0,
|
||||
null,null,null,null,null,new FsInfo(0, null, node1FSInfo), null,null,null,null,null, null),
|
||||
new NodeStats(new DiscoveryNode("node_2", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT), 0,
|
||||
new NodeStats(new DiscoveryNode("node_2", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), 0,
|
||||
null,null,null,null,null, new FsInfo(0, null, node2FSInfo), null,null,null,null,null, null),
|
||||
new NodeStats(new DiscoveryNode("node_3", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT), 0,
|
||||
new NodeStats(new DiscoveryNode("node_3", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), 0,
|
||||
null,null,null,null,null, new FsInfo(0, null, node3FSInfo), null,null,null,null,null, null)
|
||||
);
|
||||
InternalClusterInfoService.fillDiskUsagePerNode(logger, nodeStats, newLeastAvaiableUsages, newMostAvaiableUsages);
|
||||
|
@ -240,11 +239,11 @@ public class DiskUsageTests extends ESTestCase {
|
|||
new FsInfo.Path("/least", "/dev/sda", 10, -8, 0),
|
||||
};
|
||||
List<NodeStats> nodeStats = Arrays.asList(
|
||||
new NodeStats(new DiscoveryNode("node_1", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT), 0,
|
||||
new NodeStats(new DiscoveryNode("node_1", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), 0,
|
||||
null,null,null,null,null,new FsInfo(0, null, node1FSInfo), null,null,null,null,null, null),
|
||||
new NodeStats(new DiscoveryNode("node_2", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT), 0,
|
||||
new NodeStats(new DiscoveryNode("node_2", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), 0,
|
||||
null,null,null,null,null, new FsInfo(0, null, node2FSInfo), null,null,null,null,null, null),
|
||||
new NodeStats(new DiscoveryNode("node_3", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT), 0,
|
||||
new NodeStats(new DiscoveryNode("node_3", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT), 0,
|
||||
null,null,null,null,null, new FsInfo(0, null, node3FSInfo), null,null,null,null,null, null)
|
||||
);
|
||||
InternalClusterInfoService.fillDiskUsagePerNode(logger, nodeStats, newLeastAvailableUsages, newMostAvailableUsages);
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.discovery.Discovery;
|
||||
import org.elasticsearch.discovery.DiscoveryModule;
|
||||
import org.elasticsearch.discovery.DiscoverySettings;
|
||||
import org.elasticsearch.discovery.zen.ElectMasterService;
|
||||
import org.elasticsearch.discovery.zen.ZenDiscovery;
|
||||
|
@ -63,7 +64,6 @@ import static org.hamcrest.Matchers.not;
|
|||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
||||
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
|
||||
@ESIntegTestCase.SuppressLocalMode
|
||||
@TestLogging("_root:DEBUG,org.elasticsearch.cluster.service:TRACE,org.elasticsearch.discovery.zen:TRACE")
|
||||
public class MinimumMasterNodesIT extends ESIntegTestCase {
|
||||
|
||||
|
@ -74,6 +74,12 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
|
|||
return classes;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
|
||||
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "zen").build();
|
||||
}
|
||||
|
||||
public void testSimpleMinimumMasterNodes() throws Exception {
|
||||
|
||||
Settings settings = Settings.builder()
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.discovery.DiscoveryModule;
|
||||
import org.elasticsearch.discovery.DiscoverySettings;
|
||||
import org.elasticsearch.discovery.MasterNotDiscoveredException;
|
||||
import org.elasticsearch.discovery.zen.ZenDiscovery;
|
||||
|
@ -49,8 +50,14 @@ import static org.hamcrest.Matchers.lessThan;
|
|||
/**
|
||||
*/
|
||||
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
|
||||
@ESIntegTestCase.SuppressLocalMode
|
||||
public class NoMasterNodeIT extends ESIntegTestCase {
|
||||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
|
||||
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "zen").build();
|
||||
}
|
||||
|
||||
public void testNoMasterActions() throws Exception {
|
||||
// note, sometimes, we want to check with the fact that an index gets created, sometimes not...
|
||||
boolean autoCreateIndex = randomBoolean();
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.elasticsearch.common.component.Lifecycle;
|
|||
import org.elasticsearch.common.component.LifecycleListener;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.BoundTransportAddress;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
@ -64,7 +63,7 @@ public class NodeConnectionsServiceTests extends ESTestCase {
|
|||
List<DiscoveryNode> nodes = new ArrayList<>();
|
||||
for (int i = randomIntBetween(20, 50); i > 0; i--) {
|
||||
Set<DiscoveryNode.Role> roles = new HashSet<>(randomSubsetOf(Arrays.asList(DiscoveryNode.Role.values())));
|
||||
nodes.add(new DiscoveryNode("node_" + i, "" + i, LocalTransportAddress.buildUnique(), Collections.emptyMap(),
|
||||
nodes.add(new DiscoveryNode("node_" + i, "" + i, buildNewFakeTransportAddress(), Collections.emptyMap(),
|
||||
roles, Version.CURRENT));
|
||||
}
|
||||
return nodes;
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.cluster;
|
|||
import org.apache.lucene.search.join.ScoreMode;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.discovery.DiscoveryModule;
|
||||
import org.elasticsearch.discovery.MasterNotDiscoveredException;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.node.Node;
|
||||
|
@ -38,8 +39,13 @@ import static org.hamcrest.Matchers.notNullValue;
|
|||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
||||
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
|
||||
@ESIntegTestCase.SuppressLocalMode
|
||||
public class SpecificMasterNodesIT extends ESIntegTestCase {
|
||||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
|
||||
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "zen").build();
|
||||
}
|
||||
protected final Settings.Builder settingsBuilder() {
|
||||
return Settings.builder().put("discovery.type", "zen");
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders;
|
|||
import org.elasticsearch.cluster.routing.allocation.decider.MaxRetryAllocationDecider;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.indices.IndexAlreadyExistsException;
|
||||
import org.elasticsearch.indices.InvalidIndexNameException;
|
||||
|
@ -181,7 +180,7 @@ public class MetaDataCreateIndexServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
private DiscoveryNode newNode(String nodeId) {
|
||||
return new DiscoveryNode(nodeId, LocalTransportAddress.buildUnique(), emptyMap(),
|
||||
return new DiscoveryNode(nodeId, buildNewFakeTransportAddress(), emptyMap(),
|
||||
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(DiscoveryNode.Role.MASTER, DiscoveryNode.Role.DATA))), Version.CURRENT);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,7 @@ package org.elasticsearch.cluster.node;
|
|||
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -46,11 +45,11 @@ import static org.hamcrest.Matchers.equalTo;
|
|||
*/
|
||||
public class DiscoveryNodeFiltersTests extends ESTestCase {
|
||||
|
||||
private static InetSocketTransportAddress localAddress;
|
||||
private static TransportAddress localAddress;
|
||||
|
||||
@BeforeClass
|
||||
public static void createLocalAddress() throws UnknownHostException {
|
||||
localAddress = new InetSocketTransportAddress(InetAddress.getByName("192.1.1.54"), 9999);
|
||||
localAddress = new TransportAddress(InetAddress.getByName("192.1.1.54"), 9999);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -64,11 +63,11 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
|
|||
.build();
|
||||
DiscoveryNodeFilters filters = DiscoveryNodeFilters.buildFromSettings(OR, "xxx.", settings);
|
||||
|
||||
DiscoveryNode node = new DiscoveryNode("name1", "id1", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(),
|
||||
DiscoveryNode node = new DiscoveryNode("name1", "id1", buildNewFakeTransportAddress(), emptyMap(), emptySet(),
|
||||
Version.CURRENT);
|
||||
assertThat(filters.match(node), equalTo(true));
|
||||
|
||||
node = new DiscoveryNode("name2", "id2", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
node = new DiscoveryNode("name2", "id2", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
assertThat(filters.match(node), equalTo(false));
|
||||
}
|
||||
|
||||
|
@ -78,11 +77,11 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
|
|||
.build();
|
||||
DiscoveryNodeFilters filters = DiscoveryNodeFilters.buildFromSettings(OR, "xxx.", settings);
|
||||
|
||||
DiscoveryNode node = new DiscoveryNode("name1", "id1", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(),
|
||||
DiscoveryNode node = new DiscoveryNode("name1", "id1", buildNewFakeTransportAddress(), emptyMap(), emptySet(),
|
||||
Version.CURRENT);
|
||||
assertThat(filters.match(node), equalTo(true));
|
||||
|
||||
node = new DiscoveryNode("name2", "id2", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
node = new DiscoveryNode("name2", "id2", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
assertThat(filters.match(node), equalTo(false));
|
||||
}
|
||||
|
||||
|
@ -94,13 +93,13 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
|
|||
DiscoveryNodeFilters filters = DiscoveryNodeFilters.buildFromSettings(OR, "xxx.", settings);
|
||||
|
||||
final Version version = Version.CURRENT;
|
||||
DiscoveryNode node = new DiscoveryNode("name1", "id1", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), version);
|
||||
DiscoveryNode node = new DiscoveryNode("name1", "id1", buildNewFakeTransportAddress(), emptyMap(), emptySet(), version);
|
||||
assertThat(filters.match(node), equalTo(true));
|
||||
|
||||
node = new DiscoveryNode("name2", "id2", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), version);
|
||||
node = new DiscoveryNode("name2", "id2", buildNewFakeTransportAddress(), emptyMap(), emptySet(), version);
|
||||
assertThat(filters.match(node), equalTo(true));
|
||||
|
||||
node = new DiscoveryNode("name3", "id3", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), version);
|
||||
node = new DiscoveryNode("name3", "id3", buildNewFakeTransportAddress(), emptyMap(), emptySet(), version);
|
||||
assertThat(filters.match(node), equalTo(false));
|
||||
}
|
||||
|
||||
|
@ -114,7 +113,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
|
|||
Map<String, String> attributes = new HashMap<>();
|
||||
attributes.put("tag", "A");
|
||||
attributes.put("group", "B");
|
||||
DiscoveryNode node = new DiscoveryNode("name1", "id1", LocalTransportAddress.buildUnique(),
|
||||
DiscoveryNode node = new DiscoveryNode("name1", "id1", buildNewFakeTransportAddress(),
|
||||
attributes, emptySet(), Version.CURRENT);
|
||||
assertThat(filters.match(node), equalTo(true));
|
||||
|
||||
|
@ -122,7 +121,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
|
|||
attributes.put("tag", "A");
|
||||
attributes.put("group", "B");
|
||||
attributes.put("name", "X");
|
||||
node = new DiscoveryNode("name2", "id2", LocalTransportAddress.buildUnique(),
|
||||
node = new DiscoveryNode("name2", "id2", buildNewFakeTransportAddress(),
|
||||
attributes, emptySet(), Version.CURRENT);
|
||||
assertThat(filters.match(node), equalTo(true));
|
||||
|
||||
|
@ -130,11 +129,11 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
|
|||
attributes.put("tag", "A");
|
||||
attributes.put("group", "F");
|
||||
attributes.put("name", "X");
|
||||
node = new DiscoveryNode("name3", "id3", LocalTransportAddress.buildUnique(),
|
||||
node = new DiscoveryNode("name3", "id3", buildNewFakeTransportAddress(),
|
||||
attributes, emptySet(), Version.CURRENT);
|
||||
assertThat(filters.match(node), equalTo(false));
|
||||
|
||||
node = new DiscoveryNode("name4", "id4", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
node = new DiscoveryNode("name4", "id4", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
assertThat(filters.match(node), equalTo(false));
|
||||
}
|
||||
|
||||
|
@ -144,7 +143,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
|
|||
.build();
|
||||
DiscoveryNodeFilters filters = DiscoveryNodeFilters.buildFromSettings(OR, "xxx.", settings);
|
||||
|
||||
DiscoveryNode node = new DiscoveryNode("name1", "id1", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(),
|
||||
DiscoveryNode node = new DiscoveryNode("name1", "id1", buildNewFakeTransportAddress(), emptyMap(), emptySet(),
|
||||
Version.CURRENT);
|
||||
assertThat(filters.match(node), equalTo(true));
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.elasticsearch.cluster.node;
|
|||
|
||||
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -194,7 +193,7 @@ public class DiscoveryNodesTests extends ESTestCase {
|
|||
}
|
||||
|
||||
private static DiscoveryNode newNode(int nodeId, Map<String, String> attributes, Set<DiscoveryNode.Role> roles) {
|
||||
return new DiscoveryNode("name_" + nodeId, "node_" + nodeId, LocalTransportAddress.buildUnique(), attributes, roles,
|
||||
return new DiscoveryNode("name_" + nodeId, "node_" + nodeId, buildNewFakeTransportAddress(), attributes, roles,
|
||||
Version.CURRENT);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,10 +27,10 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.routing.allocation.command.AllocateEmptyPrimaryAllocationCommand;
|
||||
import org.elasticsearch.cluster.routing.allocation.command.AllocateStalePrimaryAllocationCommand;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenIntMap;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.set.Sets;
|
||||
import org.elasticsearch.discovery.DiscoveryModule;
|
||||
import org.elasticsearch.gateway.GatewayAllocator;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
|
@ -38,7 +38,6 @@ import org.elasticsearch.test.InternalTestCluster;
|
|||
import org.elasticsearch.test.disruption.NetworkDisruption;
|
||||
import org.elasticsearch.test.disruption.NetworkDisruption.NetworkDisconnect;
|
||||
import org.elasticsearch.test.disruption.NetworkDisruption.TwoPartitions;
|
||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
||||
import org.elasticsearch.test.transport.MockTransportService;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -55,7 +54,6 @@ import static org.hamcrest.Matchers.empty;
|
|||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0)
|
||||
@ESIntegTestCase.SuppressLocalMode
|
||||
public class PrimaryAllocationIT extends ESIntegTestCase {
|
||||
|
||||
@Override
|
||||
|
@ -64,6 +62,12 @@ public class PrimaryAllocationIT extends ESIntegTestCase {
|
|||
return Arrays.asList(MockTransportService.TestPlugin.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
|
||||
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "zen").build();
|
||||
}
|
||||
|
||||
private void createStaleReplicaScenario() throws Exception {
|
||||
logger.info("--> starting 3 nodes, 1 master, 2 data");
|
||||
String master = internalCluster().startMasterOnlyNode(Settings.EMPTY);
|
||||
|
@ -115,12 +119,7 @@ public class PrimaryAllocationIT extends ESIntegTestCase {
|
|||
logger.info("--> check that old primary shard does not get promoted to primary again");
|
||||
// kick reroute and wait for all shard states to be fetched
|
||||
client(master).admin().cluster().prepareReroute().get();
|
||||
assertBusy(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
assertThat(internalCluster().getInstance(GatewayAllocator.class, master).getNumberOfInFlightFetch(), equalTo(0));
|
||||
}
|
||||
});
|
||||
assertBusy(() -> assertThat(internalCluster().getInstance(GatewayAllocator.class, master).getNumberOfInFlightFetch(), equalTo(0)));
|
||||
// kick reroute a second time and check that all shards are unassigned
|
||||
assertThat(client(master).admin().cluster().prepareReroute().get().getState().getRoutingNodes().unassigned().size(), equalTo(2));
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@ import org.elasticsearch.cluster.routing.allocation.decider.ReplicaAfterPrimaryA
|
|||
import org.elasticsearch.common.UUIDs;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.util.set.Sets;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.snapshots.Snapshot;
|
||||
|
@ -291,11 +290,11 @@ public class NodeVersionAllocationDeciderTests extends ESAllocationTestCase {
|
|||
public void testRebalanceDoesNotAllocatePrimaryAndReplicasOnDifferentVersionNodes() {
|
||||
ShardId shard1 = new ShardId("test1", "_na_", 0);
|
||||
ShardId shard2 = new ShardId("test2", "_na_", 0);
|
||||
final DiscoveryNode newNode = new DiscoveryNode("newNode", LocalTransportAddress.buildUnique(), emptyMap(),
|
||||
final DiscoveryNode newNode = new DiscoveryNode("newNode", buildNewFakeTransportAddress(), emptyMap(),
|
||||
MASTER_DATA_ROLES, Version.CURRENT);
|
||||
final DiscoveryNode oldNode1 = new DiscoveryNode("oldNode1", LocalTransportAddress.buildUnique(), emptyMap(),
|
||||
final DiscoveryNode oldNode1 = new DiscoveryNode("oldNode1", buildNewFakeTransportAddress(), emptyMap(),
|
||||
MASTER_DATA_ROLES, VersionUtils.getPreviousVersion());
|
||||
final DiscoveryNode oldNode2 = new DiscoveryNode("oldNode2", LocalTransportAddress.buildUnique(), emptyMap(),
|
||||
final DiscoveryNode oldNode2 = new DiscoveryNode("oldNode2", buildNewFakeTransportAddress(), emptyMap(),
|
||||
MASTER_DATA_ROLES, VersionUtils.getPreviousVersion());
|
||||
AllocationId allocationId1P = AllocationId.newInitializing();
|
||||
AllocationId allocationId1R = AllocationId.newInitializing();
|
||||
|
@ -334,11 +333,11 @@ public class NodeVersionAllocationDeciderTests extends ESAllocationTestCase {
|
|||
}
|
||||
|
||||
public void testRestoreDoesNotAllocateSnapshotOnOlderNodes() {
|
||||
final DiscoveryNode newNode = new DiscoveryNode("newNode", LocalTransportAddress.buildUnique(), emptyMap(),
|
||||
final DiscoveryNode newNode = new DiscoveryNode("newNode", buildNewFakeTransportAddress(), emptyMap(),
|
||||
MASTER_DATA_ROLES, Version.CURRENT);
|
||||
final DiscoveryNode oldNode1 = new DiscoveryNode("oldNode1", LocalTransportAddress.buildUnique(), emptyMap(),
|
||||
final DiscoveryNode oldNode1 = new DiscoveryNode("oldNode1", buildNewFakeTransportAddress(), emptyMap(),
|
||||
MASTER_DATA_ROLES, VersionUtils.getPreviousVersion());
|
||||
final DiscoveryNode oldNode2 = new DiscoveryNode("oldNode2", LocalTransportAddress.buildUnique(), emptyMap(),
|
||||
final DiscoveryNode oldNode2 = new DiscoveryNode("oldNode2", buildNewFakeTransportAddress(), emptyMap(),
|
||||
MASTER_DATA_ROLES, VersionUtils.getPreviousVersion());
|
||||
|
||||
int numberOfShards = randomIntBetween(1, 3);
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.elasticsearch.cluster.routing.ShardRoutingState;
|
|||
import org.elasticsearch.cluster.routing.allocation.decider.SameShardAllocationDecider;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
|
@ -63,9 +62,9 @@ public class SameShardRoutingTests extends ESAllocationTestCase {
|
|||
logger.info("--> adding two nodes with the same host");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(
|
||||
DiscoveryNodes.builder()
|
||||
.add(new DiscoveryNode("node1", "node1", "node1", "test1", "test1", LocalTransportAddress.buildUnique(), emptyMap(),
|
||||
.add(new DiscoveryNode("node1", "node1", "node1", "test1", "test1", buildNewFakeTransportAddress(), emptyMap(),
|
||||
MASTER_DATA_ROLES, Version.CURRENT))
|
||||
.add(new DiscoveryNode("node2", "node2", "node2", "test1", "test1", LocalTransportAddress.buildUnique(), emptyMap(),
|
||||
.add(new DiscoveryNode("node2", "node2", "node2", "test1", "test1", buildNewFakeTransportAddress(), emptyMap(),
|
||||
MASTER_DATA_ROLES, Version.CURRENT))).build();
|
||||
clusterState = strategy.reroute(clusterState, "reroute");
|
||||
|
||||
|
@ -79,7 +78,7 @@ public class SameShardRoutingTests extends ESAllocationTestCase {
|
|||
|
||||
logger.info("--> add another node, with a different host, replicas will be allocating");
|
||||
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.add(new DiscoveryNode("node3", "node3", "node3", "test2", "test2", LocalTransportAddress.buildUnique(), emptyMap(),
|
||||
.add(new DiscoveryNode("node3", "node3", "node3", "test2", "test2", buildNewFakeTransportAddress(), emptyMap(),
|
||||
MASTER_DATA_ROLES, Version.CURRENT))).build();
|
||||
clusterState = strategy.reroute(clusterState, "reroute");
|
||||
|
||||
|
|
|
@ -49,7 +49,6 @@ import org.elasticsearch.cluster.routing.allocation.command.MoveAllocationComman
|
|||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.test.gateway.TestGatewayAllocator;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -823,9 +822,9 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|||
.addAsNew(metaData.index("foo"))
|
||||
.build();
|
||||
|
||||
DiscoveryNode discoveryNode1 = new DiscoveryNode("node1", new LocalTransportAddress("1"), emptyMap(),
|
||||
DiscoveryNode discoveryNode1 = new DiscoveryNode("node1", buildNewFakeTransportAddress(), emptyMap(),
|
||||
MASTER_DATA_ROLES, Version.CURRENT);
|
||||
DiscoveryNode discoveryNode2 = new DiscoveryNode("node2", new LocalTransportAddress("2"), emptyMap(),
|
||||
DiscoveryNode discoveryNode2 = new DiscoveryNode("node2", buildNewFakeTransportAddress(), emptyMap(),
|
||||
MASTER_DATA_ROLES, Version.CURRENT);
|
||||
DiscoveryNodes discoveryNodes = DiscoveryNodes.builder().add(discoveryNode1).add(discoveryNode2).build();
|
||||
|
||||
|
@ -942,9 +941,9 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|||
.build();
|
||||
|
||||
logger.info("--> adding one master node, one data node");
|
||||
DiscoveryNode discoveryNode1 = new DiscoveryNode("", "node1", new LocalTransportAddress("1"), emptyMap(),
|
||||
DiscoveryNode discoveryNode1 = new DiscoveryNode("", "node1", buildNewFakeTransportAddress(), emptyMap(),
|
||||
singleton(DiscoveryNode.Role.MASTER), Version.CURRENT);
|
||||
DiscoveryNode discoveryNode2 = new DiscoveryNode("", "node2", new LocalTransportAddress("2"), emptyMap(),
|
||||
DiscoveryNode discoveryNode2 = new DiscoveryNode("", "node2", buildNewFakeTransportAddress(), emptyMap(),
|
||||
singleton(DiscoveryNode.Role.DATA), Version.CURRENT);
|
||||
|
||||
DiscoveryNodes discoveryNodes = DiscoveryNodes.builder().add(discoveryNode1).add(discoveryNode2).build();
|
||||
|
@ -1010,7 +1009,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
|
|||
|
||||
// Add another datanode, it should relocate.
|
||||
logger.info("--> adding node3");
|
||||
DiscoveryNode discoveryNode3 = new DiscoveryNode("", "node3", new LocalTransportAddress("3"), emptyMap(),
|
||||
DiscoveryNode discoveryNode3 = new DiscoveryNode("", "node3", buildNewFakeTransportAddress(), emptyMap(),
|
||||
singleton(DiscoveryNode.Role.DATA), Version.CURRENT);
|
||||
ClusterState updateClusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes())
|
||||
.add(discoveryNode3)).build();
|
||||
|
|
|
@ -43,7 +43,6 @@ import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
|
|||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
|
||||
|
@ -70,9 +69,9 @@ public class DiskThresholdDeciderUnitTests extends ESAllocationTestCase {
|
|||
final Index index = metaData.index("test").getIndex();
|
||||
|
||||
ShardRouting test_0 = ShardRouting.newUnassigned(new ShardId(index, 0), true, StoreRecoverySource.EMPTY_STORE_INSTANCE, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "foo"));
|
||||
DiscoveryNode node_0 = new DiscoveryNode("node_0", LocalTransportAddress.buildUnique(), Collections.emptyMap(),
|
||||
DiscoveryNode node_0 = new DiscoveryNode("node_0", buildNewFakeTransportAddress(), Collections.emptyMap(),
|
||||
new HashSet<>(Arrays.asList(DiscoveryNode.Role.values())), Version.CURRENT);
|
||||
DiscoveryNode node_1 = new DiscoveryNode("node_1", LocalTransportAddress.buildUnique(), Collections.emptyMap(),
|
||||
DiscoveryNode node_1 = new DiscoveryNode("node_1", buildNewFakeTransportAddress(), Collections.emptyMap(),
|
||||
new HashSet<>(Arrays.asList(DiscoveryNode.Role.values())), Version.CURRENT);
|
||||
|
||||
RoutingTable routingTable = RoutingTable.builder()
|
||||
|
@ -108,9 +107,9 @@ public class DiskThresholdDeciderUnitTests extends ESAllocationTestCase {
|
|||
DiskThresholdDecider decider = new DiskThresholdDecider(Settings.EMPTY, nss);
|
||||
ImmutableOpenMap.Builder<ShardRouting, String> shardRoutingMap = ImmutableOpenMap.builder();
|
||||
|
||||
DiscoveryNode node_0 = new DiscoveryNode("node_0", LocalTransportAddress.buildUnique(), Collections.emptyMap(),
|
||||
DiscoveryNode node_0 = new DiscoveryNode("node_0", buildNewFakeTransportAddress(), Collections.emptyMap(),
|
||||
new HashSet<>(Arrays.asList(DiscoveryNode.Role.values())), Version.CURRENT);
|
||||
DiscoveryNode node_1 = new DiscoveryNode("node_1", LocalTransportAddress.buildUnique(), Collections.emptyMap(),
|
||||
DiscoveryNode node_1 = new DiscoveryNode("node_1", buildNewFakeTransportAddress(), Collections.emptyMap(),
|
||||
new HashSet<>(Arrays.asList(DiscoveryNode.Role.values())), Version.CURRENT);
|
||||
|
||||
MetaData metaData = MetaData.builder()
|
||||
|
@ -224,7 +223,7 @@ public class DiskThresholdDeciderUnitTests extends ESAllocationTestCase {
|
|||
assertEquals(100L, DiskThresholdDecider.getExpectedShardSize(test_1, allocation, 0));
|
||||
assertEquals(10L, DiskThresholdDecider.getExpectedShardSize(test_0, allocation, 0));
|
||||
|
||||
RoutingNode node = new RoutingNode("node1", new DiscoveryNode("node1", new LocalTransportAddress("test"),
|
||||
RoutingNode node = new RoutingNode("node1", new DiscoveryNode("node1", buildNewFakeTransportAddress(),
|
||||
emptyMap(), emptySet(), Version.CURRENT), test_0, test_1.getTargetRelocatingShard(), test_2);
|
||||
assertEquals(100L, DiskThresholdDecider.sizeOfRelocatingShards(node, allocation, false, "/dev/null"));
|
||||
assertEquals(90L, DiskThresholdDecider.sizeOfRelocatingShards(node, allocation, true, "/dev/null"));
|
||||
|
@ -242,7 +241,7 @@ public class DiskThresholdDeciderUnitTests extends ESAllocationTestCase {
|
|||
other_0 = ShardRoutingHelper.moveToStarted(other_0);
|
||||
other_0 = ShardRoutingHelper.relocate(other_0, "node1");
|
||||
|
||||
node = new RoutingNode("node1", new DiscoveryNode("node1", new LocalTransportAddress("test"),
|
||||
node = new RoutingNode("node1", new DiscoveryNode("node1", buildNewFakeTransportAddress(),
|
||||
emptyMap(), emptySet(), Version.CURRENT), test_0, test_1.getTargetRelocatingShard(), test_2, other_0.getTargetRelocatingShard());
|
||||
if (other_0.primary()) {
|
||||
assertEquals(10100L, DiskThresholdDecider.sizeOfRelocatingShards(node, allocation, false, "/dev/null"));
|
||||
|
|
|
@ -34,10 +34,8 @@ import org.elasticsearch.cluster.ESAllocationTestCase;
|
|||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ClusterSerializationTests extends ESAllocationTestCase {
|
||||
|
||||
public void testClusterStateSerialization() throws Exception {
|
||||
MetaData metaData = MetaData.builder()
|
||||
.put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(10).numberOfReplicas(1))
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.elasticsearch.cluster.node.DiscoveryNodes;
|
|||
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||
import org.elasticsearch.cluster.routing.allocation.AllocationService;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.cluster.ESAllocationTestCase;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
@ -50,7 +49,7 @@ public class ClusterStateToStringTests extends ESAllocationTestCase {
|
|||
.addAsNew(metaData.index("test_idx"))
|
||||
.build();
|
||||
|
||||
DiscoveryNodes nodes = DiscoveryNodes.builder().add(new DiscoveryNode("node_foo", LocalTransportAddress.buildUnique(),
|
||||
DiscoveryNodes nodes = DiscoveryNodes.builder().add(new DiscoveryNode("node_foo", buildNewFakeTransportAddress(),
|
||||
emptyMap(), emptySet(), Version.CURRENT)).localNodeId("node_foo").masterNodeId("node_foo").build();
|
||||
|
||||
ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).nodes(nodes)
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.elasticsearch.common.inject.Inject;
|
|||
import org.elasticsearch.common.inject.Singleton;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.discovery.DiscoveryModule;
|
||||
import org.elasticsearch.discovery.zen.ZenDiscovery;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
|
@ -60,7 +61,6 @@ import static org.hamcrest.Matchers.is;
|
|||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
|
||||
@ESIntegTestCase.SuppressLocalMode
|
||||
public class ClusterServiceIT extends ESIntegTestCase {
|
||||
|
||||
@Override
|
||||
|
@ -68,6 +68,12 @@ public class ClusterServiceIT extends ESIntegTestCase {
|
|||
return Arrays.asList(TestPlugin.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
|
||||
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "zen").build();
|
||||
}
|
||||
|
||||
public void testAckedUpdateTask() throws Exception {
|
||||
Settings settings = Settings.builder()
|
||||
.put("discovery.type", "local")
|
||||
|
|
|
@ -40,7 +40,6 @@ import org.elasticsearch.common.lease.Releasable;
|
|||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.MockLogAppender;
|
||||
|
@ -116,7 +115,7 @@ public class ClusterServiceTests extends ESTestCase {
|
|||
TimedClusterService timedClusterService = new TimedClusterService(Settings.builder().put("cluster.name",
|
||||
"ClusterServiceTests").build(), new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS),
|
||||
threadPool);
|
||||
timedClusterService.setLocalNode(new DiscoveryNode("node1", LocalTransportAddress.buildUnique(), emptyMap(),
|
||||
timedClusterService.setLocalNode(new DiscoveryNode("node1", buildNewFakeTransportAddress(), emptyMap(),
|
||||
emptySet(), Version.CURRENT));
|
||||
timedClusterService.setNodeConnectionsService(new NodeConnectionsService(Settings.EMPTY, null, null) {
|
||||
@Override
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.elasticsearch.plugins.NetworkPlugin;
|
|||
import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.cat.AbstractCatAction;
|
||||
import org.elasticsearch.test.transport.AssertingLocalTransport;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.Transport;
|
||||
import org.elasticsearch.transport.TransportInterceptor;
|
||||
|
@ -51,12 +50,6 @@ import java.util.function.Supplier;
|
|||
|
||||
public class NetworkModuleTests extends ModuleTestCase {
|
||||
|
||||
static class FakeTransport extends AssertingLocalTransport {
|
||||
public FakeTransport() {
|
||||
super(null, null, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
static class FakeHttpTransport extends AbstractLifecycleComponent implements HttpServerTransport {
|
||||
public FakeHttpTransport() {
|
||||
super(null);
|
||||
|
@ -110,7 +103,7 @@ public class NetworkModuleTests extends ModuleTestCase {
|
|||
Settings settings = Settings.builder().put(NetworkModule.TRANSPORT_TYPE_KEY, "custom")
|
||||
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
|
||||
.build();
|
||||
Supplier<Transport> custom = FakeTransport::new;
|
||||
Supplier<Transport> custom = () -> null; // content doesn't matter we check reference equality
|
||||
NetworkPlugin plugin = new NetworkPlugin() {
|
||||
@Override
|
||||
public Map<String, Supplier<Transport>> getTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays,
|
||||
|
@ -166,7 +159,7 @@ public class NetworkModuleTests extends ModuleTestCase {
|
|||
.put(NetworkModule.HTTP_DEFAULT_TYPE_SETTING.getKey(), "default_custom")
|
||||
.put(NetworkModule.TRANSPORT_DEFAULT_TYPE_SETTING.getKey(), "local")
|
||||
.put(NetworkModule.TRANSPORT_TYPE_KEY, "default_custom").build();
|
||||
Supplier<Transport> customTransport = FakeTransport::new;
|
||||
Supplier<Transport> customTransport = () -> null; // content doesn't matter we check reference equality
|
||||
Supplier<HttpServerTransport> custom = FakeHttpTransport::new;
|
||||
Supplier<HttpServerTransport> def = FakeHttpTransport::new;
|
||||
NetworkModule module = newNetworkModule(settings, false, new NetworkPlugin() {
|
||||
|
@ -200,7 +193,7 @@ public class NetworkModuleTests extends ModuleTestCase {
|
|||
.put(NetworkModule.TRANSPORT_DEFAULT_TYPE_SETTING.getKey(), "default_custom").build();
|
||||
Supplier<HttpServerTransport> custom = FakeHttpTransport::new;
|
||||
Supplier<HttpServerTransport> def = FakeHttpTransport::new;
|
||||
Supplier<Transport> customTransport = FakeTransport::new;
|
||||
Supplier<Transport> customTransport = () -> null;
|
||||
NetworkModule module = newNetworkModule(settings, false, new NetworkPlugin() {
|
||||
@Override
|
||||
public Map<String, Supplier<Transport>> getTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays,
|
||||
|
@ -236,7 +229,7 @@ public class NetworkModuleTests extends ModuleTestCase {
|
|||
};
|
||||
NetworkModule module = newNetworkModule(settings, false, new NetworkPlugin() {
|
||||
@Override
|
||||
public List<TransportInterceptor> getTransportInterceptors() {
|
||||
public List<TransportInterceptor> getTransportInterceptors(NamedWriteableRegistry namedWriteableRegistry) {
|
||||
return Collections.singletonList(interceptor);
|
||||
}
|
||||
});
|
||||
|
@ -249,7 +242,7 @@ public class NetworkModuleTests extends ModuleTestCase {
|
|||
NullPointerException nullPointerException = expectThrows(NullPointerException.class, () -> {
|
||||
newNetworkModule(settings, false, new NetworkPlugin() {
|
||||
@Override
|
||||
public List<TransportInterceptor> getTransportInterceptors() {
|
||||
public List<TransportInterceptor> getTransportInterceptors(NamedWriteableRegistry namedWriteableRegistry) {
|
||||
return Collections.singletonList(null);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.common.transport;
|
||||
|
||||
import org.elasticsearch.common.io.stream.ByteBufferStreamInput;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
@ -40,12 +39,12 @@ public class BoundTransportAddressTests extends ESTestCase {
|
|||
|
||||
public void testSerialization() throws Exception {
|
||||
InetAddress[] inetAddresses = InetAddress.getAllByName("0.0.0.0");
|
||||
List<InetSocketTransportAddress> transportAddressList = new ArrayList<>();
|
||||
List<TransportAddress> transportAddressList = new ArrayList<>();
|
||||
for (InetAddress address : inetAddresses) {
|
||||
transportAddressList.add(new InetSocketTransportAddress(address, randomIntBetween(9200, 9299)));
|
||||
transportAddressList.add(new TransportAddress(address, randomIntBetween(9200, 9299)));
|
||||
}
|
||||
final BoundTransportAddress transportAddress =
|
||||
new BoundTransportAddress(transportAddressList.toArray(new InetSocketTransportAddress[0]), transportAddressList.get(0));
|
||||
new BoundTransportAddress(transportAddressList.toArray(new TransportAddress[0]), transportAddressList.get(0));
|
||||
assertThat(transportAddress.boundAddresses().length, equalTo(transportAddressList.size()));
|
||||
|
||||
// serialize
|
||||
|
@ -75,7 +74,7 @@ public class BoundTransportAddressTests extends ESTestCase {
|
|||
public void testBadBoundAddressArray() {
|
||||
try {
|
||||
TransportAddress[] badArray = randomBoolean() ? null : new TransportAddress[0];
|
||||
new BoundTransportAddress(badArray, new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), 80));
|
||||
new BoundTransportAddress(badArray, new TransportAddress(InetAddress.getLoopbackAddress(), 80));
|
||||
fail("expected an exception to be thrown due to no bound address");
|
||||
} catch (IllegalArgumentException e) {
|
||||
//expected
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.elasticsearch.discovery;
|
|||
import org.apache.logging.log4j.Logger;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
@ -77,7 +76,7 @@ public class BlockingClusterStatePublishResponseHandlerTests extends ESTestCase
|
|||
int nodeCount = scaledRandomIntBetween(10, 20);
|
||||
DiscoveryNode[] allNodes = new DiscoveryNode[nodeCount];
|
||||
for (int i = 0; i < nodeCount; i++) {
|
||||
DiscoveryNode node = new DiscoveryNode("node_" + i, LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNode node = new DiscoveryNode("node_" + i, buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
allNodes[i] = node;
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,6 @@ import static org.hamcrest.Matchers.not;
|
|||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
||||
@ClusterScope(scope = Scope.TEST, numDataNodes = 0, transportClientRatio = 0)
|
||||
@ESIntegTestCase.SuppressLocalMode
|
||||
@TestLogging("_root:DEBUG,org.elasticsearch.cluster.service:TRACE")
|
||||
public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
|
||||
|
||||
|
|
|
@ -29,9 +29,11 @@ import org.elasticsearch.cluster.service.ClusterService;
|
|||
import org.elasticsearch.common.breaker.CircuitBreaker;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.network.NetworkService;
|
||||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
import org.elasticsearch.discovery.zen.fd.FaultDetection;
|
||||
import org.elasticsearch.discovery.zen.fd.MasterFaultDetection;
|
||||
import org.elasticsearch.discovery.zen.fd.NodesFaultDetection;
|
||||
|
@ -41,10 +43,10 @@ import org.elasticsearch.test.ESTestCase;
|
|||
import org.elasticsearch.test.transport.MockTransportService;
|
||||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.MockTcpTransport;
|
||||
import org.elasticsearch.transport.TransportConnectionListener;
|
||||
import org.elasticsearch.transport.TransportRequestOptions;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.transport.local.LocalTransport;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.After;
|
||||
|
@ -141,12 +143,8 @@ public class ZenFaultDetectionTests extends ESTestCase {
|
|||
// trace zenfd actions but keep the default otherwise
|
||||
.put(TransportService.TRACE_LOG_EXCLUDE_SETTING.getKey(), singleton(TransportLivenessAction.NAME))
|
||||
.build(),
|
||||
new LocalTransport(settings, threadPool, namedWriteableRegistry, circuitBreakerService) {
|
||||
@Override
|
||||
protected Version getVersion() {
|
||||
return version;
|
||||
}
|
||||
},
|
||||
new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE, circuitBreakerService,
|
||||
namedWriteableRegistry, new NetworkService(settings, Collections.emptyList()), version),
|
||||
threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR);
|
||||
transportService.start();
|
||||
transportService.acceptIncomingRequests();
|
||||
|
|
|
@ -35,7 +35,6 @@ import java.util.concurrent.ExecutionException;
|
|||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
|
||||
@ESIntegTestCase.SuppressLocalMode
|
||||
public class ZenUnicastDiscoveryIT extends ESIntegTestCase {
|
||||
|
||||
private ClusterDiscoveryConfiguration discoveryConfig;
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.elasticsearch.discovery.zen;
|
|||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.discovery.zen.ElectMasterService.MasterCandidate;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
|
@ -50,7 +49,7 @@ public class ElectMasterServiceTests extends ESTestCase {
|
|||
if (randomBoolean()) {
|
||||
roles.add(DiscoveryNode.Role.MASTER);
|
||||
}
|
||||
DiscoveryNode node = new DiscoveryNode("n_" + i, "n_" + i, LocalTransportAddress.buildUnique(), Collections.emptyMap(),
|
||||
DiscoveryNode node = new DiscoveryNode("n_" + i, "n_" + i, buildNewFakeTransportAddress(), Collections.emptyMap(),
|
||||
roles, Version.CURRENT);
|
||||
nodes.add(node);
|
||||
}
|
||||
|
@ -65,7 +64,7 @@ public class ElectMasterServiceTests extends ESTestCase {
|
|||
for (int i = 0; i < count; i++) {
|
||||
Set<DiscoveryNode.Role> roles = new HashSet<>();
|
||||
roles.add(DiscoveryNode.Role.MASTER);
|
||||
DiscoveryNode node = new DiscoveryNode("n_" + i, "n_" + i, LocalTransportAddress.buildUnique(), Collections.emptyMap(),
|
||||
DiscoveryNode node = new DiscoveryNode("n_" + i, "n_" + i, buildNewFakeTransportAddress(), Collections.emptyMap(),
|
||||
roles, Version.CURRENT);
|
||||
candidates.add(new MasterCandidate(node, randomBoolean() ? MasterCandidate.UNRECOVERED_CLUSTER_VERSION : randomPositiveLong()));
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.elasticsearch.cluster.routing.UnassignedInfo;
|
|||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
||||
import org.elasticsearch.common.util.concurrent.BaseFuture;
|
||||
|
@ -427,7 +426,7 @@ public class NodeJoinControllerTests extends ESTestCase {
|
|||
public void testNewClusterStateOnExistingNodeJoin() throws InterruptedException, ExecutionException {
|
||||
ClusterState state = clusterService.state();
|
||||
final DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(state.nodes());
|
||||
final DiscoveryNode other_node = new DiscoveryNode("other_node", LocalTransportAddress.buildUnique(),
|
||||
final DiscoveryNode other_node = new DiscoveryNode("other_node", buildNewFakeTransportAddress(),
|
||||
emptyMap(), emptySet(), Version.CURRENT);
|
||||
nodesBuilder.add(other_node);
|
||||
setState(clusterService, ClusterState.builder(state).nodes(nodesBuilder));
|
||||
|
@ -557,7 +556,7 @@ public class NodeJoinControllerTests extends ESTestCase {
|
|||
final DiscoveryNode other_node = new DiscoveryNode(
|
||||
randomBoolean() ? existing.getName() : "other_name",
|
||||
existing.getId(),
|
||||
randomBoolean() ? existing.getAddress() : LocalTransportAddress.buildUnique(),
|
||||
randomBoolean() ? existing.getAddress() : buildNewFakeTransportAddress(),
|
||||
randomBoolean() ? existing.getAttributes() : Collections.singletonMap("attr", "other"),
|
||||
randomBoolean() ? existing.getRoles() : new HashSet<>(randomSubsetOf(Arrays.asList(DiscoveryNode.Role.values()))),
|
||||
randomBoolean() ? existing.getVersion() : VersionUtils.randomVersion(random()));
|
||||
|
@ -585,7 +584,7 @@ public class NodeJoinControllerTests extends ESTestCase {
|
|||
*/
|
||||
public void testElectionBasedOnConflictingNodes() throws InterruptedException, ExecutionException {
|
||||
final DiscoveryNode masterNode = clusterService.localNode();
|
||||
final DiscoveryNode otherNode = new DiscoveryNode("other_node", LocalTransportAddress.buildUnique(), emptyMap(),
|
||||
final DiscoveryNode otherNode = new DiscoveryNode("other_node", buildNewFakeTransportAddress(), emptyMap(),
|
||||
EnumSet.allOf(DiscoveryNode.Role.class), Version.CURRENT);
|
||||
// simulate master going down with stale nodes in it's cluster state (for example when min master nodes is set to 2)
|
||||
// also add some shards to that node
|
||||
|
@ -629,7 +628,7 @@ public class NodeJoinControllerTests extends ESTestCase {
|
|||
setState(clusterService, stateBuilder.build());
|
||||
|
||||
final DiscoveryNode restartedNode = new DiscoveryNode(otherNode.getId(),
|
||||
randomBoolean() ? otherNode.getAddress() : LocalTransportAddress.buildUnique(), otherNode.getAttributes(),
|
||||
randomBoolean() ? otherNode.getAddress() : buildNewFakeTransportAddress(), otherNode.getAttributes(),
|
||||
otherNode.getRoles(), Version.CURRENT);
|
||||
|
||||
nodeJoinController.startElectionContext();
|
||||
|
@ -669,7 +668,7 @@ public class NodeJoinControllerTests extends ESTestCase {
|
|||
ClusterState state = clusterService.state();
|
||||
final DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(state.nodes());
|
||||
for (int i = 0;i< count;i++) {
|
||||
final DiscoveryNode node = new DiscoveryNode("node_" + state.nodes().getSize() + i, LocalTransportAddress.buildUnique(),
|
||||
final DiscoveryNode node = new DiscoveryNode("node_" + state.nodes().getSize() + i, buildNewFakeTransportAddress(),
|
||||
emptyMap(), new HashSet<>(randomSubsetOf(Arrays.asList(DiscoveryNode.Role.values()))), Version.CURRENT);
|
||||
nodesBuilder.add(node);
|
||||
}
|
||||
|
@ -752,6 +751,6 @@ public class NodeJoinControllerTests extends ESTestCase {
|
|||
roles.add(DiscoveryNode.Role.MASTER);
|
||||
}
|
||||
final String prefix = master ? "master_" : "data_";
|
||||
return new DiscoveryNode(prefix + i, i + "", new LocalTransportAddress("test_" + i), emptyMap(), roles, Version.CURRENT);
|
||||
return new DiscoveryNode(prefix + i, i + "", buildNewFakeTransportAddress(), emptyMap(), roles, Version.CURRENT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.elasticsearch.cluster.ClusterStateTaskExecutor;
|
|||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.allocation.AllocationService;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -177,7 +176,7 @@ public class NodeRemovalClusterStateTaskExecutorTests extends ESTestCase {
|
|||
}
|
||||
|
||||
private DiscoveryNode node(final int id) {
|
||||
return new DiscoveryNode(Integer.toString(id), LocalTransportAddress.buildUnique(), Version.CURRENT);
|
||||
return new DiscoveryNode(Integer.toString(id), buildNewFakeTransportAddress(), Version.CURRENT);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,11 +34,11 @@ import org.elasticsearch.cluster.service.ClusterService;
|
|||
import org.elasticsearch.common.Priority;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.discovery.Discovery;
|
||||
import org.elasticsearch.discovery.DiscoveryModule;
|
||||
import org.elasticsearch.discovery.DiscoveryStats;
|
||||
import org.elasticsearch.discovery.zen.fd.FaultDetection;
|
||||
import org.elasticsearch.discovery.zen.membership.MembershipAction;
|
||||
|
@ -75,12 +75,17 @@ import static org.hamcrest.Matchers.not;
|
|||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, numClientNodes = 0)
|
||||
@ESIntegTestCase.SuppressLocalMode
|
||||
@TestLogging("_root:DEBUG")
|
||||
public class ZenDiscoveryIT extends ESIntegTestCase {
|
||||
|
||||
private Version previousMajorVersion;
|
||||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
|
||||
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "zen").build();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void computePrevMajorVersion() {
|
||||
Version previousMajor;
|
||||
|
@ -204,7 +209,7 @@ public class ZenDiscoveryIT extends ESIntegTestCase {
|
|||
assert node != null;
|
||||
|
||||
DiscoveryNodes.Builder nodes = DiscoveryNodes.builder(state.nodes())
|
||||
.add(new DiscoveryNode("abc", new LocalTransportAddress("abc"), emptyMap(),
|
||||
.add(new DiscoveryNode("abc", buildNewFakeTransportAddress(), emptyMap(),
|
||||
emptySet(), Version.CURRENT)).masterNodeId("abc");
|
||||
ClusterState.Builder builder = ClusterState.builder(state);
|
||||
builder.nodes(nodes);
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.elasticsearch.cluster.node.DiscoveryNodes;
|
|||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.discovery.Discovery;
|
||||
import org.elasticsearch.discovery.zen.ping.ZenPing;
|
||||
import org.elasticsearch.discovery.zen.ping.ZenPingService;
|
||||
|
@ -67,9 +66,9 @@ public class ZenDiscoveryUnitTests extends ESTestCase {
|
|||
ClusterName clusterName = new ClusterName("abc");
|
||||
|
||||
DiscoveryNodes.Builder currentNodes = DiscoveryNodes.builder();
|
||||
currentNodes.masterNodeId("a").add(new DiscoveryNode("a", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
||||
currentNodes.masterNodeId("a").add(new DiscoveryNode("a", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||
DiscoveryNodes.Builder newNodes = DiscoveryNodes.builder();
|
||||
newNodes.masterNodeId("a").add(new DiscoveryNode("a", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
||||
newNodes.masterNodeId("a").add(new DiscoveryNode("a", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||
|
||||
ClusterState.Builder currentState = ClusterState.builder(clusterName);
|
||||
currentState.nodes(currentNodes);
|
||||
|
@ -87,7 +86,7 @@ public class ZenDiscoveryUnitTests extends ESTestCase {
|
|||
assertFalse("should not ignore, because new state's version is higher to current state's version", shouldIgnoreOrRejectNewClusterState(logger, currentState.build(), newState.build()));
|
||||
|
||||
currentNodes = DiscoveryNodes.builder();
|
||||
currentNodes.masterNodeId("b").add(new DiscoveryNode("b", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT));
|
||||
currentNodes.masterNodeId("b").add(new DiscoveryNode("b", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT));
|
||||
;
|
||||
// version isn't taken into account, so randomize it to ensure this.
|
||||
if (randomBoolean()) {
|
||||
|
@ -125,7 +124,7 @@ public class ZenDiscoveryUnitTests extends ESTestCase {
|
|||
ArrayList<DiscoveryNode> allNodes = new ArrayList<>();
|
||||
for (int i = randomIntBetween(10, 20); i >= 0; i--) {
|
||||
Set<Role> roles = new HashSet<>(randomSubsetOf(Arrays.asList(Role.values())));
|
||||
DiscoveryNode node = new DiscoveryNode("node_" + i, "id_" + i, LocalTransportAddress.buildUnique(), Collections.emptyMap(),
|
||||
DiscoveryNode node = new DiscoveryNode("node_" + i, "id_" + i, buildNewFakeTransportAddress(), Collections.emptyMap(),
|
||||
roles, Version.CURRENT);
|
||||
responses.add(new ZenPing.PingResponse(node, randomBoolean() ? null : node, new ClusterName("test"), randomLong()));
|
||||
allNodes.add(node);
|
||||
|
@ -155,7 +154,7 @@ public class ZenDiscoveryUnitTests extends ESTestCase {
|
|||
try {
|
||||
Set<DiscoveryNode> expectedFDNodes = null;
|
||||
|
||||
final MockTransportService masterTransport = MockTransportService.local(settings, Version.CURRENT, threadPool);
|
||||
final MockTransportService masterTransport = MockTransportService.createNewService(settings, Version.CURRENT, threadPool);
|
||||
masterTransport.start();
|
||||
DiscoveryNode masterNode = new DiscoveryNode("master", masterTransport.boundAddress().publishAddress(), Version.CURRENT);
|
||||
toClose.add(masterTransport);
|
||||
|
@ -171,7 +170,7 @@ public class ZenDiscoveryUnitTests extends ESTestCase {
|
|||
toClose.add(masterZen);
|
||||
masterTransport.acceptIncomingRequests();
|
||||
|
||||
final MockTransportService otherTransport = MockTransportService.local(settings, Version.CURRENT, threadPool);
|
||||
final MockTransportService otherTransport = MockTransportService.createNewService(settings, Version.CURRENT, threadPool);
|
||||
otherTransport.start();
|
||||
toClose.add(otherTransport);
|
||||
DiscoveryNode otherNode = new DiscoveryNode("other", otherTransport.boundAddress().publishAddress(), Version.CURRENT);
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.elasticsearch.Version;
|
|||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.discovery.zen.ping.ZenPing;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
|
@ -43,7 +42,7 @@ public class ZenPingTests extends ESTestCase {
|
|||
long clusterStateVersionPerNode[] = new long[nodes.length];
|
||||
ArrayList<ZenPing.PingResponse> pings = new ArrayList<>();
|
||||
for (int i = 0; i < nodes.length; i++) {
|
||||
nodes[i] = new DiscoveryNode("" + i, LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
nodes[i] = new DiscoveryNode("" + i, buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
}
|
||||
|
||||
for (int pingCount = scaledRandomIntBetween(10, nodes.length * 10); pingCount > 0; pingCount--) {
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
|||
import org.elasticsearch.common.network.NetworkAddress;
|
||||
import org.elasticsearch.common.network.NetworkService;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
|
@ -229,16 +228,16 @@ public class UnicastZenPingTests extends ESTestCase {
|
|||
final DiscoveryNode node = new DiscoveryNode(nodeId, transportService.boundAddress().publishAddress(), emptyMap(), emptySet(),
|
||||
version);
|
||||
transportService.setLocalNode(node);
|
||||
return new NetworkHandle((InetSocketTransportAddress)transport.boundAddress().publishAddress(), transportService, node, counters);
|
||||
return new NetworkHandle((TransportAddress)transport.boundAddress().publishAddress(), transportService, node, counters);
|
||||
}
|
||||
|
||||
private static class NetworkHandle {
|
||||
public final InetSocketTransportAddress address;
|
||||
public final TransportAddress address;
|
||||
public final TransportService transportService;
|
||||
public final DiscoveryNode node;
|
||||
public final ConcurrentMap<TransportAddress, AtomicInteger> counters;
|
||||
|
||||
public NetworkHandle(InetSocketTransportAddress address, TransportService transportService, DiscoveryNode discoveryNode,
|
||||
public NetworkHandle(TransportAddress address, TransportService transportService, DiscoveryNode discoveryNode,
|
||||
ConcurrentMap<TransportAddress, AtomicInteger> counters) {
|
||||
this.address = address;
|
||||
this.transportService = transportService;
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.discovery.zen.publish.PendingClusterStatesQueue.ClusterStateContext;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
|
@ -237,7 +236,7 @@ public class PendingClusterStatesQueueTests extends ESTestCase {
|
|||
ClusterState state = lastClusterStatePerMaster[masterIndex];
|
||||
if (state == null) {
|
||||
state = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).nodes(DiscoveryNodes.builder()
|
||||
.add(new DiscoveryNode(masters[masterIndex], LocalTransportAddress.buildUnique(),
|
||||
.add(new DiscoveryNode(masters[masterIndex], buildNewFakeTransportAddress(),
|
||||
emptyMap(), emptySet(),Version.CURRENT)).masterNodeId(masters[masterIndex]).build()
|
||||
).build();
|
||||
} else {
|
||||
|
|
|
@ -229,7 +229,7 @@ public class PublishClusterStateActionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
private static MockTransportService buildTransportService(Settings settings, ThreadPool threadPool) {
|
||||
MockTransportService transportService = MockTransportService.local(settings, Version.CURRENT, threadPool);
|
||||
MockTransportService transportService = MockTransportService.createNewService(settings, Version.CURRENT, threadPool);
|
||||
transportService.start();
|
||||
transportService.acceptIncomingRequests();
|
||||
return transportService;
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.elasticsearch.action.support.nodes.BaseNodeResponse;
|
|||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
|
@ -45,11 +44,11 @@ import static org.hamcrest.Matchers.sameInstance;
|
|||
/**
|
||||
*/
|
||||
public class AsyncShardFetchTests extends ESTestCase {
|
||||
private final DiscoveryNode node1 = new DiscoveryNode("node1", LocalTransportAddress.buildUnique(), Collections.emptyMap(),
|
||||
private final DiscoveryNode node1 = new DiscoveryNode("node1", buildNewFakeTransportAddress(), Collections.emptyMap(),
|
||||
Collections.singleton(DiscoveryNode.Role.DATA), Version.CURRENT);
|
||||
private final Response response1 = new Response(node1);
|
||||
private final Throwable failure1 = new Throwable("simulated failure 1");
|
||||
private final DiscoveryNode node2 = new DiscoveryNode("node2", LocalTransportAddress.buildUnique(), Collections.emptyMap(),
|
||||
private final DiscoveryNode node2 = new DiscoveryNode("node2", buildNewFakeTransportAddress(), Collections.emptyMap(),
|
||||
Collections.singleton(DiscoveryNode.Role.DATA), Version.CURRENT);
|
||||
private final Response response2 = new Response(node2);
|
||||
private final Throwable failure2 = new Throwable("simulate failure 2");
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.elasticsearch.common.component.AbstractLifecycleComponent;
|
|||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.BoundTransportAddress;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||
|
@ -142,7 +141,7 @@ public class HttpServerTests extends ESTestCase {
|
|||
|
||||
@Override
|
||||
public BoundTransportAddress boundAddress() {
|
||||
LocalTransportAddress transportAddress = new LocalTransportAddress("1");
|
||||
TransportAddress transportAddress = buildNewFakeTransportAddress();
|
||||
return new BoundTransportAddress(new TransportAddress[] {transportAddress} ,transportAddress);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,6 @@ import static org.hamcrest.Matchers.equalTo;
|
|||
* Test failure when index replication actions fail mid-flight
|
||||
*/
|
||||
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, transportClientRatio = 0)
|
||||
@ESIntegTestCase.SuppressLocalMode
|
||||
public class TransportIndexFailuresIT extends ESIntegTestCase {
|
||||
|
||||
private static final Settings nodeSettings = Settings.builder()
|
||||
|
|
|
@ -29,16 +29,19 @@ import org.elasticsearch.cluster.action.shard.ShardStateAction;
|
|||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.network.NetworkService;
|
||||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
||||
import org.elasticsearch.test.ESSingleNodeTestCase;
|
||||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.MockTcpTransport;
|
||||
import org.elasticsearch.transport.Transport;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.transport.local.LocalTransport;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -54,7 +57,7 @@ public class DynamicMappingDisabledTests extends ESSingleNodeTestCase {
|
|||
|
||||
private static ThreadPool THREAD_POOL;
|
||||
private ClusterService clusterService;
|
||||
private LocalTransport transport;
|
||||
private Transport transport;
|
||||
private TransportService transportService;
|
||||
private IndicesService indicesService;
|
||||
private ShardStateAction shardStateAction;
|
||||
|
@ -75,8 +78,9 @@ public class DynamicMappingDisabledTests extends ESSingleNodeTestCase {
|
|||
.put(MapperService.INDEX_MAPPER_DYNAMIC_SETTING.getKey(), false)
|
||||
.build();
|
||||
clusterService = createClusterService(THREAD_POOL);
|
||||
transport = new LocalTransport(settings, THREAD_POOL, new NamedWriteableRegistry(Collections.emptyList()),
|
||||
new NoneCircuitBreakerService());
|
||||
transport = new MockTcpTransport(settings, THREAD_POOL, BigArrays.NON_RECYCLING_INSTANCE,
|
||||
new NoneCircuitBreakerService(), new NamedWriteableRegistry(Collections.emptyList()),
|
||||
new NetworkService(settings, Collections.emptyList()));
|
||||
transportService = new TransportService(clusterService.getSettings(), transport, THREAD_POOL,
|
||||
TransportService.NOOP_TRANSPORT_INTERCEPTOR);
|
||||
indicesService = getInstanceFromNode(IndicesService.class);
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.elasticsearch.cluster.routing.ShardRouting;
|
|||
import org.elasticsearch.cluster.routing.ShardRoutingHelper;
|
||||
import org.elasticsearch.common.collect.Iterators;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.engine.Engine;
|
||||
import org.elasticsearch.index.mapper.Uid;
|
||||
|
@ -90,7 +89,7 @@ public abstract class ESIndexLevelReplicationTestCase extends IndexShardTestCase
|
|||
}
|
||||
|
||||
protected DiscoveryNode getDiscoveryNode(String id) {
|
||||
return new DiscoveryNode(id, id, new LocalTransportAddress(id), Collections.emptyMap(),
|
||||
return new DiscoveryNode(id, id, buildNewFakeTransportAddress(), Collections.emptyMap(),
|
||||
Collections.singleton(DiscoveryNode.Role.DATA), Version.CURRENT);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ import org.elasticsearch.cluster.service.ClusterService;
|
|||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.unit.ByteSizeUnit;
|
||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.env.Environment;
|
||||
|
@ -448,7 +447,7 @@ public class IndexShardIT extends ESSingleNodeTestCase {
|
|||
|
||||
|
||||
public static final IndexShard recoverShard(IndexShard newShard) throws IOException {
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
newShard.markAsRecovering("store", new RecoveryState(newShard.routingEntry(), localNode, null));
|
||||
assertTrue(newShard.recoverFromStore());
|
||||
newShard.updateRoutingEntry(newShard.routingEntry().moveToStarted());
|
||||
|
|
|
@ -58,7 +58,6 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
|||
import org.elasticsearch.common.lease.Releasable;
|
||||
import org.elasticsearch.common.lease.Releasables;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
||||
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -423,7 +422,7 @@ public class IndexShardTests extends IndexShardTestCase {
|
|||
flushShard(shard);
|
||||
|
||||
final IndexShard newShard = reinitShard(shard);
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
|
||||
Store.MetadataSnapshot snapshot = newShard.snapshotStoreMetadata();
|
||||
assertThat(snapshot.getSegmentsFile().name(), equalTo("segments_2"));
|
||||
|
@ -863,7 +862,7 @@ public class IndexShardTests extends IndexShardTestCase {
|
|||
translogOps = 0;
|
||||
}
|
||||
IndexShard newShard = reinitShard(shard);
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
newShard.markAsRecovering("store", new RecoveryState(newShard.routingEntry(), localNode, null));
|
||||
assertTrue(newShard.recoverFromStore());
|
||||
assertEquals(translogOps, newShard.recoveryState().getTranslog().recoveredOperations());
|
||||
|
@ -886,7 +885,7 @@ public class IndexShardTests extends IndexShardTestCase {
|
|||
ShardRoutingHelper.initWithSameId(shardRouting, RecoverySource.StoreRecoverySource.EMPTY_STORE_INSTANCE)
|
||||
);
|
||||
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
newShard.markAsRecovering("store", new RecoveryState(newShard.routingEntry(), localNode, null));
|
||||
assertTrue(newShard.recoverFromStore());
|
||||
assertEquals(0, newShard.recoveryState().getTranslog().recoveredOperations());
|
||||
|
@ -911,7 +910,7 @@ public class IndexShardTests extends IndexShardTestCase {
|
|||
cleanLuceneIndex(store.directory());
|
||||
store.decRef();
|
||||
IndexShard newShard = reinitShard(shard);
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
ShardRouting routing = newShard.routingEntry();
|
||||
newShard.markAsRecovering("store", new RecoveryState(routing, localNode, null));
|
||||
try {
|
||||
|
@ -985,7 +984,7 @@ public class IndexShardTests extends IndexShardTestCase {
|
|||
Store sourceStore = source.store();
|
||||
Store targetStore = target.store();
|
||||
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
target.markAsRecovering("store", new RecoveryState(routing, localNode, null));
|
||||
assertTrue(target.restoreFromRepository(new RestoreOnlyRepository("test") {
|
||||
@Override
|
||||
|
@ -1224,7 +1223,7 @@ public class IndexShardTests extends IndexShardTestCase {
|
|||
IndexShard shard = newStartedShard(true);
|
||||
indexDoc(shard, "type", "0");
|
||||
shard = reinitShard(shard);
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
shard.markAsRecovering("for testing", new RecoveryState(shard.routingEntry(), localNode, null));
|
||||
// Shard is still inactive since we haven't started recovering yet
|
||||
assertFalse(shard.isActive());
|
||||
|
@ -1251,7 +1250,7 @@ public class IndexShardTests extends IndexShardTestCase {
|
|||
|
||||
indexDoc(primary, "test", "0", "{\"foo\" : \"bar\"}");
|
||||
IndexShard replica = newShard(primary.shardId(), false, "n2", metaData, null);
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
replica.markAsRecovering("for testing", new RecoveryState(replica.routingEntry(), localNode, localNode));
|
||||
// Shard is still inactive since we haven't started recovering yet
|
||||
assertFalse(replica.isActive());
|
||||
|
@ -1299,7 +1298,7 @@ public class IndexShardTests extends IndexShardTestCase {
|
|||
ShardRoutingState.INITIALIZING, RecoverySource.LocalShardsRecoverySource.INSTANCE);
|
||||
|
||||
final IndexShard targetShard;
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
Map<String, MappingMetaData> requestedMappingUpdates = ConcurrentCollections.newConcurrentMap();
|
||||
{
|
||||
targetShard = newShard(targetRouting);
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse;
|
|||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.unit.ByteSizeUnit;
|
||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
|
@ -447,7 +446,7 @@ public class IndexingMemoryControllerTests extends ESSingleNodeTestCase {
|
|||
try {
|
||||
assertEquals(0, imc.availableShards().size());
|
||||
ShardRouting routing = newShard.routingEntry();
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNode localNode = new DiscoveryNode("foo", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
newShard.markAsRecovering("store", new RecoveryState(routing, localNode, null));
|
||||
|
||||
assertEquals(1, imc.availableShards().size());
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.elasticsearch.cluster.routing.ShardRouting;
|
|||
import org.elasticsearch.cluster.routing.ShardRoutingHelper;
|
||||
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.NodeServicesProvider;
|
||||
|
@ -106,7 +105,7 @@ public class IndicesLifecycleListenerSingleNodeTests extends ESSingleNodeTestCas
|
|||
newRouting = ShardRoutingHelper.initialize(newRouting, nodeId);
|
||||
IndexShard shard = index.createShard(newRouting);
|
||||
shard.updateRoutingEntry(newRouting);
|
||||
final DiscoveryNode localNode = new DiscoveryNode("foo", LocalTransportAddress.buildUnique(),
|
||||
final DiscoveryNode localNode = new DiscoveryNode("foo", buildNewFakeTransportAddress(),
|
||||
emptyMap(), emptySet(), Version.CURRENT);
|
||||
shard.markAsRecovering("store", new RecoveryState(newRouting, localNode, null));
|
||||
shard.recoverFromStore();
|
||||
|
|
|
@ -43,7 +43,6 @@ import org.elasticsearch.cluster.routing.allocation.FailedShard;
|
|||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.UUIDs;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.util.set.Sets;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.indices.recovery.PeerRecoveryTargetService;
|
||||
|
@ -353,7 +352,7 @@ public class IndicesClusterStateServiceRandomUpdatesTests extends AbstractIndice
|
|||
roles.add(mustHaveRole);
|
||||
}
|
||||
final String id = String.format(Locale.ROOT, "node_%03d", nodeIdGenerator.incrementAndGet());
|
||||
return new DiscoveryNode(id, id, LocalTransportAddress.buildUnique(), Collections.emptyMap(), roles,
|
||||
return new DiscoveryNode(id, id, buildNewFakeTransportAddress(), Collections.emptyMap(), roles,
|
||||
Version.CURRENT);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,13 +35,11 @@ import org.elasticsearch.ExceptionsHelper;
|
|||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.routing.RecoverySource;
|
||||
import org.elasticsearch.common.io.FileSystemUtils;
|
||||
import org.elasticsearch.common.lease.Releasable;
|
||||
import org.elasticsearch.common.lucene.store.IndexOutputOutputStream;
|
||||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.shard.IndexShard;
|
||||
import org.elasticsearch.index.shard.IndexShardRelocatedException;
|
||||
|
@ -82,8 +80,8 @@ public class RecoverySourceHandlerTests extends ESTestCase {
|
|||
put("indices.recovery.concurrent_small_file_streams", 1).build();
|
||||
final RecoverySettings recoverySettings = new RecoverySettings(settings, service);
|
||||
StartRecoveryRequest request = new StartRecoveryRequest(shardId,
|
||||
new DiscoveryNode("b", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
new DiscoveryNode("b", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
new DiscoveryNode("b", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
new DiscoveryNode("b", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
null, randomBoolean(), randomLong());
|
||||
Store store = newStore(createTempDir());
|
||||
RecoverySourceHandler handler = new RecoverySourceHandler(null, null, request, () -> 0L, e -> () -> {},
|
||||
|
@ -134,8 +132,8 @@ public class RecoverySourceHandlerTests extends ESTestCase {
|
|||
put("indices.recovery.concurrent_small_file_streams", 1).build();
|
||||
final RecoverySettings recoverySettings = new RecoverySettings(settings, service);
|
||||
StartRecoveryRequest request = new StartRecoveryRequest(shardId,
|
||||
new DiscoveryNode("b", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
new DiscoveryNode("b", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
new DiscoveryNode("b", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
new DiscoveryNode("b", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
null, randomBoolean(), randomLong());
|
||||
Path tempDir = createTempDir();
|
||||
Store store = newStore(tempDir, false);
|
||||
|
@ -198,8 +196,8 @@ public class RecoverySourceHandlerTests extends ESTestCase {
|
|||
put("indices.recovery.concurrent_small_file_streams", 1).build();
|
||||
final RecoverySettings recoverySettings = new RecoverySettings(settings, service);
|
||||
StartRecoveryRequest request = new StartRecoveryRequest(shardId,
|
||||
new DiscoveryNode("b", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
new DiscoveryNode("b", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
new DiscoveryNode("b", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
new DiscoveryNode("b", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
null, randomBoolean(), randomLong());
|
||||
Path tempDir = createTempDir();
|
||||
Store store = newStore(tempDir, false);
|
||||
|
@ -257,8 +255,8 @@ public class RecoverySourceHandlerTests extends ESTestCase {
|
|||
public void testThrowExceptionOnPrimaryRelocatedBeforePhase1Completed() throws IOException {
|
||||
final RecoverySettings recoverySettings = new RecoverySettings(Settings.EMPTY, service);
|
||||
StartRecoveryRequest request = new StartRecoveryRequest(shardId,
|
||||
new DiscoveryNode("b", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
new DiscoveryNode("b", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
new DiscoveryNode("b", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
new DiscoveryNode("b", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
null, false, randomLong());
|
||||
IndexShard shard = mock(IndexShard.class);
|
||||
Translog.View translogView = mock(Translog.View.class);
|
||||
|
@ -287,8 +285,8 @@ public class RecoverySourceHandlerTests extends ESTestCase {
|
|||
public void testWaitForClusterStateOnPrimaryRelocation() throws IOException, InterruptedException {
|
||||
final RecoverySettings recoverySettings = new RecoverySettings(Settings.EMPTY, service);
|
||||
StartRecoveryRequest request = new StartRecoveryRequest(shardId,
|
||||
new DiscoveryNode("b", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
new DiscoveryNode("b", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
new DiscoveryNode("b", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
new DiscoveryNode("b", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT),
|
||||
null, true, randomLong());
|
||||
AtomicBoolean phase1Called = new AtomicBoolean();
|
||||
AtomicBoolean phase2Called = new AtomicBoolean();
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.apache.lucene.codecs.CodecUtil;
|
|||
import org.apache.lucene.store.IndexOutput;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.util.set.Sets;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.shard.IndexShard;
|
||||
|
@ -42,7 +41,7 @@ public class RecoveryStatusTests extends ESSingleNodeTestCase {
|
|||
IndexService service = createIndex("foo");
|
||||
|
||||
IndexShard indexShard = service.getShardOrNull(0);
|
||||
DiscoveryNode node = new DiscoveryNode("foo", new LocalTransportAddress("bar"), emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNode node = new DiscoveryNode("foo", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
RecoveryTarget status = new RecoveryTarget(indexShard, node, new PeerRecoveryTargetService.RecoveryListener() {
|
||||
@Override
|
||||
public void onRecoveryDone(RecoveryState state) {
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.indices.recovery.RecoveryState.File;
|
||||
import org.elasticsearch.indices.recovery.RecoveryState.Index;
|
||||
|
@ -342,7 +341,7 @@ public class RecoveryTargetTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testStageSequenceEnforcement() {
|
||||
final DiscoveryNode discoveryNode = new DiscoveryNode("1", LocalTransportAddress.buildUnique(), emptyMap(), emptySet(),
|
||||
final DiscoveryNode discoveryNode = new DiscoveryNode("1", buildNewFakeTransportAddress(), emptyMap(), emptySet(),
|
||||
Version.CURRENT);
|
||||
Stage[] stages = Stage.values();
|
||||
int i = randomIntBetween(0, stages.length - 1);
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.elasticsearch.Version;
|
|||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.io.stream.InputStreamStreamInput;
|
||||
import org.elasticsearch.common.io.stream.OutputStreamStreamOutput;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.index.store.Store;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
@ -43,8 +42,8 @@ public class StartRecoveryRequestTests extends ESTestCase {
|
|||
Version targetNodeVersion = randomVersion(random());
|
||||
StartRecoveryRequest outRequest = new StartRecoveryRequest(
|
||||
new ShardId("test", "_na_", 0),
|
||||
new DiscoveryNode("a", new LocalTransportAddress("1"), emptyMap(), emptySet(), targetNodeVersion),
|
||||
new DiscoveryNode("b", new LocalTransportAddress("1"), emptyMap(), emptySet(), targetNodeVersion),
|
||||
new DiscoveryNode("a", buildNewFakeTransportAddress(), emptyMap(), emptySet(), targetNodeVersion),
|
||||
new DiscoveryNode("b", buildNewFakeTransportAddress(), emptyMap(), emptySet(), targetNodeVersion),
|
||||
Store.MetadataSnapshot.EMPTY,
|
||||
randomBoolean(),
|
||||
1L
|
||||
|
|
|
@ -41,7 +41,6 @@ import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders;
|
|||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.discovery.DiscoveryModule;
|
||||
import org.elasticsearch.discovery.DiscoverySettings;
|
||||
|
@ -76,9 +75,15 @@ import static org.hamcrest.Matchers.instanceOf;
|
|||
/**
|
||||
*/
|
||||
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, numClientNodes = 0, transportClientRatio = 0)
|
||||
@ESIntegTestCase.SuppressLocalMode
|
||||
@TestLogging("_root:DEBUG")
|
||||
public class RareClusterStateIT extends ESIntegTestCase {
|
||||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
|
||||
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "zen").build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int numberOfShards() {
|
||||
return 1;
|
||||
|
@ -126,7 +131,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
|
|||
// inject a node
|
||||
ClusterState.Builder builder = ClusterState.builder(currentState);
|
||||
builder.nodes(DiscoveryNodes.builder(currentState.nodes()).add(new DiscoveryNode("_non_existent",
|
||||
LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT)));
|
||||
buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT)));
|
||||
|
||||
// open index
|
||||
final IndexMetaData indexMetaData = IndexMetaData.builder(currentState.metaData().index(index)).state(IndexMetaData.State.OPEN).build();
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.elasticsearch.cluster.routing.TestShardRouting;
|
|||
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
|
@ -86,7 +85,7 @@ public class IndicesStoreTests extends ESTestCase {
|
|||
|
||||
@Before
|
||||
public void before() {
|
||||
localNode = new DiscoveryNode("abc", new LocalTransportAddress("abc"), emptyMap(), emptySet(), Version.CURRENT);
|
||||
localNode = new DiscoveryNode("abc", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
|
||||
clusterService = createClusterService(threadPool);
|
||||
indicesStore = new IndicesStore(Settings.EMPTY, null, clusterService, new TransportService(clusterService.getSettings(), null, null, TransportService.NOOP_TRANSPORT_INTERCEPTOR), null);
|
||||
}
|
||||
|
@ -142,7 +141,7 @@ public class IndicesStoreTests extends ESTestCase {
|
|||
ClusterState.Builder clusterState = ClusterState.builder(new ClusterName("test"));
|
||||
clusterState.metaData(MetaData.builder().put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(numShards).numberOfReplicas(numReplicas)));
|
||||
clusterState.nodes(DiscoveryNodes.builder().localNodeId(localNode.getId()).add(localNode).add(new DiscoveryNode("xyz",
|
||||
new LocalTransportAddress("xyz"), emptyMap(), emptySet(), Version.CURRENT)));
|
||||
buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT)));
|
||||
IndexShardRoutingTable.Builder routingTable = new IndexShardRoutingTable.Builder(new ShardId("test", "_na_", 1));
|
||||
int localShardId = randomInt(numShards - 1);
|
||||
for (int i = 0; i < numShards; i++) {
|
||||
|
@ -187,7 +186,7 @@ public class IndicesStoreTests extends ESTestCase {
|
|||
ClusterState.Builder clusterState = ClusterState.builder(new ClusterName("test"));
|
||||
clusterState.metaData(MetaData.builder().put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(numShards).numberOfReplicas(numReplicas)));
|
||||
clusterState.nodes(DiscoveryNodes.builder().localNodeId(localNode.getId()).add(localNode).add(new DiscoveryNode("xyz",
|
||||
new LocalTransportAddress("xyz"), emptyMap(), emptySet(), nodeVersion)));
|
||||
buildNewFakeTransportAddress(), emptyMap(), emptySet(), nodeVersion)));
|
||||
IndexShardRoutingTable.Builder routingTable = new IndexShardRoutingTable.Builder(new ShardId("test", "_na_", 1));
|
||||
for (int i = 0; i < numShards; i++) {
|
||||
routingTable.addShard(TestShardRouting.newShardRouting("test", i, "xyz", null, true, ShardRoutingState.STARTED));
|
||||
|
@ -210,8 +209,8 @@ public class IndicesStoreTests extends ESTestCase {
|
|||
|
||||
clusterState.nodes(DiscoveryNodes.builder().localNodeId(localNode.getId())
|
||||
.add(localNode)
|
||||
.add(new DiscoveryNode("xyz", new LocalTransportAddress("xyz"), emptyMap(), emptySet(), Version.CURRENT))
|
||||
.add(new DiscoveryNode("def", new LocalTransportAddress("def"), emptyMap(), emptySet(), nodeVersion) // <-- only set relocating, since we're testing that in this test
|
||||
.add(new DiscoveryNode("xyz", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT))
|
||||
.add(new DiscoveryNode("def", buildNewFakeTransportAddress(), emptyMap(), emptySet(), nodeVersion) // <-- only set relocating, since we're testing that in this test
|
||||
));
|
||||
IndexShardRoutingTable.Builder routingTable = new IndexShardRoutingTable.Builder(new ShardId("test", "_na_", 1));
|
||||
for (int i = 0; i < numShards; i++) {
|
||||
|
|
|
@ -30,7 +30,6 @@ import org.elasticsearch.cluster.metadata.MetaData;
|
|||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.junit.Before;
|
||||
|
||||
|
@ -264,9 +263,9 @@ public class PipelineStoreTests extends ESTestCase {
|
|||
PutPipelineRequest putRequest = new PutPipelineRequest("_id", new BytesArray(
|
||||
"{\"processors\": [{\"set\" : {\"field\": \"_field\", \"value\": \"_value\"}},{\"remove\" : {\"field\": \"_field\"}}]}"));
|
||||
|
||||
DiscoveryNode node1 = new DiscoveryNode("_node_id1", new LocalTransportAddress("_id"),
|
||||
DiscoveryNode node1 = new DiscoveryNode("_node_id1", buildNewFakeTransportAddress(),
|
||||
emptyMap(), emptySet(), Version.CURRENT);
|
||||
DiscoveryNode node2 = new DiscoveryNode("_node_id2", new LocalTransportAddress("_id"),
|
||||
DiscoveryNode node2 = new DiscoveryNode("_node_id2", buildNewFakeTransportAddress(),
|
||||
emptyMap(), emptySet(), Version.CURRENT);
|
||||
Map<DiscoveryNode, IngestInfo> ingestInfos = new HashMap<>();
|
||||
ingestInfos.put(node1, new IngestInfo(Arrays.asList(new ProcessorInfo("set"), new ProcessorInfo("remove"))));
|
||||
|
@ -293,7 +292,7 @@ public class PipelineStoreTests extends ESTestCase {
|
|||
assertThat(e.getMessage(), equalTo("Ingest info is empty"));
|
||||
}
|
||||
|
||||
DiscoveryNode discoveryNode = new DiscoveryNode("_node_id", new LocalTransportAddress("_id"),
|
||||
DiscoveryNode discoveryNode = new DiscoveryNode("_node_id", buildNewFakeTransportAddress(),
|
||||
emptyMap(), emptySet(), Version.CURRENT);
|
||||
IngestInfo ingestInfo = new IngestInfo(Collections.singletonList(new ProcessorInfo("set")));
|
||||
store.validatePipeline(Collections.singletonMap(discoveryNode, ingestInfo), putRequest);
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
|||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.BoundTransportAddress;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
|
@ -106,7 +105,7 @@ public class NodeInfoStreamingTests extends ESTestCase {
|
|||
|
||||
private static NodeInfo createNodeInfo() {
|
||||
Build build = Build.CURRENT;
|
||||
DiscoveryNode node = new DiscoveryNode("test_node", LocalTransportAddress.buildUnique(),
|
||||
DiscoveryNode node = new DiscoveryNode("test_node", buildNewFakeTransportAddress(),
|
||||
emptyMap(), emptySet(), VersionUtils.randomVersion(random()));
|
||||
Settings settings = randomBoolean() ? null : Settings.builder().put("test", "setting").build();
|
||||
OsInfo osInfo = null;
|
||||
|
@ -133,7 +132,7 @@ public class NodeInfoStreamingTests extends ESTestCase {
|
|||
}
|
||||
Map<String, BoundTransportAddress> profileAddresses = new HashMap<>();
|
||||
BoundTransportAddress dummyBoundTransportAddress = new BoundTransportAddress(
|
||||
new TransportAddress[]{LocalTransportAddress.buildUnique()}, LocalTransportAddress.buildUnique());
|
||||
new TransportAddress[]{buildNewFakeTransportAddress()}, buildNewFakeTransportAddress());
|
||||
profileAddresses.put("test_address", dummyBoundTransportAddress);
|
||||
TransportInfo transport = randomBoolean() ? null : new TransportInfo(dummyBoundTransportAddress, profileAddresses);
|
||||
HttpInfo httpInfo = randomBoolean() ? null : new HttpInfo(dummyBoundTransportAddress, randomLong());
|
||||
|
|
|
@ -21,19 +21,15 @@ package org.elasticsearch.search.aggregations.bucket;
|
|||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.index.mapper.DateFieldMapper;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
|
||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.transport.AssertingLocalTransport;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
|
@ -58,11 +54,6 @@ public class DateHistogramOffsetIT extends ESIntegTestCase {
|
|||
return DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.parser().parseDateTime(date);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> nodePlugins() {
|
||||
return Collections.singleton(AssertingLocalTransport.TestPlugin.class);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void beforeEachTest() throws IOException {
|
||||
prepareCreate("idx2").addMapping("type", "date", "type=date").execute().actionGet();
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.elasticsearch.common.Priority;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.ByteSizeUnit;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.discovery.DiscoveryModule;
|
||||
import org.elasticsearch.discovery.zen.ElectMasterService;
|
||||
import org.elasticsearch.discovery.zen.ZenDiscovery;
|
||||
import org.elasticsearch.index.store.IndexStore;
|
||||
|
@ -92,8 +93,15 @@ import static org.hamcrest.Matchers.nullValue;
|
|||
/**
|
||||
*/
|
||||
@ClusterScope(scope = Scope.TEST, numDataNodes = 0, transportClientRatio = 0)
|
||||
@ESIntegTestCase.SuppressLocalMode // TODO only restorePersistentSettingsTest needs this maybe factor out?
|
||||
public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCase {
|
||||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
|
||||
// TODO only restorePersistentSettingsTest needs this maybe factor out?
|
||||
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "zen").build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> nodePlugins() {
|
||||
return Arrays.asList(MockRepository.Plugin.class);
|
||||
|
|
|
@ -1,37 +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.transport.local;
|
||||
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.test.transport.MockTransportService;
|
||||
import org.elasticsearch.transport.AbstractSimpleTransportTestCase;
|
||||
|
||||
public class SimpleLocalTransportTests extends AbstractSimpleTransportTestCase {
|
||||
|
||||
@Override
|
||||
protected MockTransportService build(Settings settings, Version version) {
|
||||
MockTransportService transportService = MockTransportService.local(settings, version, threadPool);
|
||||
transportService.start();
|
||||
return transportService;
|
||||
}
|
||||
}
|
|
@ -44,6 +44,7 @@ import org.elasticsearch.plugins.Plugin;
|
|||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.InternalTestCluster;
|
||||
import org.elasticsearch.test.NodeConfigurationSource;
|
||||
import org.elasticsearch.transport.MockTcpTransportPlugin;
|
||||
import org.elasticsearch.transport.Transport;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
|
@ -193,15 +194,15 @@ public class TribeIT extends ESIntegTestCase {
|
|||
settings.put(Node.NODE_DATA_SETTING.getKey(), false);
|
||||
settings.put(Node.NODE_MASTER_SETTING.getKey(), true);
|
||||
settings.put(NetworkModule.HTTP_ENABLED.getKey(), false);
|
||||
settings.put(NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), NetworkModule.LOCAL_TRANSPORT);
|
||||
settings.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), NetworkModule.LOCAL_TRANSPORT);
|
||||
settings.put(NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);
|
||||
settings.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "local");
|
||||
|
||||
doWithAllClusters(filter, c -> {
|
||||
String tribeSetting = "tribe." + c.getClusterName() + ".";
|
||||
settings.put(tribeSetting + ClusterName.CLUSTER_NAME_SETTING.getKey(), c.getClusterName());
|
||||
settings.put(tribeSetting + DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING.getKey(), "100ms");
|
||||
settings.put(tribeSetting + NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), NetworkModule.LOCAL_TRANSPORT);
|
||||
settings.put(tribeSetting + DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), NetworkModule.LOCAL_TRANSPORT);
|
||||
settings.put(tribeSetting + NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);
|
||||
settings.put(tribeSetting + DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "local");
|
||||
|
||||
Set<String> hosts = new HashSet<>();
|
||||
for (Transport transport : c.getInstances(Transport.class)) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue