Merged from private branch before release 4.3.0
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/vre-management/smart-executor-api@141988 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f6347d5af3
commit
bdcfc24250
|
@ -1,7 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE xml>
|
||||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.vre-management.smart-executor-api.1.4.0" date="${buildDate}">
|
||||
<Changeset component="org.gcube.vre-management.smart-executor-api.1.5.0" date="${buildDate}">
|
||||
<Change></Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.vre-management.smart-executor-api.1.4.0" date="2016-11-07">
|
||||
<Change>SmartExecutor has been passed to Authorization 2.0 (refs #4944 #2112)</Change>
|
||||
<Change>Provided to plugins the possibility to specify progress percentage (refs #440)</Change>
|
||||
<Change>Provided to plugins the possibility to define a custom notifier (refs #5089)</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.vre-management.smart-executor-api.1.3.0" date="2016-02-08">
|
||||
<Change>Using Persistence (CouchDB) to save Scheduled Task configuration (refs #579)</Change>
|
||||
<Change>Added Unscheduling feature for repetitive task (refs #521)</Change>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<assembly
|
||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
|
||||
<id>servicearchive</id>
|
||||
<formats>
|
||||
<format>tar.gz</format>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE xml>
|
||||
<Resource>
|
||||
<ID></ID>
|
||||
<Type>Service</Type>
|
||||
|
|
23
pom.xml
23
pom.xml
|
@ -9,7 +9,7 @@
|
|||
|
||||
<groupId>org.gcube.vremanagement</groupId>
|
||||
<artifactId>smart-executor-api</artifactId>
|
||||
<version>1.4.0-SNAPSHOT</version>
|
||||
<version>1.5.0-SNAPSHOT</version>
|
||||
<description>Smart Executor Service API Library</description>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
@ -34,6 +34,13 @@
|
|||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.information-system</groupId>
|
||||
<artifactId>information-system-bom</artifactId>
|
||||
<version>LATEST</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
@ -53,6 +60,20 @@
|
|||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Test Dependency -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.gcube.vremanagement.executor.plugin.PluginStateEvolution;
|
|||
|
||||
/**
|
||||
* Service Endpoint Interface
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@WebService(serviceName = SmartExecutor.WEB_SERVICE_SERVICE_NAME, targetNamespace=SmartExecutor.TARGET_NAMESPACE)
|
||||
@SOAPBinding(style = Style.DOCUMENT, use=Use.LITERAL)
|
||||
|
|
|
@ -17,28 +17,31 @@ import org.gcube.vremanagement.executor.plugin.PluginStateNotification;
|
|||
import org.gcube.vremanagement.executor.utils.MapCompare;
|
||||
import org.gcube.vremanagement.executor.utils.ObjectCompare;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@XmlRootElement()
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property=Scheduling.CLASS_PROPERTY)
|
||||
public class LaunchParameter implements Comparable<LaunchParameter> {
|
||||
|
||||
@XmlElement
|
||||
/**
|
||||
* The name of the plugin to launch
|
||||
*/
|
||||
@XmlElement
|
||||
protected String pluginName;
|
||||
|
||||
@XmlElement
|
||||
|
||||
/**
|
||||
* The version of the plugin to launch. Version can be null, this means
|
||||
* that no specific version is required. In other words, null means any
|
||||
* version.
|
||||
*/
|
||||
@XmlElement
|
||||
protected String pluginVersion;
|
||||
|
||||
@XmlJavaTypeAdapter(MapAdapter.class)
|
||||
/**
|
||||
* The Plugin Capabilities which has to be satisfied to launch the
|
||||
* plugin instance execution. The SmartExectuor Service check that this
|
||||
|
@ -49,31 +52,39 @@ public class LaunchParameter implements Comparable<LaunchParameter> {
|
|||
* be satisfied. In other words, null means that no constraint are required
|
||||
* to launch the execution
|
||||
*/
|
||||
@XmlJavaTypeAdapter(MapAdapter.class)
|
||||
protected Map<String, String> pluginCapabilities;
|
||||
|
||||
@XmlJavaTypeAdapter(MapAdapter.class)
|
||||
/**
|
||||
* Inputs to provide to the plugin instance which have to be executed.
|
||||
*/
|
||||
@XmlJavaTypeAdapter(MapAdapter.class)
|
||||
protected Map<String, Object> inputs;
|
||||
|
||||
|
||||
@XmlJavaTypeAdapter(MapAdapter.class)
|
||||
/**
|
||||
* Plugin State Notification to be used and inputs to be provided
|
||||
* when instantiated
|
||||
*/
|
||||
protected Map<String, Map<String, String>> pluginStateNotificationWithParameters;
|
||||
@XmlJavaTypeAdapter(MapAdapter.class)
|
||||
protected Map<String, Map<String, String>> pluginStateNotifications;
|
||||
|
||||
|
||||
@XmlElement
|
||||
/**
|
||||
* Scheduling parameters. See {#Scheduling} for further details
|
||||
*/
|
||||
@XmlElement
|
||||
protected Scheduling scheduling;
|
||||
|
||||
protected LaunchParameter(){}
|
||||
|
||||
public LaunchParameter(LaunchParameter launchParameter){
|
||||
this.pluginName = launchParameter.pluginName;
|
||||
this.pluginVersion = launchParameter.pluginVersion;
|
||||
this.pluginCapabilities = launchParameter.pluginCapabilities;
|
||||
this.inputs = launchParameter.inputs;
|
||||
this.scheduling = launchParameter.scheduling;
|
||||
this.pluginStateNotifications = launchParameter.pluginStateNotifications;
|
||||
}
|
||||
|
||||
public LaunchParameter(String pluginName, Map<String, Object> inputs) {
|
||||
this(pluginName, null, null, inputs, null);
|
||||
}
|
||||
|
@ -96,7 +107,7 @@ public class LaunchParameter implements Comparable<LaunchParameter> {
|
|||
this.pluginCapabilities = pluginCapabilities;
|
||||
this.inputs = inputs;
|
||||
this.scheduling = scheduling;
|
||||
this.pluginStateNotificationWithParameters = new HashMap<>();
|
||||
this.pluginStateNotifications = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -142,24 +153,33 @@ public class LaunchParameter implements Comparable<LaunchParameter> {
|
|||
}
|
||||
|
||||
public void addPluginStateNotifications(Class<? extends PluginStateNotification> pluginStateNotification, Map<String, String> inputs){
|
||||
this.pluginStateNotificationWithParameters.put(pluginStateNotification.getName(), inputs);
|
||||
this.pluginStateNotifications.put(pluginStateNotification.getName(), inputs);
|
||||
}
|
||||
|
||||
public Map<String, Map<String, String>> getPluginStateNotifications(){
|
||||
return this.pluginStateNotificationWithParameters;
|
||||
return this.pluginStateNotifications;
|
||||
}
|
||||
|
||||
public void setPluginStateNotifications(Map<String, Map<String, String>> pluginStateNotifications) {
|
||||
this.pluginStateNotifications = pluginStateNotifications;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return String.format(
|
||||
"%s : "
|
||||
+ "{ Plugin : { Name: %s - Version : %s - Capabilites : %s} - "
|
||||
+ "Scheduling : {%s} - Inputs : %s - "
|
||||
+ "Notifications With Inputs : %s}",
|
||||
this.getClass().getSimpleName(),
|
||||
pluginName, pluginVersion, pluginCapabilities,
|
||||
scheduling, inputs,
|
||||
pluginStateNotificationWithParameters);
|
||||
return String.format("{"
|
||||
+ "pluginName:%s,"
|
||||
+ "pluginVersion:%s,"
|
||||
+ "pluginCapabilities:%s,"
|
||||
+ "scheduling:%s,"
|
||||
+ "inputs:%s,"
|
||||
+ "pluginStateNotifications:%s"
|
||||
+ "}",
|
||||
pluginName,
|
||||
pluginVersion,
|
||||
pluginCapabilities,
|
||||
scheduling,
|
||||
inputs,
|
||||
pluginStateNotifications);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
@ -13,13 +13,18 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
import org.gcube.vremanagement.executor.utils.ObjectCompare;
|
||||
import org.quartz.CronExpression;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@XmlRootElement()
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property=Scheduling.CLASS_PROPERTY)
|
||||
public class Scheduling implements Comparable<Scheduling> {
|
||||
|
||||
public static final String CLASS_PROPERTY = "@class";
|
||||
|
||||
/**
|
||||
* CRON like expression for a repetitive task.
|
||||
* This field is not valid when using delay
|
||||
|
@ -64,14 +69,15 @@ public class Scheduling implements Comparable<Scheduling> {
|
|||
@XmlElement
|
||||
protected boolean previuosExecutionsMustBeCompleted;
|
||||
|
||||
@XmlElement
|
||||
/**
|
||||
* Indicate if the Scheduled Task has to be take in charge from another
|
||||
* SmartExecutor instance if the initial one die.
|
||||
*/
|
||||
protected Boolean global;
|
||||
@XmlElement
|
||||
protected boolean global;
|
||||
|
||||
protected void init(CronExpression cronExpression, Integer delay, int schedulingTimes, Long firstStartTime, Long endTime, boolean previuosExecutionsMustBeCompleted, Boolean global){
|
||||
|
||||
protected void init(CronExpression cronExpression, Integer delay, int schedulingTimes, Long firstStartTime, Long endTime, boolean previuosExecutionsMustBeCompleted, boolean global){
|
||||
if(cronExpression!=null){
|
||||
this.cronExpression = cronExpression.getCronExpression();
|
||||
}else{
|
||||
|
@ -88,63 +94,51 @@ public class Scheduling implements Comparable<Scheduling> {
|
|||
protected Scheduling(){}
|
||||
|
||||
public Scheduling(CronExpression cronExpression) {
|
||||
// TODO Set global to false when LaunchParameter.persist will be removed
|
||||
init(cronExpression, null, 0, null, null, false, null);
|
||||
init(cronExpression, null, 0, null, null, false, false);
|
||||
}
|
||||
|
||||
public Scheduling(CronExpression cronExpression, boolean previuosExecutionsMustBeCompleted) {
|
||||
// TODO Set global to false when LaunchParameter.persist will be removed
|
||||
init(cronExpression, null, 0, null, null, previuosExecutionsMustBeCompleted, null);
|
||||
init(cronExpression, null, 0, null, null, previuosExecutionsMustBeCompleted, false);
|
||||
}
|
||||
|
||||
public Scheduling(CronExpression cronExpression, int schedulingTimes) {
|
||||
// TODO Set global to false when LaunchParameter.persist will be removed
|
||||
init(cronExpression, null, schedulingTimes, null, null, false, null);
|
||||
init(cronExpression, null, schedulingTimes, null, null, false, false);
|
||||
}
|
||||
|
||||
public Scheduling(CronExpression cronExpression, int schedulingTimes, boolean previuosExecutionsMustBeCompleted ) {
|
||||
// TODO Set global to false when LaunchParameter.persist will be removed
|
||||
init(cronExpression, null, schedulingTimes, null, null, previuosExecutionsMustBeCompleted, null);
|
||||
init(cronExpression, null, schedulingTimes, null, null, previuosExecutionsMustBeCompleted, false);
|
||||
}
|
||||
|
||||
public Scheduling(CronExpression cronExpression, int schedulingTimes, Calendar firstStartTime, Calendar endTime) {
|
||||
// TODO Set global to false when LaunchParameter.persist will be removed
|
||||
init(cronExpression, null, schedulingTimes, firstStartTime.getTimeInMillis(), endTime.getTimeInMillis(), false, null);
|
||||
init(cronExpression, null, schedulingTimes, firstStartTime.getTimeInMillis(), endTime.getTimeInMillis(), false, false);
|
||||
}
|
||||
|
||||
public Scheduling(CronExpression cronExpression, int schedulingTimes, Calendar firstStartTime, Calendar endTime, boolean previuosExecutionsMustBeCompleted) {
|
||||
// TODO Set global to false when LaunchParameter.persist will be removed
|
||||
init(cronExpression, null, schedulingTimes, firstStartTime.getTimeInMillis(), endTime.getTimeInMillis(), previuosExecutionsMustBeCompleted, null);
|
||||
init(cronExpression, null, schedulingTimes, firstStartTime.getTimeInMillis(), endTime.getTimeInMillis(), previuosExecutionsMustBeCompleted, false);
|
||||
}
|
||||
|
||||
public Scheduling(int delay) {
|
||||
// TODO Set global to false when LaunchParameter.persist will be removed
|
||||
init(null, delay, 0, null, null, false, null);
|
||||
init(null, delay, 0, null, null, false, false);
|
||||
}
|
||||
|
||||
public Scheduling(int delay, boolean previuosExecutionsMustBeCompleted) {
|
||||
// TODO Set global to false when LaunchParameter.persist will be removed
|
||||
init(null, delay, 0, null, null, previuosExecutionsMustBeCompleted, null);
|
||||
init(null, delay, 0, null, null, previuosExecutionsMustBeCompleted, false);
|
||||
}
|
||||
|
||||
public Scheduling(int delay, int schedulingTimes) {
|
||||
// TODO Set global to false when LaunchParameter.persist will be removed
|
||||
init(null, delay, schedulingTimes, null, null, false, null);
|
||||
init(null, delay, schedulingTimes, null, null, false, false);
|
||||
}
|
||||
|
||||
public Scheduling(int delay, int schedulingTimes, boolean previuosExecutionsMustBeCompleted ) {
|
||||
// TODO Set global to false when LaunchParameter.persist will be removed
|
||||
init(null, delay, schedulingTimes, null, null, previuosExecutionsMustBeCompleted, null);
|
||||
init(null, delay, schedulingTimes, null, null, previuosExecutionsMustBeCompleted, false);
|
||||
}
|
||||
|
||||
public Scheduling(int delay, int schedulingTimes, Calendar firstStartTime, Calendar endTime) {
|
||||
// TODO Set global to false when LaunchParameter.persist will be removed
|
||||
init(null, delay, schedulingTimes, firstStartTime.getTimeInMillis(), endTime.getTimeInMillis(), false, null);
|
||||
init(null, delay, schedulingTimes, firstStartTime.getTimeInMillis(), endTime.getTimeInMillis(), false, false);
|
||||
}
|
||||
|
||||
public Scheduling(int delay, int schedulingTimes, Calendar firstStartTime, Calendar endTime, boolean previuosExecutionsMustBeCompleted) {
|
||||
// TODO Set global to false when LaunchParameter.persist will be removed
|
||||
init(null, delay, schedulingTimes, firstStartTime.getTimeInMillis(), endTime.getTimeInMillis(), previuosExecutionsMustBeCompleted, null);
|
||||
init(null, delay, schedulingTimes, firstStartTime.getTimeInMillis(), endTime.getTimeInMillis(), previuosExecutionsMustBeCompleted, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -175,13 +169,6 @@ public class Scheduling implements Comparable<Scheduling> {
|
|||
return previuosExecutionsMustBeCompleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the firtStartTime
|
||||
*/
|
||||
public Long getFirtStartTime() {
|
||||
return firstStartTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the firstStartTime
|
||||
*/
|
||||
|
@ -207,10 +194,6 @@ public class Scheduling implements Comparable<Scheduling> {
|
|||
* @return the global
|
||||
*/
|
||||
public Boolean getGlobal() {
|
||||
// TODO Remove if when LaunchParameter.persist will be removed
|
||||
if(global==null){
|
||||
return false;
|
||||
}
|
||||
return global;
|
||||
}
|
||||
|
||||
|
@ -222,9 +205,22 @@ public class Scheduling implements Comparable<Scheduling> {
|
|||
}
|
||||
|
||||
public String toString(){
|
||||
return String.format("CronExpression %s, Delay %d, SchedulingTimes %d, FirstStartTime %d, EndTime %d, PreviuosExecutionsMustBeCompleted %b, Global %b",
|
||||
cronExpression, delay, schedulingTimes, firstStartTime,
|
||||
endTime, previuosExecutionsMustBeCompleted, global);
|
||||
return String.format("{"
|
||||
+ "cronExpression:%s,"
|
||||
+ "delay:%d,"
|
||||
+ "schedulingTimes:%d,"
|
||||
+ "firstStartTime:%d,"
|
||||
+ "endTime:%d,"
|
||||
+ "previuosExecutionsMustBeCompleted:%b,"
|
||||
+ "global:%b"
|
||||
+ "}",
|
||||
cronExpression,
|
||||
delay,
|
||||
schedulingTimes,
|
||||
firstStartTime,
|
||||
endTime,
|
||||
previuosExecutionsMustBeCompleted,
|
||||
global);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}} */
|
||||
|
@ -258,6 +254,9 @@ public class Scheduling implements Comparable<Scheduling> {
|
|||
}
|
||||
|
||||
compareResult = new ObjectCompare<Boolean>().compare(new Boolean(previuosExecutionsMustBeCompleted), new Boolean(scheduling.previuosExecutionsMustBeCompleted));
|
||||
if(compareResult!=0){
|
||||
return compareResult;
|
||||
}
|
||||
|
||||
return new ObjectCompare<Boolean>().compare(new Boolean(global), new Boolean(scheduling.global));
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import javax.xml.ws.WebFault;
|
|||
import org.gcube.vremanagement.executor.exception.beans.ExceptionBean;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
@WebFault
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.gcube.vremanagement.executor.exception.beans.ExceptionBean;
|
|||
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
@WebFault
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.gcube.vremanagement.executor.exception.beans.ExceptionBean;
|
|||
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
@WebFault
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
package org.gcube.vremanagement.executor.exception;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public class InvalidPluginStateEvolutionException extends Exception {
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.gcube.vremanagement.executor.exception.beans.ExceptionBean;
|
|||
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
@WebFault
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.gcube.vremanagement.executor.exception.beans.ExceptionBean;
|
|||
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
@WebFault
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.gcube.vremanagement.executor.exception.beans.ExceptionBean;
|
|||
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
@WebFault
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.gcube.vremanagement.executor.exception.beans.ExceptionBean;
|
|||
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
@WebFault
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.gcube.vremanagement.executor.exception.beans.ExceptionBean;
|
|||
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
@WebFault
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.gcube.vremanagement.executor.plugin.PluginState;
|
|||
|
||||
/**
|
||||
* This class is used to persist the execution state
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class Persistence<P extends PersistenceConnector> {
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.gcube.vremanagement.executor.plugin.PluginStateNotification;
|
|||
|
||||
/**
|
||||
* Model the connector which create or open the connection to DB
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class PersistenceConnector extends PluginStateNotification {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
package org.gcube.vremanagement.executor.plugin;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public interface PercentageSetter {
|
||||
|
|
|
@ -1,19 +1,34 @@
|
|||
package org.gcube.vremanagement.executor.plugin;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This interface represent the contract for a plugin runnable by the executor.
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public abstract class Plugin<T extends PluginDeclaration> {
|
||||
|
||||
private T pluginDeclaration;
|
||||
private PercentageSetter percentageSetter;
|
||||
protected UUID uuid;
|
||||
protected int iterationNumber;
|
||||
|
||||
protected T pluginDeclaration;
|
||||
protected PercentageSetter percentageSetter;
|
||||
|
||||
public Plugin(T pluginDeclaration){
|
||||
this.pluginDeclaration = pluginDeclaration;
|
||||
this.percentageSetter = new PercentageSetter() {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private int percentage = 0;
|
||||
|
||||
@Override
|
||||
public void setPercentageEvolution(Integer integer) {
|
||||
this.percentage = integer;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,7 +46,37 @@ public abstract class Plugin<T extends PluginDeclaration> {
|
|||
}
|
||||
|
||||
protected void setPercentageEvolution(Integer integer){
|
||||
//if(this.percentageSetter!=null){
|
||||
this.percentageSetter.setPercentageEvolution(integer);
|
||||
//}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the uuid
|
||||
*/
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uuid the uuid to set
|
||||
*/
|
||||
public void setUUID(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the iterationNumner
|
||||
*/
|
||||
public int getIterationNumber() {
|
||||
return iterationNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param iterationNumner the iterationNumner to set
|
||||
*/
|
||||
public void setIterationNumber(int iterationNumber) {
|
||||
this.iterationNumber = iterationNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,14 +11,23 @@ import javax.xml.bind.annotation.XmlElement;
|
|||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import org.gcube.vremanagement.executor.api.types.Scheduling;
|
||||
import org.gcube.vremanagement.executor.api.types.adapter.MapAdapter;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
@XmlRootElement()
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property=Scheduling.CLASS_PROPERTY)
|
||||
@JsonDeserialize(as=PluginDeclarationImpl.class)
|
||||
@JsonTypeName(value="PluginDeclaration")
|
||||
public interface PluginDeclaration {
|
||||
|
||||
/**
|
||||
|
@ -66,6 +75,7 @@ public interface PluginDeclaration {
|
|||
* Used to retrieve the class which run the plugin
|
||||
* @return the class which run the plugin
|
||||
*/
|
||||
@JsonIgnore
|
||||
public Class<? extends Plugin<? extends PluginDeclaration>> getPluginImplementation();
|
||||
|
||||
/* Waiting for Java 8 where this method should be declarable
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.vremanagement.executor.plugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
class PluginDeclarationImpl implements PluginDeclaration {
|
||||
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected String version;
|
||||
protected Map<String, String> supportedCapabilities;
|
||||
|
||||
protected PluginDeclarationImpl(){
|
||||
supportedCapabilities = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getSupportedCapabilities() {
|
||||
return supportedCapabilities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Plugin<? extends PluginDeclaration>> getPluginImplementation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package org.gcube.vremanagement.executor.plugin;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public enum PluginState {
|
||||
/**
|
||||
|
|
|
@ -7,27 +7,40 @@ import java.util.UUID;
|
|||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
import org.gcube.vremanagement.executor.api.types.Scheduling;
|
||||
import org.gcube.vremanagement.executor.exception.InvalidPluginStateEvolutionException;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonGetter;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property=Scheduling.CLASS_PROPERTY)
|
||||
public class PluginStateEvolution {
|
||||
|
||||
|
||||
@XmlElement
|
||||
protected UUID uuid;
|
||||
|
||||
@XmlElement
|
||||
protected int iteration;
|
||||
|
||||
@XmlElement
|
||||
protected long timestamp;
|
||||
|
||||
protected PluginDeclaration pluginDeclaration;
|
||||
|
||||
@XmlElement
|
||||
protected PluginState pluginState;
|
||||
|
||||
@XmlElement
|
||||
protected int percentage;
|
||||
|
||||
@XmlElement
|
||||
protected RunOn runOn;
|
||||
|
||||
|
||||
public PluginStateEvolution(){
|
||||
|
||||
}
|
||||
|
@ -41,7 +54,8 @@ public class PluginStateEvolution {
|
|||
* @throws Exception if fails
|
||||
*/
|
||||
public PluginStateEvolution(UUID uuid, int iteration, long timestamp,
|
||||
PluginDeclaration pluginDeclaration, PluginState pluginState, Integer percentage) throws InvalidPluginStateEvolutionException {
|
||||
PluginDeclaration pluginDeclaration,
|
||||
PluginState pluginState, Integer percentage) throws InvalidPluginStateEvolutionException {
|
||||
this.uuid = uuid;
|
||||
this.iteration = iteration;
|
||||
this.timestamp = timestamp;
|
||||
|
@ -86,6 +100,7 @@ public class PluginStateEvolution {
|
|||
/**
|
||||
* @return the pluginDeclaration
|
||||
*/
|
||||
@JsonGetter
|
||||
public PluginDeclaration getPluginDeclaration() {
|
||||
return pluginDeclaration;
|
||||
}
|
||||
|
@ -104,12 +119,38 @@ public class PluginStateEvolution {
|
|||
return this.percentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the runOn
|
||||
*/
|
||||
protected RunOn getRunOn() {
|
||||
return runOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param runOn the runOn to set
|
||||
*/
|
||||
protected void setRunOn(RunOn runOn) {
|
||||
this.runOn = runOn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return String.format("%s : { %s : %s - iteration : %d - timestamp - %d - {%s} - %s - Percentage : %d }}",
|
||||
this.getClass().getSimpleName(),
|
||||
uuid.getClass().getSimpleName(), uuid.toString(),
|
||||
iteration, timestamp, pluginDeclaration, pluginState.toString(), percentage);
|
||||
return String.format("{"
|
||||
+ "uuid:%s,"
|
||||
+ "iteration:%d,"
|
||||
+ "timestamp:%d,"
|
||||
+ "pluginDeclaration:%s,"
|
||||
+ "pluginState:%s,"
|
||||
+ "percentage:%d"
|
||||
+ "}",
|
||||
uuid,
|
||||
iteration,
|
||||
timestamp,
|
||||
pluginDeclaration,
|
||||
pluginState,
|
||||
percentage);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,12 +7,12 @@ import java.util.Map;
|
|||
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public abstract class PluginStateNotification {
|
||||
|
||||
protected Map<String, String> inputs;
|
||||
protected final Map<String, String> inputs;
|
||||
|
||||
public PluginStateNotification(Map<String, String> inputs){
|
||||
this.inputs = inputs;
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.vremanagement.executor.plugin;
|
||||
|
||||
import org.gcube.vremanagement.executor.api.types.Scheduling;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property=Scheduling.CLASS_PROPERTY)
|
||||
@JsonTypeName(value="Ref")
|
||||
public class Ref {
|
||||
|
||||
protected String id;
|
||||
protected String address;
|
||||
|
||||
protected Ref() {}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param address
|
||||
*/
|
||||
public Ref(String id, String address) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the address
|
||||
*/
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param address the address to set
|
||||
*/
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.vremanagement.executor.plugin;
|
||||
|
||||
import org.gcube.vremanagement.executor.api.types.Scheduling;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property=Scheduling.CLASS_PROPERTY)
|
||||
@JsonTypeName(value="RunOn")
|
||||
public class RunOn {
|
||||
|
||||
@JsonProperty
|
||||
protected Ref hostingNode;
|
||||
|
||||
@JsonProperty
|
||||
protected Ref eService;
|
||||
|
||||
public RunOn(){
|
||||
|
||||
}
|
||||
|
||||
public RunOn(Ref hostingNode, Ref eService){
|
||||
this.hostingNode = hostingNode;
|
||||
this.eService = hostingNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hostingNodeID
|
||||
*/
|
||||
public Ref getHostingNode() {
|
||||
return hostingNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hostingNodeID the hostingNodeID to set
|
||||
*/
|
||||
public void setHostingNode(Ref hostingNode) {
|
||||
this.hostingNode = hostingNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the eServiceID
|
||||
*/
|
||||
public Ref getEService() {
|
||||
return eService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param eServiceID the eServiceID to set
|
||||
*/
|
||||
public void setEService(Ref eService) {
|
||||
this.eService = eService;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@ import java.util.Set;
|
|||
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public class MapCompare<M extends Map<K, V>, K, V> {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
package org.gcube.vremanagement.executor.utils;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public class ObjectCompare<CO extends Comparable<CO>> {
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.vremanagement.executor.api.types;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.bind.util.JAXBSource;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
*/
|
||||
public class LaunchParameterTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(LaunchParameterTest.class);
|
||||
|
||||
protected Marshaller createMarshaller(JAXBContext context) throws JAXBException{
|
||||
Marshaller marshaller = context.createMarshaller();
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.FALSE);
|
||||
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.FALSE);
|
||||
return marshaller;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerialization() throws JAXBException {
|
||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||
inputs.put("Hello", "World");
|
||||
long sleepTime = 10000;
|
||||
inputs.put("sleepTime", sleepTime);
|
||||
Scheduling scheduling = new Scheduling(20);
|
||||
scheduling.setGlobal(true);
|
||||
|
||||
LaunchParameter launchParameter = new LaunchParameter("HelloWorld", inputs, scheduling);
|
||||
logger.debug("{} to be serialized : {}", launchParameter.getClass().getSimpleName(), launchParameter);
|
||||
|
||||
|
||||
JAXBContext context = JAXBContext.newInstance(LaunchParameter.class);
|
||||
JAXBElement<LaunchParameter> jaxbElement = new JAXBElement<LaunchParameter>(new QName("org.gcube"), LaunchParameter.class, launchParameter);
|
||||
JAXBSource source = new JAXBSource(context, jaxbElement);
|
||||
|
||||
Marshaller marshaller = createMarshaller(context);
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
marshaller.marshal(jaxbElement, stringWriter);
|
||||
logger.debug("Marshalled {} : {}", launchParameter.getClass().getSimpleName(), stringWriter);
|
||||
|
||||
|
||||
|
||||
JAXBContext contextOut = JAXBContext.newInstance(LaunchParameter.class);
|
||||
Unmarshaller unmarshaller = contextOut.createUnmarshaller();
|
||||
JAXBElement<LaunchParameter> jaxbElementOut = unmarshaller.unmarshal(source, LaunchParameter.class);
|
||||
|
||||
|
||||
LaunchParameter launchParameterUnmarshalled = jaxbElementOut.getValue();
|
||||
logger.debug("Deserialized {} : {}", launchParameter.getClass().getSimpleName(), launchParameterUnmarshalled);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.vremanagement.executor.api.types;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.bind.util.JAXBSource;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.gcube.vremanagement.executor.exception.InvalidPluginStateEvolutionException;
|
||||
import org.gcube.vremanagement.executor.plugin.Plugin;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginDeclaration;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginState;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginStateEvolution;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public class SerializationTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(SerializationTest.class);
|
||||
|
||||
protected Marshaller createMarshaller(JAXBContext context) throws JAXBException{
|
||||
Marshaller marshaller = context.createMarshaller();
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.FALSE);
|
||||
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.FALSE);
|
||||
return marshaller;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXMLSerializationDeserialization() throws JAXBException {
|
||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||
inputs.put("Hello", "World");
|
||||
long sleepTime = 10000;
|
||||
inputs.put("sleepTime", sleepTime);
|
||||
|
||||
Scheduling scheduling = new Scheduling(20);
|
||||
scheduling.setGlobal(true);
|
||||
|
||||
LaunchParameter launchParameter = new LaunchParameter("HelloWorld", inputs, scheduling);
|
||||
logger.debug("{} to be serialized : {}", launchParameter.getClass().getSimpleName(), launchParameter);
|
||||
|
||||
JAXBContext context = JAXBContext.newInstance(LaunchParameter.class);
|
||||
JAXBElement<LaunchParameter> jaxbElement = new JAXBElement<LaunchParameter>(new QName("org.gcube"), LaunchParameter.class, launchParameter);
|
||||
JAXBSource source = new JAXBSource(context, jaxbElement);
|
||||
|
||||
Marshaller marshaller = createMarshaller(context);
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
marshaller.marshal(jaxbElement, stringWriter);
|
||||
logger.debug("Marshalled {} : {}", launchParameter.getClass().getSimpleName(), stringWriter);
|
||||
|
||||
JAXBContext contextOut = JAXBContext.newInstance(LaunchParameter.class);
|
||||
Unmarshaller unmarshaller = contextOut.createUnmarshaller();
|
||||
JAXBElement<LaunchParameter> jaxbElementOut = unmarshaller.unmarshal(source, LaunchParameter.class);
|
||||
|
||||
|
||||
LaunchParameter launchParameterUnmarshalled = jaxbElementOut.getValue();
|
||||
logger.debug("Deserialized {} : {}", launchParameter.getClass().getSimpleName(), launchParameterUnmarshalled);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPluginEvolutionState() throws InvalidPluginStateEvolutionException, JAXBException {
|
||||
PluginDeclaration pluginDeclaration = new PluginDeclaration(){
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return PluginDeclaration.class.getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return PluginDeclaration.class.getSimpleName() + " Description";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "1.0.0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getSupportedCapabilities() {
|
||||
return new HashMap<String, String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Plugin<? extends PluginDeclaration>> getPluginImplementation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return String.format("%s :{ %s - %s - %s }",
|
||||
PluginDeclaration.class.getSimpleName(),
|
||||
getName(), getVersion(), getDescription());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
PluginStateEvolution pes = new PluginStateEvolution(UUID.randomUUID(), 1, Calendar.getInstance().getTimeInMillis(), pluginDeclaration, PluginState.RUNNING, 10);
|
||||
logger.debug("{} to be Marshalled : {}", pes.getClass().getSimpleName(), pes);
|
||||
|
||||
JAXBContext context = JAXBContext.newInstance(PluginStateEvolution.class);
|
||||
JAXBElement<PluginStateEvolution> jaxbElement = new JAXBElement<>(new QName("org.gcube"), PluginStateEvolution.class, pes);
|
||||
JAXBSource source = new JAXBSource(context, jaxbElement);
|
||||
|
||||
Marshaller marshaller = createMarshaller(context);
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
marshaller.marshal(jaxbElement, stringWriter);
|
||||
logger.debug("Marshalled {} : {}", pes.getClass().getSimpleName(), stringWriter);
|
||||
|
||||
|
||||
JAXBContext contextOut = JAXBContext.newInstance(PluginStateEvolution.class);
|
||||
Unmarshaller unmarshaller = contextOut.createUnmarshaller();
|
||||
JAXBElement<PluginStateEvolution> jaxbElementOut = unmarshaller.unmarshal(source, PluginStateEvolution.class);
|
||||
|
||||
PluginStateEvolution pesUnmarshalled = jaxbElementOut.getValue();
|
||||
logger.debug("UnMarshalled : {}", pesUnmarshalled);
|
||||
}
|
||||
|
||||
}
|
|
@ -14,7 +14,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public class PluginStateEvolutionTest {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE xml>
|
||||
<configuration>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
|
|
Loading…
Reference in New Issue