Skip to content

Conversation

@Tim-Brooks
Copy link
Contributor

Right now we use a custom future for the CloseFuture associated with a
channel. This is because we need special unwrapping logic to ensure that
exceptions from a future failure are a certain type (opposed to an
UncategorizedException). However, the current version is limiting
because we can only attach one listener.

This commit changes the CloseFuture to extend the
PlainListenableActionFuture. This change allows us to attach multiple
listeners.

Right now we use a custom future for the CloseFuture associated with a
channel. This is because we need special unwrapping logic to ensure that
exceptions from a future failure are a certain type (opposed to an
UncategorizedException). However, the current version is limiting
because we can only attach one listener.

This commit changes the CloseFuture to extend the
PlainListenableActionFuture. This change allows us to attach multiple
listeners.
@Tim-Brooks Tim-Brooks requested a review from s1monw August 16, 2017 15:32
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.

left a comment or two


import java.util.function.Consumer;

public class ChannelConsumerAdaptor implements ActionListener<NioChannel> {
Copy link
Contributor

Choose a reason for hiding this comment

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

can this be pkg private and final?

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm can't we do:

NioChannel channel = ...;
Consumer<NioChannel> consumer = ...;
ActionListener<NioChannel> insteadOfAdaptor = ActionListener.wrap(consumer, e -> consumer.accept(channel));

instead of having this adaptor class?

@Tim-Brooks
Copy link
Contributor Author

@s1monw

I explored this:

NioChannel channel = ...;
Consumer<NioChannel> consumer = ...;
ActionListener<NioChannel> insteadOfAdaptor = ActionListener.wrap(consumer, e -> consumer.accept(channel));

The fact that ActionListenter.wrap takes a CheckedConsumer was causing a lot of problems for me. For example if I changed the listened to a CheckConsumer, that broke using it as the onError Consumer because that is just a Consumer. I added ActionListener.wrap that takes a single Runnable and runs it in case of success or failure and that fits my needs. Is that a suitable solution?

@Tim-Brooks
Copy link
Contributor Author

Simon pointed out to me on Slack that I could pass the reference as consumer::accept as a CheckedConsumer. So I went with that approach and removed the Runnable work.

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.

LGTM

@Tim-Brooks Tim-Brooks merged commit 5d7a78f into elastic:master Aug 18, 2017
Tim-Brooks added a commit that referenced this pull request Nov 8, 2017
Right now we use a custom future for the CloseFuture associated with a
channel. This is because we need special unwrapping logic to ensure that
exceptions from a future failure are a certain type (opposed to an
UncategorizedException). However, the current version is limiting
because we can only attach one listener.

This commit changes the CloseFuture to extend the
PlainListenableActionFuture. This change allows us to attach multiple
listeners.
jasontedor added a commit that referenced this pull request Nov 9, 2017
* 6.x:
  Update Tika version to 1.15
  Introduce templating support to timezone/locale in DateProcessor (#27089)
  Increase logging on qa:mixed-cluster tests
  Update to AWS SDK 1.11.223 (#27278)
  Improve error message for parse failures of completion fields (#27297)
  Remove optimisations to reuse objects when applying a new `ClusterState` (#27317)
  Decouple `ChannelFactory` from Tcp classes (#27286)
  Use PlainListenableActionFuture for CloseFuture (#26242)
  Fix find remote when building BWC
  Remove colons from task and configuration names
  Fix snapshot getting stuck in INIT state (#27214)
  Snapshot/Restore: better handle incorrect chunk_size settings in FS repo (#26844)
  Add unreleased 5.6.5 version number
  testCreateSplitIndexToN: do not set `routing_partition_size` to >= `number_of_routing_shards`
  Correct comment in index shard test
  Roll translog generation on primary promotion
  ObjectParser: Replace IllegalStateException with ParsingException (#27302)
  scripted_metric _agg parameter disappears if params are provided (#27159)
  Update discovery-ec2.asciidoc
@Tim-Brooks Tim-Brooks deleted the listenable_future branch November 14, 2018 14:50
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.

3 participants