You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2020/04/02 15:32:47 UTC

[GitHub] [cassandra] sbtourist commented on a change in pull request #497: Cassandra 15666 trunk

sbtourist commented on a change in pull request #497: Cassandra 15666 trunk
URL: https://github.com/apache/cassandra/pull/497#discussion_r402406186
 
 

 ##########
 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:
   nit: `statu` -> `status`, `change` -> `changed`.

----------------------------------------------------------------
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