mjsax commented on a change in pull request #8833:
URL: https://github.com/apache/kafka/pull/8833#discussion_r438361083



##########
File path: 
streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamTask.java
##########
@@ -247,82 +246,23 @@ public void completeRestoration() {
         }
     }
 
-    /**
-     * <pre>
-     * the following order must be followed:
-     *  1. first close topology to make sure all cached records in the 
topology are processed
-     *  2. then flush the state, send any left changelog records
-     *  3. then flush the record collector
-     *  4. then commit the record collector -- for EOS this is the 
synchronization barrier
-     *  5. then checkpoint the state manager -- even if we crash before this 
step, EOS is still guaranteed
-     * </pre>
-     *
-     * @throws TaskMigratedException if committing offsets failed (non-EOS)
-     *                               or if the task producer got fenced (EOS)
-     */
-    @Override
-    public void prepareSuspend() {
-        switch (state()) {
-            case CREATED:
-            case SUSPENDED:
-                // do nothing
-                log.trace("Skip prepare suspending since state is {}", 
state());
-
-                break;
-
-            case RESTORING:
-                stateMgr.flush();
-                log.info("Prepare suspending restoring");
-
-                break;
-
-            case RUNNING:
-                closeTopology(true);
-
-                stateMgr.flush();
-                recordCollector.flush();
-
-                log.info("Prepare suspending running");
-
-                break;
-
-            case CLOSED:
-                throw new IllegalStateException("Illegal state " + state() + " 
while suspending active task " + id);
-
-            default:
-                throw new IllegalStateException("Unknown state " + state() + " 
while suspending active task " + id);
-        }
-    }
-
     @Override
     public void suspend() {
         switch (state()) {
             case CREATED:
             case SUSPENDED:
-                // do nothing
-                log.trace("Skip suspending since state is {}", state());
-
-                break;
-
-            case RUNNING:
-                stateMgr.checkpoint(checkpointableOffsets());
-                partitionGroup.clear();
-
-                transitionTo(State.SUSPENDED);
-                log.info("Suspended running");
+                log.info("Skip suspending since state is {}", state());
 
                 break;
 
             case RESTORING:
-                // we just checkpoint the position that we've restored up to 
without
-                // going through the commit process
-                stateMgr.checkpoint(emptyMap());
-
-                // we should also clear any buffered records of a task when 
suspending it
-                partitionGroup.clear();
-
-                transitionTo(State.SUSPENDED);
-                log.info("Suspended restoring");
+            case RUNNING:
+                try {
+                    closeTopology();

Review comment:
       Yes. `RESTORING` above is it's own "case" branch now (before `RUNNING` 
and `RESTORING` was shared the code).




----------------------------------------------------------------
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:
[email protected]


Reply via email to