-
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
Add NioGroup for use in different transports #27737
Conversation
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 left some comments
private void shutdownSelector(ESSelector selector) { | ||
try { | ||
selector.close(); | ||
} catch (Exception e) { |
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 might make sense to deduplicate this exception otherwise we might spam logs?
} | ||
|
||
startSelectors(socketSelectors, socketSelectorThreadFactory); | ||
|
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.
extra newlines
private final ThreadFactory socketSelectorThreadFactory; | ||
private final ArrayList<SocketSelector> socketSelectors; | ||
private final Function<Logger, SocketEventHandler> socketEventHandlerFunction; | ||
private RoundRobinSupplier<SocketSelector> socketSelectorSupplier; |
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.
can be final?
private final ThreadFactory acceptorThreadFactory; | ||
private final ArrayList<AcceptingSelector> acceptors; | ||
private final BiFunction<Logger, Supplier<SocketSelector>, AcceptorEventHandler> acceptorEventHandlerFunction; | ||
private RoundRobinSupplier<AcceptingSelector> acceptorSupplier; |
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.
can be final?
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 don't think they can be final in the current design. Creating a Selector
can throw an exception which is why I do it in start()
.
I guess the options are:
- I could make them
volatile
- I could throw
IOException
from the ctor. Although with handling exceptions and closing in the ctor.
Thoughts?
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 am leaning towards 2. it's much cleaner
import java.util.function.BiFunction; | ||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
|
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.
can you summarize what this does?
socketSelectors.clear(); | ||
} | ||
|
||
private static <S extends ESSelector> void startSelectors(Iterable<S> selectors, ThreadFactory threadFactory) { |
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.
if we fail to start do we close the started ones
@s1monw - based on your comment about making the suppliers final, I decided to put in some work relating to ensuring that the state of the |
socketSelectors = new ArrayList<>(this.socketSelectorCount); | ||
} | ||
|
||
public synchronized void start() throws IOException { |
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.
if we can prevent this kind of state handling we should. My experience with stuff like this is consistently negative so lets try to move it to the ctor and make it clear once the group is created it's ready to use. I still think we should have an ensureOpen()
method that checks a boolean if we are still open.
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.
LGTM
ensureRunning(); | ||
if (acceptorCount == 0) { | ||
ensureOpen(); | ||
if (acceptors.size() == 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.
nit: maybe us isEmpty()?
This commit is related to #27260. It adds a base NioGroup for use in different transports. This class creates and starts the underlying selectors. Different protocols or transports are established by passing the ChannelFactory to the bindServerChannel or openChannel methods. This allows a TcpChannelFactory to be passed which will create and register channels that support the elasticsearch tcp binary protocol or a channel factory that will create http channels (or other).
* es/6.x: (170 commits) Allow TrimFilter to be used in custom normalizers (#27758) recovery from snapshot should fill gaps (#27850) Remove unused class PreBuiltTokenFilters (#27839) Reject scroll query if size is 0 (#22552) (#27842) Mutes ‘Rollover no condition matched’ YAML test Make randomNonNegativeLong() draw from a uniform distribution (#27856) Adapt rest test after backport. Relates #27833 Handle case where the hole vertex is south of the containing polygon(s) (#27685) Move range field mapper back to core Fix publication of elasticsearch-cli to Maven Do not use system properties when building the HttpAsyncClient (#27829) Optimize version map for append-only indexing (#27752) Add NioGroup for use in different transports (#27737) adapt field collapsing skip test version. relates #27833 Add version support for inner hits in field collapsing (#27822) (#27833) Clarify that number of threads is set by packages Register HTTP read timeout setting Fixes Checkstyle Remove `operationThreaded` from Java API (#27836) Fixes failing BytesSizeValues tests ...
This commit is related to #27260. It adds a base
NioGroup
for use indifferent transports. This class creates and starts the underlying
selectors. Different protocols or transports are established by passing
the
ChannelFactory
to thebindServerChannel
oropenChannel
methods. This allows a
TcpChannelFactory
to be passed which willcreate and register channels that support the elasticsearch tcp binary
protocol or a channel factory that will create http channels (or other).