zwangsheng commented on code in PR #1835:
URL: 
https://github.com/apache/incubator-celeborn/pull/1835#discussion_r1304021807


##########
worker/src/main/java/org/apache/celeborn/service/deploy/worker/memory/MemoryManager.java:
##########
@@ -274,6 +240,59 @@ public ServingState currentServingState() {
     return isPaused ? ServingState.PUSH_PAUSED : ServingState.NONE_PAUSED;
   }
 
+  @VisibleForTesting
+  protected void switchServingState() {
+    ServingState lastState = servingState;
+    servingState = currentServingState();
+    if (lastState == servingState) {
+      if (servingState != ServingState.NONE_PAUSED) {
+        logger.debug("Trigger action: TRIM");
+        trimAllListeners();
+      }
+      return;
+    }
+    logger.info("Serving state transformed from {} to {}", lastState, 
servingState);
+    switch (servingState) {
+      case PUSH_PAUSED:
+        pausePushDataCounter.increment();
+        logger.info("Trigger action: PAUSE PUSH, RESUME REPLICATE");
+        if (lastState == ServingState.PUSH_AND_REPLICATE_PAUSED) {

Review Comment:
   Here and follow code, after determining the previous serving state, call 
listener method to avoid calling the method too much times, which is 
meaningless and costed (because it contains `synchronized` lock and 
`ConcurrentHashMap#KeySetView` foreach methods).
   



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to