Commit d9d1e541 authored by Klaus Aehlig's avatar Klaus Aehlig

Add Luxi Request to pick up a job in the queue

During the transition to the new daemon layout, from step 2
onwards, luxid will write to the queue but masterd will trigger
the execution. Therefore, add a new luxi request to tell masterd
to pick up a job that has already been written to the queue.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent fcd70b89
......@@ -53,6 +53,7 @@ KEY_VERSION = "version"
REQ_SUBMIT_JOB = "SubmitJob"
REQ_SUBMIT_JOB_TO_DRAINED_QUEUE = "SubmitJobToDrainedQueue"
REQ_SUBMIT_MANY_JOBS = "SubmitManyJobs"
REQ_PICKUP_JOB = "PickupJob"
REQ_WAIT_FOR_JOB_CHANGE = "WaitForJobChange"
REQ_CANCEL_JOB = "CancelJob"
REQ_ARCHIVE_JOB = "ArchiveJob"
......@@ -78,6 +79,7 @@ REQ_ALL = compat.UniqueFrozenset([
REQ_AUTO_ARCHIVE_JOBS,
REQ_CANCEL_JOB,
REQ_CHANGE_JOB_PRIORITY,
REQ_PICKUP_JOB,
REQ_QUERY,
REQ_QUERY_CLUSTER_INFO,
REQ_QUERY_CONFIG_VALUES,
......@@ -479,6 +481,9 @@ class Client(object):
def SetWatcherPause(self, until):
return self.CallMethod(REQ_SET_WATCHER_PAUSE, (until, ))
def PickupJob(self, job):
return self.CallMethod(REQ_PICKUP_JOB, (job,))
def SubmitJob(self, ops):
ops_state = map(lambda op: op.__getstate__(), ops)
return self.CallMethod(REQ_SUBMIT_JOB, (ops_state, ))
......
......@@ -295,6 +295,11 @@ class ClientOps:
_LogNewJob(True, job_id, ops)
return job_id
elif method == luxi.REQ_PICKUP_JOB:
logging.info("Picking up new job from queue")
(job_id, ) = args
queue.PickupJob(job_id)
elif method == luxi.REQ_SUBMIT_JOB_TO_DRAINED_QUEUE:
logging.info("Forcefully receiving new job")
(job_def, ) = args
......
......@@ -163,6 +163,9 @@ $(genLuxiOp "LuxiOp"
, simpleField "prev_log" [t| JSValue |]
, simpleField "tmout" [t| Int |]
])
, (luxiReqPickupJob,
[ simpleField "job" [t| JobId |] ]
)
, (luxiReqArchiveJob,
[ simpleField "job" [t| JobId |] ]
)
......@@ -394,6 +397,9 @@ decodeCall (LuxiCall call args) =
J.readJSON e
_ -> J.Error "Not enough values"
return $ WaitForJobChange jid fields pinfo pidx wtmout
ReqPickupJob -> do
[jid] <- fromJVal args
return $ PickupJob jid
ReqArchiveJob -> do
[jid] <- fromJVal args
return $ ArchiveJob jid
......
......@@ -84,6 +84,7 @@ instance Arbitrary Luxi.LuxiOp where
Luxi.ReqWaitForJobChange -> Luxi.WaitForJobChange <$> arbitrary <*>
genFields <*> pure J.JSNull <*>
pure J.JSNull <*> arbitrary
Luxi.ReqPickupJob -> Luxi.PickupJob <$> arbitrary
Luxi.ReqArchiveJob -> Luxi.ArchiveJob <$> arbitrary
Luxi.ReqAutoArchiveJobs -> Luxi.AutoArchiveJobs <$> arbitrary <*>
arbitrary
......
......@@ -43,6 +43,7 @@ KNOWN_UNUSED_LUXI = compat.UniqueFrozenset([
luxi.REQ_ARCHIVE_JOB,
luxi.REQ_AUTO_ARCHIVE_JOBS,
luxi.REQ_CHANGE_JOB_PRIORITY,
luxi.REQ_PICKUP_JOB,
luxi.REQ_QUERY_EXPORTS,
luxi.REQ_QUERY_CONFIG_VALUES,
luxi.REQ_QUERY_NETWORKS,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment