refs #508: Support Config File to run task at service startup
https://support.d4science.org/issues/508 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/vre-management/smart-executor-api@117748 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4dc31c4eb1
commit
888ce28828
|
@ -18,19 +18,19 @@ import org.gcube.vremanagement.executor.api.types.adapter.MapAdapter;
|
|||
*/
|
||||
@XmlRootElement()
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class LaunchParameter {
|
||||
public class LaunchParameter implements Comparable<LaunchParameter> {
|
||||
|
||||
@XmlElement
|
||||
private String pluginName;
|
||||
protected String pluginName;
|
||||
|
||||
@XmlJavaTypeAdapter(MapAdapter.class)
|
||||
private Map<String, Object> inputs;
|
||||
|
||||
|
||||
private Scheduling scheduling;
|
||||
protected Map<String, Object> inputs;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private LaunchParameter(){}
|
||||
protected Scheduling scheduling;
|
||||
|
||||
protected boolean persist;
|
||||
|
||||
protected LaunchParameter(){}
|
||||
|
||||
/**
|
||||
* @param pluginName
|
||||
|
@ -39,8 +39,22 @@ public class LaunchParameter {
|
|||
public LaunchParameter(String pluginName, Map<String, Object> inputs) {
|
||||
this.pluginName = pluginName;
|
||||
this.inputs = inputs;
|
||||
this.persist = false;
|
||||
this.scheduling = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @param inputs
|
||||
* @param persist
|
||||
*/
|
||||
public LaunchParameter(String pluginName, Map<String, Object> inputs, boolean persist) {
|
||||
this.pluginName = pluginName;
|
||||
this.inputs = inputs;
|
||||
this.persist = persist;
|
||||
this.scheduling = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @param inputs
|
||||
|
@ -49,6 +63,20 @@ public class LaunchParameter {
|
|||
public LaunchParameter(String pluginName, Map<String, Object> inputs, Scheduling scheduling) {
|
||||
this.pluginName = pluginName;
|
||||
this.inputs = inputs;
|
||||
this.persist = false;
|
||||
this.scheduling = scheduling;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @param inputs
|
||||
* @param persist
|
||||
* @param scheduling
|
||||
*/
|
||||
public LaunchParameter(String pluginName, Map<String, Object> inputs, boolean persist, Scheduling scheduling) {
|
||||
this.pluginName = pluginName;
|
||||
this.inputs = inputs;
|
||||
this.persist = persist;
|
||||
this.scheduling = scheduling;
|
||||
}
|
||||
|
||||
|
@ -95,4 +123,31 @@ public class LaunchParameter {
|
|||
this.getClass().getSimpleName(), scheduling, inputs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the persist
|
||||
*/
|
||||
public boolean isPersist() {
|
||||
return persist;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param persist the persist to set
|
||||
*/
|
||||
public void setPersist(boolean persist) {
|
||||
this.persist = persist;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(LaunchParameter launchParameter) {
|
||||
int compare = pluginName.compareTo(launchParameter.pluginName);
|
||||
if(compare!=0){
|
||||
return pluginName.compareTo(launchParameter.pluginName);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,23 +19,34 @@ public class Scheduling {
|
|||
* CRON like expression for a repetitive task.
|
||||
* This field is not valid when using delay
|
||||
*/
|
||||
private String cronExpression;
|
||||
protected String cronExpression;
|
||||
|
||||
@XmlElement
|
||||
/**
|
||||
* Delay between subsequent execution in seconds.
|
||||
* This field is not valid when using cronExpression
|
||||
*/
|
||||
private Integer delay;
|
||||
|
||||
protected Integer delay;
|
||||
|
||||
@XmlElement
|
||||
/**
|
||||
* Indicates the number of times the scheduling pattern must be applied.
|
||||
* 0 means indefinitely.
|
||||
*/
|
||||
private int schedulingTimes;
|
||||
protected int schedulingTimes;
|
||||
|
||||
@XmlElement
|
||||
/**
|
||||
* The first instant when the scheduling can start
|
||||
*/
|
||||
protected Long firstStartTime; // O or null means immediately
|
||||
|
||||
/**
|
||||
* Time at which the Trigger will no longer fire even if it's schedule
|
||||
* has remaining repeats.
|
||||
*/
|
||||
@XmlElement
|
||||
protected Long endTime; // O or null means never
|
||||
|
||||
@XmlElement
|
||||
/**
|
||||
|
@ -45,22 +56,10 @@ public class Scheduling {
|
|||
* The discarded execution is counted in the total number of executions
|
||||
* happened.
|
||||
*/
|
||||
private boolean previuosExecutionsMustBeCompleted;
|
||||
protected boolean previuosExecutionsMustBeCompleted;
|
||||
|
||||
@XmlElement
|
||||
/**
|
||||
* The first instant when the scheduling can start
|
||||
*/
|
||||
private Long firstStartTime; // O or null means immediately
|
||||
|
||||
/**
|
||||
* Time at which the Trigger will no longer fire even if it's schedule
|
||||
* has remaining repeats.
|
||||
*/
|
||||
@XmlElement
|
||||
private Long endTime; // O or null means never
|
||||
|
||||
private void init(CronExpression cronExpression, Integer delay, int schedulingTimes, Long firstStartTime, Long endTime, boolean previuosExecutionsMustBeCompleted){
|
||||
protected void init(CronExpression cronExpression, Integer delay, int schedulingTimes, Long firstStartTime, Long endTime, boolean previuosExecutionsMustBeCompleted){
|
||||
if(cronExpression!=null){
|
||||
this.cronExpression = cronExpression.getCronExpression();
|
||||
}else{
|
||||
|
@ -74,6 +73,8 @@ public class Scheduling {
|
|||
}
|
||||
|
||||
|
||||
protected Scheduling(){}
|
||||
|
||||
public Scheduling(CronExpression cronExpression) {
|
||||
init(cronExpression, null, 0, null, null, false);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue