From 2752ad536c68d637709e5dc7039a2719619a3d05 Mon Sep 17 00:00:00 2001 From: Diego Tavares Date: Thu, 20 Jun 2024 10:06:04 -0700 Subject: [PATCH] Apply review suggestions (#1387) --- .../spcue/dispatcher/AbstractDispatcher.java | 7 +------ .../imageworks/spcue/dispatcher/BookingQueue.java | 2 ++ .../spcue/dispatcher/CoreUnitDispatcher.java | 9 ++------- .../imageworks/spcue/dispatcher/DispatchSupport.java | 12 +++--------- 4 files changed, 8 insertions(+), 22 deletions(-) diff --git a/cuebot/src/main/java/com/imageworks/spcue/dispatcher/AbstractDispatcher.java b/cuebot/src/main/java/com/imageworks/spcue/dispatcher/AbstractDispatcher.java index c956071e9..687a14ce5 100644 --- a/cuebot/src/main/java/com/imageworks/spcue/dispatcher/AbstractDispatcher.java +++ b/cuebot/src/main/java/com/imageworks/spcue/dispatcher/AbstractDispatcher.java @@ -197,12 +197,7 @@ public boolean dispatchHost(DispatchFrame frame, VirtualProc proc) { public void dispatch(DispatchFrame frame, VirtualProc proc) { /* - * The frame is reserved, the proc is created, now update the frame to - * the running state. - * - * Creates a proc to run on the specified frame. Throws a - * ResourceReservationFailureException if the proc cannot be created due - * to lack of resources. + * Start frame and create proc on the database. */ dispatchSupport.startFrameAndProc(proc, frame); diff --git a/cuebot/src/main/java/com/imageworks/spcue/dispatcher/BookingQueue.java b/cuebot/src/main/java/com/imageworks/spcue/dispatcher/BookingQueue.java index 36ba8f513..6f950e327 100644 --- a/cuebot/src/main/java/com/imageworks/spcue/dispatcher/BookingQueue.java +++ b/cuebot/src/main/java/com/imageworks/spcue/dispatcher/BookingQueue.java @@ -33,6 +33,8 @@ public class BookingQueue implements QueueHealthCheck { private final int queueCapacity; private final int corePoolSize; private final int maxPoolSize; + // Base value for calculating the job sleep time + // this is used to slow down the booking queue to avoid racing conditions private static final int BASE_SLEEP_TIME_MILLIS = 300; private static final Logger logger = LogManager.getLogger("HEALTH"); diff --git a/cuebot/src/main/java/com/imageworks/spcue/dispatcher/CoreUnitDispatcher.java b/cuebot/src/main/java/com/imageworks/spcue/dispatcher/CoreUnitDispatcher.java index 6e5e229aa..e55a76865 100644 --- a/cuebot/src/main/java/com/imageworks/spcue/dispatcher/CoreUnitDispatcher.java +++ b/cuebot/src/main/java/com/imageworks/spcue/dispatcher/CoreUnitDispatcher.java @@ -360,15 +360,10 @@ public List dispatchHost(DispatchHost host, FrameInterface frame) { @Override public void dispatch(DispatchFrame frame, VirtualProc proc) { - /* - * The frame is reserved, the proc is created, now update - * the frame to the running state. - */ + // Allocate frame on the database dispatchSupport.startFrameAndProc(proc, frame); - /* - * Communicate with RQD to run the frame. - */ + // Communicate with RQD to run the frame. if (!testMode) { dispatchSupport.runFrame(proc,frame); } diff --git a/cuebot/src/main/java/com/imageworks/spcue/dispatcher/DispatchSupport.java b/cuebot/src/main/java/com/imageworks/spcue/dispatcher/DispatchSupport.java index 1b163f465..ffb4a7a34 100644 --- a/cuebot/src/main/java/com/imageworks/spcue/dispatcher/DispatchSupport.java +++ b/cuebot/src/main/java/com/imageworks/spcue/dispatcher/DispatchSupport.java @@ -168,15 +168,9 @@ boolean stopFrame(FrameInterface frame, FrameState state, int exitStatus, long maxrss); /** - * Updates the frame to the Running state. This should - * be done after RQD has accepted the frame. Setting - * the frame's state to running will result in a - * new entry in the frame_history table for the - * running frame. - * - * Reserve the resources in the specified proc for the - * specified frame. If the proc does not exist, its - * inserted, otherwise its updated. + * Updates the frame to the Running state and Reserve the resources + * in the specified proc for the specified frame. If the proc does + * not exist, its inserted, otherwise its updated. * * When a proc is created, the subscription, host, * job, layer, folder, and shot proc counts get updated.