Skip to content

Conversation

@Tim-Brooks
Copy link
Contributor

This is related to #27260. This commit moves the NioTransport from
:test:framework to a new nio-transport plugin. Additionally, supporting
tcp decoding classes are moved to this plugin. Generic byte reading and
writing contexts are moved to the nio library.

Additionally, this commit adds a basic MockNioTransport to
:test:framework that is a TcpTransport implementation for testing that
is driven by nio.

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

I reviewed the gradle/plugin side.

compileTestJava.options.compilerArgs << "-Xlint:-rawtypes,-unchecked"

dependencies {
compile project(path: ':libs:elasticsearch-nio', configuration: 'runtime')
Copy link
Member

Choose a reason for hiding this comment

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

Is the plan to publish the nio jar (since it is used by the test framework, and may be used by the rest client in the future)? If so, the pattern we have used in the rest of the build is to setup a project substitution, and use maven coordinates here.

@Override
public Settings additionalSettings() {
final Settings.Builder settingsBuilder = Settings.builder();
settingsBuilder.put(NetworkModule.TRANSPORT_TYPE_KEY, NIO_TRANSPORT_NAME);
Copy link
Member

Choose a reason for hiding this comment

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

For the cloud plugins, we decided against "auto configuring" like this, since if there are multiple plugins trying to set themselves as an implementation, the last one loaded wins.

Copy link
Contributor

@s1monw s1monw left a comment

Choose a reason for hiding this comment

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

I left some qustions


@FunctionalInterface
interface ReadConsumer {

Copy link
Contributor

Choose a reason for hiding this comment

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

extra newlines?

public class NioNotEnabledBootstrapCheck implements BootstrapCheck {

@Override
public BootstrapCheckResult check(BootstrapContext context) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I love that!

serverAcceptedChannel((TcpChannel) channel);
}

private static BytesReference toBytesReference(InboundChannelBuffer channelBuffer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add a utilitiy that is shared for this somehow, does it make sense?

return new CompositeBytesReference(references);
}

private class MockTcpChannelFactory extends ChannelFactory<MockServerChannel, MockSocketChannel> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can extract this into a common place. maybe we just have utility methods there that we call. but I would love to reduce the footprint of this class here. I am ok with delegating but it should be mostly shared. We might be able to pass in factories for MockSocketChannel?

@Tim-Brooks Tim-Brooks requested a review from s1monw January 4, 2018 22:55
@Tim-Brooks
Copy link
Contributor Author

@s1monw I made a number of changes based on your comments. I pulled quite a bit of duplicate decoding work into TcpTransport. NioTransport, MockNioTransport, and MockTcpTransport should all use this work. Netty4Transport uses some of it. But it has to have a slightly different code path due to the distinction between decode and read in netty handlers.

Copy link
Contributor

@s1monw s1monw left a comment

Choose a reason for hiding this comment

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

this looks great! thanks for the extra iteration

/**
* Returns an array of byte buffers from the given BytesReference.
*/
public static BytesReference fromByteBuffers(ByteBuffer[] buffers) {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@Tim-Brooks Tim-Brooks merged commit 38701fb into elastic:master Jan 5, 2018
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jan 6, 2018
* master: (25 commits)
  Remove Gradle cheatsheet
  Fix reproduction info to point to Gradle wrapper
  Update platforms tests to use Gradle wrapper
  Update testing docs to reflect Gradle wrapper
  Painless: Modify Loader to Load Classes Directly from Definition (elastic#28088)
  Update contributing docs to use the Gradle wrapper
  Create nio-transport plugin for NioTransport (elastic#27949)
  test: replaced try-catch statements with expectThrows(...)
  Add getWarmer and getTranslog method to NodeIndicesStats (elastic#28092)
  fix doc mistake
  Added ASN support for Ingest GeoIP plugin.
  Fix global aggregation that requires breadth first and scores (elastic#27942)
  Introduce Gradle wrapper
  Ignore GIT_COMMIT when calculating commit hash
  Re-enable bwc tests after elastic#27881 was backported
  Set the elasticsearch-nio codebase for tests (elastic#28067)
  Bump compat version for local depdendent test to 6.2.0
  Pass `java.locale.providers=COMPAT` to Java 9 onwards (elastic#28080)
  Allow shrinking of indices from a previous major (elastic#28076)
  Remove deprecated exceptions (elastic#28059)
  ...
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jan 6, 2018
* master:
  Remove Gradle cheatsheet
  Fix reproduction info to point to Gradle wrapper
  Update platforms tests to use Gradle wrapper
  Update testing docs to reflect Gradle wrapper
  Painless: Modify Loader to Load Classes Directly from Definition (elastic#28088)
  Update contributing docs to use the Gradle wrapper
  Create nio-transport plugin for NioTransport (elastic#27949)
jasontedor added a commit that referenced this pull request Jan 6, 2018
* master:
  Remove out-of-date projectile file
  Remove Gradle cheatsheet
  Fix reproduction info to point to Gradle wrapper
  Update platforms tests to use Gradle wrapper
  Update testing docs to reflect Gradle wrapper
  Painless: Modify Loader to Load Classes Directly from Definition (#28088)
  Update contributing docs to use the Gradle wrapper
  Create nio-transport plugin for NioTransport (#27949)
  test: replaced try-catch statements with expectThrows(...)
  Add getWarmer and getTranslog method to NodeIndicesStats (#28092)
  fix doc mistake
  Added ASN support for Ingest GeoIP plugin.
  Fix global aggregation that requires breadth first and scores (#27942)
@Tim-Brooks Tim-Brooks deleted the add_plugin branch December 10, 2018 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed Coordination/Network Http and internode communication implementations >enhancement v7.0.0-beta1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants