Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove LocalTransport in favor of MockTcpTransport #20695

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public boolean match(DiscoveryNode node) {
// We check both the host_ip or the publish_ip
String publishAddress = null;
if (node.getAddress() instanceof TransportAddress) {
publishAddress = NetworkAddress.format(((TransportAddress) node.getAddress()).address().getAddress());
publishAddress = NetworkAddress.format(node.getAddress().address().getAddress());
}

boolean match = matchByIP(values, node.getHostAddress(), publishAddress);
Expand Down Expand Up @@ -117,7 +117,7 @@ public boolean match(DiscoveryNode node) {
// We check explicitly only the publish_ip
String address = null;
if (node.getAddress() instanceof TransportAddress) {
address = NetworkAddress.format(((TransportAddress) node.getAddress()).address().getAddress());
address = NetworkAddress.format(node.getAddress().address().getAddress());
}

boolean match = matchByIP(values, address, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ public void writeTo(StreamOutput out) throws IOException {
}

public boolean sameHost(TransportAddress other) {
return other instanceof TransportAddress &&
address.getAddress().equals(((TransportAddress) other).address.getAddress());
return address.getAddress().equals(other.address.getAddress());
}

public boolean isLoopbackOrLinkLocalAddress() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,7 @@ private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoR
table.addCell(info == null ? null : info.getProcess().getId());
table.addCell(node.getHostName());
table.addCell(node.getHostAddress());
if (node.getAddress() instanceof TransportAddress) {
table.addCell(((TransportAddress) node.getAddress()).address().getPort());
} else {
table.addCell("-");
}
table.addCell(node.getAddress().address().getPort());
table.addCell(attrEntry.getKey());
table.addCell(attrEntry.getValue());
table.endRow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,19 +235,11 @@ private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoR
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 TransportAddress) {
table.addCell(((TransportAddress) 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 TransportAddress) {
table.addCell(NetworkAddress.format(((TransportAddress)transportAddress).address()));
} else {
table.addCell(transportAddress.toString());
}
table.addCell(NetworkAddress.format(transportAddress.address()));
} else {
table.addCell("-");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,7 @@ private void buildRow(Table table, boolean fullId, boolean detailed, DiscoveryNo
// 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 TransportAddress) {
table.addCell(((TransportAddress) node.getAddress()).address().getPort());
} else {
table.addCell("-");
}
table.addCell(node.getAddress().address().getPort());
Copy link
Member

Choose a reason for hiding this comment

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

Awesome.

table.addCell(node == null ? "-" : node.getName());
table.addCell(node == null ? "-" : node.getVersion().toString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,7 @@ private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoR
table.addCell(info == null ? null : info.getProcess().getId());
table.addCell(node.getHostName());
table.addCell(node.getHostAddress());
if (node.getAddress() instanceof TransportAddress) {
table.addCell(((TransportAddress) 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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public long serverOpen() {
}

protected NodeChannels connectToChannelsLight(DiscoveryNode node) {
InetSocketAddress address = ((TransportAddress) node.getAddress()).address();
InetSocketAddress address = node.getAddress().address();
ChannelFuture connect = clientBootstrap.connect(address);
connect.awaitUninterruptibly((long) (connectTimeout.millis() * 1.5));
if (!connect.isSuccess()) {
Expand All @@ -352,7 +352,7 @@ protected NodeChannels connectToChannels(DiscoveryNode node) throws IOException
int numConnections = connectionsPerNodeBulk + connectionsPerNodePing + connectionsPerNodeRecovery + connectionsPerNodeReg
+ connectionsPerNodeState;
ArrayList<ChannelFuture> connections = new ArrayList<>();
InetSocketAddress address = ((TransportAddress) node.getAddress()).address();
InetSocketAddress address = node.getAddress().address();
for (int i = 0; i < numConnections; i++) {
connections.add(clientBootstrap.connect(address));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ public void testThatInfosAreExposed() throws Exception {
// bound addresses
for (TransportAddress transportAddress : boundTransportAddress.boundAddresses()) {
assertThat(transportAddress, instanceOf(TransportAddress.class));
assertThat(((TransportAddress) transportAddress).address().getPort(),
assertThat(transportAddress.address().getPort(),
is(allOf(greaterThanOrEqualTo(randomPort), lessThanOrEqualTo(randomPort + 10))));
}

// publish address
assertThat(boundTransportAddress.publishAddress(), instanceOf(TransportAddress.class));
TransportAddress publishAddress = (TransportAddress) boundTransportAddress.publishAddress();
TransportAddress publishAddress = boundTransportAddress.publishAddress();
assertThat(NetworkAddress.format(publishAddress.address().getAddress()), is("127.0.0.7"));
assertThat(publishAddress.address().getPort(), is(4321));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public long serverOpen() {
}

protected NodeChannels connectToChannelsLight(DiscoveryNode node) {
InetSocketAddress address = ((TransportAddress) node.getAddress()).address();
InetSocketAddress address = node.getAddress().address();
ChannelFuture connect = bootstrap.connect(address);
connect.awaitUninterruptibly((long) (connectTimeout.millis() * 1.5));
if (!connect.isSuccess()) {
Expand Down Expand Up @@ -364,7 +364,7 @@ protected NodeChannels connectToChannels(DiscoveryNode node) {
connectionsPerNodeState +
connectionsPerNodeRecovery;
final ArrayList<ChannelFuture> connections = new ArrayList<>(numConnections);
final InetSocketAddress address = ((TransportAddress) node.getAddress()).address();
final InetSocketAddress address = node.getAddress().address();
for (int i = 0; i < numConnections; i++) {
connections.add(bootstrap.connect(address));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ public void testThatInfosAreExposed() throws Exception {
// bound addresses
for (TransportAddress transportAddress : boundTransportAddress.boundAddresses()) {
assertThat(transportAddress, instanceOf(TransportAddress.class));
assertThat(((TransportAddress) transportAddress).address().getPort(),
assertThat(transportAddress.address().getPort(),
is(allOf(greaterThanOrEqualTo(randomPort), lessThanOrEqualTo(randomPort + 10))));
}

// publish address
assertThat(boundTransportAddress.publishAddress(), instanceOf(TransportAddress.class));
TransportAddress publishAddress = (TransportAddress) boundTransportAddress.publishAddress();
TransportAddress publishAddress = boundTransportAddress.publishAddress();
assertThat(NetworkAddress.format(publishAddress.address().getAddress()), is("127.0.0.7"));
assertThat(publishAddress.address().getPort(), is(4321));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public ExternalTestCluster(Path tempDir, Settings additionalSettings, Collection
int masterAndDataNodes = 0;
for (int i = 0; i < nodeInfos.getNodes().size(); i++) {
NodeInfo nodeInfo = nodeInfos.getNodes().get(i);
httpAddresses[i] = ((TransportAddress) nodeInfo.getHttp().address().publishAddress()).address();
httpAddresses[i] = nodeInfo.getHttp().address().publishAddress().address();
if (DiscoveryNode.isDataNode(nodeInfo.getSettings())) {
dataNodes++;
masterAndDataNodes++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ public synchronized int size() {
public InetSocketAddress[] httpAddresses() {
List<InetSocketAddress> addresses = new ArrayList<>();
for (HttpServerTransport httpServerTransport : getInstances(HttpServerTransport.class)) {
addresses.add(((TransportAddress) httpServerTransport.boundAddress().publishAddress()).address());
addresses.add(httpServerTransport.boundAddress().publishAddress().address());
}
return addresses.toArray(new InetSocketAddress[addresses.size()]);
}
Expand Down