Cleaned up chaining of ChannelGroupFutures #991

Merged
merged 1 commit into from Jan 3, 2013

Projects

None yet

5 participants

@drewhk
Member
drewhk commented Jan 3, 2013

Added support to NettyFutureBridge for ChannelGroupFutures following the recommendation of Viktor.

@viktorklang
Member

LGTM! :-)

@drewhk drewhk commented on the diff Jan 3, 2013
...cala/akka/remote/transport/netty/NettyTransport.scala
@@ -41,6 +41,20 @@ object NettyFutureBridge {
})
p.future
}
+
+ def apply(nettyFuture: ChannelGroupFuture): Future[ChannelGroup] = {
+ import scala.collection.JavaConverters._
+ val p = Promise[ChannelGroup]
+ nettyFuture.addListener(new ChannelGroupFutureListener {
+ def operationComplete(future: ChannelGroupFuture): Unit = p complete Try(
+ if (future.isCompleteSuccess) future.getGroup
+ else throw future.iterator.asScala.collectFirst {
@drewhk
drewhk Jan 3, 2013 Member

Need feedback on this line. I only report the first failure in the future group, is this enough?

@viktorklang
viktorklang Jan 3, 2013 Member

Yeah, I think so

@patriknw patriknw commented on the diff Jan 3, 2013
...cala/akka/remote/transport/netty/NettyTransport.scala
- channelGroup.close().addListener(new ChannelGroupFutureListener {
- def operationComplete(future: ChannelGroupFuture) {
- inboundBootstrap.releaseExternalResources()
- }
- })
- }
- })
- }
- })
+ def always(c: ChannelGroupFuture) = NettyFutureBridge(c) recover { case _ c.getGroup }
+ for {
+ // Force flush by trying to write an empty buffer and wait for success
+ _ always(channelGroup.write(ChannelBuffers.buffer(0)))
+ _ always({ channelGroup.unbind(); channelGroup.disconnect() })
+ _ always(channelGroup.close())
+ } inboundBootstrap.releaseExternalResources()
@patriknw
Member
patriknw commented Jan 3, 2013

LGTM

@rkuhn
Collaborator
rkuhn commented Jan 3, 2013

LGTM

@viktorklang
Member

You can merge this

@drewhk
Member
drewhk commented Jan 3, 2013

No build kitteh?

@viktorklang
Member

hmmm, the build kitteh hasn't run in 5h?? Sounds like a problem to me

@viktorklang
Member

PLS REBUILD ALL

@akka-ci
Member
akka-ci commented Jan 3, 2013

Started jenkins job akka-pr-validator at https://jenkins.akka.io/job/akka-pr-validator/268/

@akka-ci
Member
akka-ci commented Jan 3, 2013

jenkins job akka-pr-validator: Success - https://jenkins.akka.io/job/akka-pr-validator/268/

@drewhk drewhk merged commit 3ceb02f into akka:master Jan 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment