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

Add experimental nio-transport plugin with http #26295

Closed
wants to merge 48 commits into from

Conversation

Tim-Brooks
Copy link
Contributor

This commit adds an nio-transport plugin. It builds upon the nio
transport work in test:framework. However, it adds http functionality.
The http functionality is added by adapting a netty embedded channel.
For now, the bulk of the nio networking and tcp transport will remain in
test:framework. This allows it to be used as a tcp transport for
internal clusters.

This plugin is unique in that it depends on test:framework for the nio
work and the netty4 transport module for http (cors, pipeling, etc)
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.

I did a first pass and I think it looks pretty good as a first iteration.

@@ -245,6 +245,11 @@ public void apply(Settings value, Settings current, Settings previous) {
HttpTransportSettings.SETTING_HTTP_MAX_HEADER_SIZE,
HttpTransportSettings.SETTING_HTTP_MAX_INITIAL_LINE_LENGTH,
HttpTransportSettings.SETTING_HTTP_RESET_COOKIES,
HttpTransportSettings.SETTING_HTTP_TCP_NO_DELAY,
Copy link
Contributor

Choose a reason for hiding this comment

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

can you make the move of these settings a seperate PR. This would help to keep this one focused

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened here: #26310

@@ -39,7 +39,7 @@
import java.util.Set;
import java.util.stream.Collectors;

public class Netty4HttpRequest extends RestRequest {
class Netty4HttpRequest extends RestRequest {
Copy link
Contributor

Choose a reason for hiding this comment

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

can it also be final in that case?

import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class ESChannelPromise implements ActionListener<NioChannel>, ChannelPromise {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe leave some javadocs?

import java.util.LinkedList;
import java.util.Queue;

class ESEmbeddedChannel extends EmbeddedChannel {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you quickly explain what we are doing here?

import java.util.Map;
import java.util.function.Supplier;

public class NioPlugin extends Plugin implements NetworkPlugin {
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 should add a bootstrap check to make sure nobody uses this in production just yet? ie a check that always fails with a good explain error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a check.

((Releasable) content).close();
}
if (releaseBytesStreamOutput) {
bytesOutputOrNull().close();
Copy link
Contributor

Choose a reason for hiding this comment

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

this asks for an NPE given the title of the method? Should we maybe use mutliple try finally blocks just in case one of the close methods throws?

@Override
public Method method() {
HttpMethod httpMethod = request.method();
if (httpMethod == HttpMethod.GET)
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks like it should be a switch statement or an EnumMap?

}

@Override
public boolean isEmpty() {
Copy link
Contributor

Choose a reason for hiding this comment

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

unneeded default to size() == 0

}

@Override
public boolean containsValue(Object value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe just throw UOE?

}

final FullHttpRequest copy =
new DefaultFullHttpRequest(
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can use a single line here?

@nik9000
Copy link
Member

nik9000 commented Aug 21, 2017

It's just that, as we depend on test:framework

Is it a good idea for a production plugin to depend on the test framework? Even if it is experimental I think that is a thing we should avoid. I suppose if we have a bootstrap check to make sure no one uses it in production then we can depend on the test framework until we drop it.


dependencies {
compile project(path: ':modules:transport-netty4', configuration: 'runtime')
compile project(path: ':test:framework', 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.

What is it in the test framework needed here?

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 nio transport classes are in test:framework. Selectors, channels, etc.

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 they were going to move into this plugin?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I spoke to @s1monw about this last week, his preference was to leave the tcp version of the nio transport in test:framework for now for for testing.

@Tim-Brooks
Copy link
Contributor Author

Tim-Brooks commented Aug 29, 2017

I want to comment on this to say - I spoke to @s1monw about his suggested changes to:

  • NioHttpRequest.java
  • NioHttpChannel.java

The problem here is that these classes are just duplicates of the netty module classes (with slight modifications to make them work with nio functionality). His suggestions would also apply to the netty classes. So we decided to hold of those changes. I might submit a follow-up PR that applies these suggestions to both netty / nio.

@s1monw
Copy link
Contributor

s1monw commented Sep 18, 2017

@tbrooks8 are we ready to move here? Shall I take another look?

@Tim-Brooks
Copy link
Contributor Author

@s1monw yes. I made changes based on all your feedback that was specific for nio. I can submit a follow up PR for the changes that apply to both this and the netty module.

@Tim-Brooks Tim-Brooks requested a review from jaymode October 17, 2017 22:07
@Tim-Brooks Tim-Brooks requested a review from s1monw November 1, 2017 15:14
@Tim-Brooks
Copy link
Contributor Author

This PR has been opened for a while and I think is ready for more reviews as I have address @s1monw concerns. Although I do have a concern about how this will work.

@jasontedor I guess that when this gets merged I will put the http plugin part on 7.0 and back port the nio transport changes only to 6.X? As I think you said you wanted the plugin part on 7.0 only?

@Tim-Brooks
Copy link
Contributor Author

I don't need any reviews on this PR currently. There has been a number of changes to the various nio classes. This PR will need some conflicts resolved before it is ready to be reviewed again.

@Tim-Brooks
Copy link
Contributor Author

I am closing this PR. It is well out of date with updates to nio. I will eventually use some of this work to submit a separate PR for http.

@Tim-Brooks Tim-Brooks closed this Dec 7, 2017
@Tim-Brooks Tim-Brooks deleted the embedded_http branch November 14, 2018 14:50
@jimczi jimczi added v7.0.0-beta1 and removed v7.0.0 labels Feb 7, 2019
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 >non-issue v6.1.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants