zentol commented on a change in pull request #14923:
URL: https://github.com/apache/flink/pull/14923#discussion_r577043778



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/declarative/DeclarativeScheduler.java
##########
@@ -887,19 +897,22 @@ public void runIfState(State expectedState, Runnable 
action, Duration delay) {
 
     // ----------------------------------------------------------------
 
-    private void transitionToState(State newState) {
-        if (state != newState) {
-            LOG.debug(
-                    "Transition from state {} to {}.",
-                    state.getClass().getSimpleName(),
-                    newState.getClass().getSimpleName());
+    @VisibleForTesting
+    <S extends State> void transitionToState(
+            Supplier<S> stateTransition, Class<S> targetStateClass) {

Review comment:
       What exactly are you thinking of? Just some generic Pojo that you'd 
create like this:
   ```
   new StateFactory(
                   () -> new WaitingForResources(this, LOG, desiredResources, 
Duration.ofSeconds(10)),
                   WaitingForResources.class)
   ```
   
   or more like an interface with explicit implementations for each state:
   ```
   class CreatedStateFactory implements StateFactory<Created> {
   
       public Class<Created> getStateClass() { return Created.class; }
   
       // supplier variant:
       // usage: new StateFactory(() -> new WaitingForResources(this, LOG, 
desiredResources, Duration.ofSeconds(10))
       public Created getState() { return this.supplier.get(); }
   
       // constructor variant
       // usage new StateFactory(this, LOG, desiredResources, 
Duration.ofSeconds(10)
       public Created getState() { return new 
WaitingForResources(this.scheduler, this.log, this.desiredResources, 
Duration.ofSeconds(10); }
   }
   ```
   
   Overall, I'm not sold yet on either option; it feels like wed'd be adding 
code without really changing things all that much on the practical side of 
things.




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to