asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Murtadha Hubail (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: [ASTERIXDB-2018][NET] Add HTTP close channel listener
Date Fri, 04 Aug 2017 12:04:00 GMT
Murtadha Hubail has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/1917

Change subject: [ASTERIXDB-2018][NET] Add HTTP close channel listener
......................................................................

[ASTERIXDB-2018][NET] Add HTTP close channel listener

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
Add a listener on HTTP channel to notify waiters when the
channel is closed.

Change-Id: I08e4890880a70d42e3e181366a5b0252102d0ea2
---
M hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/ChunkedNettyOutputStream.java
1 file changed, 9 insertions(+), 0 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/17/1917/1

diff --git a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/ChunkedNettyOutputStream.java
b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/ChunkedNettyOutputStream.java
index 6509dcc..acaad27 100644
--- a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/ChunkedNettyOutputStream.java
+++ b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/ChunkedNettyOutputStream.java
@@ -40,6 +40,12 @@
         this.response = response;
         this.ctx = ctx;
         buffer = ctx.alloc().buffer(chunkSize);
+        // register listener for channel closed
+        ctx.channel().closeFuture().addListener(futureListener -> {
+            synchronized (ChunkedNettyOutputStream.this) {
+                ChunkedNettyOutputStream.this.notifyAll();
+            }
+        });
     }
 
     @Override
@@ -121,6 +127,9 @@
         while (!ctx.channel().isWritable()) {
             try {
                 ctx.flush();
+                if (!ctx.channel().isOpen()) {
+                    throw new IOException("Closed channel");
+                }
                 wait();
             } catch (InterruptedException e) {
                 Thread.currentThread().interrupt();

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1917
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I08e4890880a70d42e3e181366a5b0252102d0ea2
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Murtadha Hubail <mhubail@apache.org>

Mime
View raw message