-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Conversation
29d2a90
to
8abd72c
Compare
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.
8abd72c
to
e646596
Compare
@@ -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); |
There was a problem hiding this comment.
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<>(); |
There was a problem hiding this comment.
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())); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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".
@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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome.
Cool. I'm happy with it. If you want to get it in now and deal with the question of |
…ll incoming and outgoing requests / responses
@nik9000 I added an AssertingTransportInterceptor so we are getting these assertions everywhere randomly! |
There was a problem hiding this 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.
test this please |
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
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.
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.
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.