cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [cassandra] sbtourist commented on a change in pull request #497: Cassandra 15666 trunk
Date Thu, 02 Apr 2020 15:32:47 GMT
sbtourist commented on a change in pull request #497: Cassandra 15666 trunk
URL: https://github.com/apache/cassandra/pull/497#discussion_r402407051
 
 

 ##########
 File path: src/java/org/apache/cassandra/streaming/StreamSession.java
 ##########
 @@ -156,18 +166,57 @@
     private final NettyStreamingMessageSender messageSender;
     private final ConcurrentMap<ChannelId, Channel> incomingChannels = new ConcurrentHashMap<>();
 
-    private final AtomicBoolean isAborted = new AtomicBoolean(false);
+    // "maybeCompleted()" should be executed at most once. Because it can be executed asynchronously
by IO
+    // threads(serialization/deserialization) and stream messaging processing thread, causing
connection closed before
+    // receiving peer's CompleteMessage.
+    private final AtomicBoolean maybeCompleted = new AtomicBoolean(false);
+    private final AtomicBoolean isClosed = new AtomicBoolean(false);
+    private Future closeFuture;
+
     private final UUID pendingRepair;
     private final PreviewKind previewKind;
 
+    /**
+     * State Transition:
+     *
+     * <pre>
+     *
+     *  +------------------+----------> FAILED <------------------+
+     *  |                  |              ^                       |
+     *  |                  |              |                       |
+     *  INITIALIZED --> PREPARING --> STREAMING ----------> WAIT_COMPLETE ---->
COMPLETED
+     *  |                  |                                      ^                 ^
+     *  |                  |         if preview                   |                 |
+     *  |                  +--------------------------------------+                 |
+     *  |               nothing to request or to transfer                           |
+     *  +---------------------------------------------------------------------------+
+     *                  nothing to request or to transfer
+     *
+     *  </pre>
+     */
     public enum State
     {
-        INITIALIZED,
-        PREPARING,
-        STREAMING,
-        WAIT_COMPLETE,
-        COMPLETE,
-        FAILED,
+        INITIALIZED(false),
+        PREPARING(false),
+        STREAMING(false),
+        WAIT_COMPLETE(false),
+        COMPLETE(true),
+        FAILED(true);
+
+        private final boolean finalState;
+
+        State(boolean finalState)
+        {
+            this.finalState = finalState;
+        }
+
+        /**
+         * @return true if current statu is final and cannot be change to other state.
 
 Review comment:
   Also, this doesn't seem to be actually enforced? That is, we still allow to go from a final
state to a different state.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Mime
View raw message