Unverified Commit 54df5efb authored by Fabien Viale's avatar Fabien Viale Committed by GitHub
Browse files

Merge pull request #3990 from oanaBiancaSchiopu/add-signal-new-endpoint

add-signal-new-endpoint
parents f8ece9f0 3e05bbc2
......@@ -2348,10 +2348,32 @@ public interface SchedulerRestInterface {
*/
@POST
@Path("job/{jobid}/signals")
@Consumes(value = MediaType.APPLICATION_JSON)
@Consumes(value = MediaType.APPLICATION_OCTET_STREAM)
@Produces(MediaType.APPLICATION_JSON)
Set<String> addJobSignal(@HeaderParam("sessionid") String sessionId, @QueryParam("signal") String signal,
@PathParam("jobid") String jobId, Map<String, String> updatedVariables) throws RestException;
@PathParam("jobid") String jobId) throws RestException;
/**
*
* Add a signal to the list of signals used by the considered job
*
* @param sessionId
* current session
* @param jobId
* id of the job
* @param signal
* signal name to add
* @param updatedVariables
* the update variables of the signal
* @return the set of job signals associated with the given job after the addition
*/
@POST
@Path("job/{jobid}/signals")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
Set<String> addJobSignalWithVariables(@HeaderParam("sessionid") String sessionId,
@QueryParam("signal") String signal, @PathParam("jobid") String jobId, Map<String, String> updatedVariables)
throws RestException;
/**
*
......
......@@ -1523,7 +1523,7 @@ public class SchedulerClient extends ClientBase implements ISchedulerClient {
throws NotConnectedException, UnknownJobException, PermissionException, SignalApiException {
Set<String> result = new HashSet<>();
try {
result = restApi().addJobSignal(sid, signal, jobId, updatedVariables);
result = restApi().addJobSignalWithVariables(sid, signal, jobId, updatedVariables);
} catch (Exception e) {
throwSAEorUJEOrNCEOrPE(e);
}
......
......@@ -254,8 +254,8 @@ public class SchedulerStateRest implements SchedulerRestInterface {
}
@Override
public Set<String> addJobSignal(String sessionId, String signal, String jobId, Map<String, String> updatedVariables)
throws RestException {
public Set<String> addJobSignalWithVariables(String sessionId, String signal, String jobId,
Map<String, String> updatedVariables) throws RestException {
try {
Scheduler s = checkAccess(sessionId, "/scheduler/jobs/" + jobId);
return s.addJobSignal(jobId, signal, updatedVariables);
......@@ -266,6 +266,11 @@ public class SchedulerStateRest implements SchedulerRestInterface {
}
}
@Override
public Set<String> addJobSignal(String sessionId, String signal, String jobId) throws RestException {
return addJobSignalWithVariables(sessionId, signal, jobId, null);
}
@Override
public JobValidationData validateJobSignal(String sessionId, String signal, String jobId,
Map<String, String> updatedVariables) throws RestException {
......
......@@ -2119,12 +2119,14 @@ public class SchedulerFrontend implements InitActive, Scheduler, RunActive, EndA
signalsChannel + jobId,
readyPrefix + signalName);
DefaultModelJobValidatorServiceProvider validatorServiceProvider = new DefaultModelJobValidatorServiceProvider();
Map<String, Serializable> serializableUpdatedVariables = new LinkedHashMap<>(updatedVariables);
validatorServiceProvider.validateVariables(readySignal.getInputVariables(),
serializableUpdatedVariables,
this,
this);
readySignal.setUpdatedVariables(updatedVariables);
if (updatedVariables != null) {
Map<String, Serializable> serializableUpdatedVariables = new LinkedHashMap<>(updatedVariables);
validatorServiceProvider.validateVariables(readySignal.getInputVariables(),
serializableUpdatedVariables,
this,
this);
readySignal.setUpdatedVariables(updatedVariables);
}
publicStore.remove(SIGNAL_ORIGINATOR, SIGNAL_TASK_ID, signalsChannel + jobId, readyPrefix + signalName);
publicStore.put(SIGNAL_ORIGINATOR, SIGNAL_TASK_ID, signalsChannel + jobId, signalName, readySignal);
......
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