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

Conversation

s1monw
Copy link
Contributor

@s1monw s1monw commented Sep 29, 2016

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.

@s1monw s1monw added >test Issues or PRs that are addressing/adding tests review WIP :Distributed Coordination/Network Http and internode communication implementations v6.0.0-alpha1 labels Sep 29, 2016
@s1monw s1monw force-pushed the trash_local_transport branch from 29d2a90 to 8abd72c Compare October 4, 2016 07:51
s1monw added 9 commits October 4, 2016 12:12
This change proposes the removal of all non-tcp transport implementations. The
mock transport can be used by defaule to run tests instead of local transport that has
roughly the same performance compared to TCP or at least not noticibely slower.

This is a master only change, deprecation notice in 5.x will be committed as a
separate change.
@s1monw s1monw force-pushed the trash_local_transport branch from 8abd72c to e646596 Compare October 4, 2016 10:12
@s1monw s1monw removed the WIP label Oct 4, 2016
@@ -217,7 +215,7 @@ public DiscoveryNode(StreamInput in) throws IOException {
this.ephemeralId = in.readString().intern();
this.hostName = in.readString().intern();
this.hostAddress = in.readString().intern();
this.address = TransportAddressSerializers.addressFromStream(in);
this.address = new TransportAddress(in);
Copy link
Member

Choose a reason for hiding this comment

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

👍

private static final Map<Short, Writeable.Reader<TransportAddress>> ADDRESS_REGISTRY;

static {
Map<Short, Writeable.Reader<TransportAddress>> registry = new HashMap<>();
Copy link
Member

Choose a reason for hiding this comment

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

Hurray! Another NamedWriteableRegistry clone removed!

//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);
assertTrue(iteration.nodeAddresses.contains(discoveryNode.getAddress()));
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer something like assertThat(iteration.nodeAddresses, hasItemInArray(discoveryNode.getAddress())). The error messages are nicer.

import static org.hamcrest.Matchers.equalTo;

/**
*
*/
public class ClusterSerializationTests extends ESAllocationTestCase {
private static final AtomicInteger port = new AtomicInteger(0);
Copy link
Member

Choose a reason for hiding this comment

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

Is this a leftover?

super(null, null, null, null);
}
}
// static class FakeTransport extends MockTcpTransport {
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be uncommented and used?

Copy link
Member

Choose a reason for hiding this comment

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

Looks like this should just be removed.

@@ -121,7 +121,6 @@
import static org.hamcrest.Matchers.nullValue;

@ClusterScope(scope = Scope.TEST, numDataNodes = 0, transportClientRatio = 0)
@ESIntegTestCase.SuppressLocalMode
Copy link
Member

Choose a reason for hiding this comment

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

Note to self - figure out why this doesn't need the traditional zen discovery setting.

Copy link
Member

Choose a reason for hiding this comment

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

Answer to self - because this uses ClusterDiscoveryConfiguration which already comes with it.

@@ -58,11 +54,6 @@ private DateTime date(String date) {
return DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.parser().parseDateTime(date);
}

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(AssertingLocalTransport.TestPlugin.class);
Copy link
Member

Choose a reason for hiding this comment

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

This seems like a weird place for this plugin!

Settings.Builder networkSettings = Settings.builder();
final boolean isNetwork;
if (noLocal != null && noNetwork != null) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm glad this is gone!

@@ -174,6 +184,14 @@ protected void afterAlways(List<Throwable> errors) throws Throwable {
});

/**
* Generates a new transport address using {@link TransportAddress#META_ADDRESS} with an incrementing port number.
* The port number starts at 0 and is reset before each test suite run.
Copy link
Member

Choose a reason for hiding this comment

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

s/before/after/


@Override
protected void handleParsedResponse(final TransportResponse response, final TransportResponseHandler handler) {
ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersionBetween(random, minVersion, maxVersion), response,
Copy link
Member

Choose a reason for hiding this comment

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

Are we ok with dropping this assertion and the one in the method below? Should we add them to MockTransportService?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no it serializes by default since it goes across the network

Copy link
Member

Choose a reason for hiding this comment

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

I thought the value we got out of this was in serializing to a random version, not that it serializes at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure there is value here to be honest if you insist I can add it back

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the original reason I added this was to serialize at all

Copy link
Member

Choose a reason for hiding this comment

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

It has caught some interesting bugs in the past for me. Stuff like "don't mutate the request after you've sent it" and "don't mutate the request after you've received it" and "make sure to add version guards on read as well as write".

@s1monw
Copy link
Contributor Author

s1monw commented Oct 5, 2016

@nik9000 I pushed updates can you look again

@@ -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) {
Copy link
Member

Choose a reason for hiding this comment

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

Awesome.

@nik9000
Copy link
Member

nik9000 commented Oct 5, 2016

Cool.

I'm happy with it. If you want to get it in now and deal with the question of assertVersionSerializable after that is fine. I could work on a followup to get the random version testing back and we could debate its merits there?

@s1monw
Copy link
Contributor Author

s1monw commented Oct 6, 2016

@nik9000 I added an AssertingTransportInterceptor so we are getting these assertions everywhere randomly!

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

I'm fine with it once the build passes.

Thanks for adding the assertion back. I wouldn't have asked unless I'd seen it catch stuff no other assertions caught.

@s1monw
Copy link
Contributor Author

s1monw commented Oct 7, 2016

test this please

@s1monw s1monw merged commit 194a6b1 into elastic:master Oct 7, 2016
s1monw added a commit that referenced this pull request Nov 28, 2016
TransportAddress used to be customizable per transport but this has been removed
a while ago. Therefore we can remove all usage of this method as well.

Relates to #20695
ywelsch added a commit to ywelsch/elasticsearch that referenced this pull request Jun 19, 2018
ywelsch added a commit that referenced this pull request Jun 21, 2018
With #20695 we removed local transport and there is just TransportAddress now. The
UnicastHostsProvider currently returns DiscoveryNode instances, where, during pinging, we're
actually only making use of the TransportAddress to establish a first connection to the possible new 
node. To simplify the interface, we can just return a list of transport addresses instead, which
means that it's not necessary anymore to create fake node objects in each plugin just to return the
address information.
ywelsch added a commit that referenced this pull request Jun 21, 2018
With #20695 we removed local transport and there is just TransportAddress now. The
UnicastHostsProvider currently returns DiscoveryNode instances, where, during pinging, we're
actually only making use of the TransportAddress to establish a first connection to the possible new 
node. To simplify the interface, we can just return a list of transport addresses instead, which
means that it's not necessary anymore to create fake node objects in each plugin just to return the
address information.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>breaking >breaking-java :Distributed Coordination/Network Http and internode communication implementations >test Issues or PRs that are addressing/adding tests v6.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants