Refactored code to manage better marshalling and unmarshalling of
required classes
This commit is contained in:
parent
98768688a0
commit
a4157eadd2
8
pom.xml
8
pom.xml
|
@ -6,7 +6,7 @@
|
|||
<parent>
|
||||
<groupId>org.gcube.tools</groupId>
|
||||
<artifactId>maven-parent</artifactId>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<version>1.1.0</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.gcube.vremanagement</groupId>
|
||||
|
@ -174,9 +174,9 @@
|
|||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.acme</groupId>
|
||||
<artifactId>HelloWorldPlugin</artifactId>
|
||||
<version>[1.2.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<groupId>org.gcube.vremanagement</groupId>
|
||||
<artifactId>hello-world-se-plugin</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.gcube.smartgears.ApplicationManager;
|
|||
import org.gcube.smartgears.ContextProvider;
|
||||
import org.gcube.smartgears.configuration.container.ContainerConfiguration;
|
||||
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
|
||||
import org.gcube.vremanagement.executor.json.SEMapper;
|
||||
import org.gcube.vremanagement.executor.json.ExtendedSEMapper;
|
||||
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConnector;
|
||||
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceFactory;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginDeclaration;
|
||||
|
@ -43,8 +43,6 @@ import org.quartz.SchedulerException;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
|
@ -344,9 +342,8 @@ public class SmartExecutorInitializator implements ApplicationManager {
|
|||
}
|
||||
|
||||
for(final ScheduledTask scheduledTask : scheduledTasks){
|
||||
final ObjectMapper mapper = SEMapper.getObjectMapper();
|
||||
|
||||
String taskAsString = mapper.writeValueAsString(scheduledTask);
|
||||
String taskAsString = ExtendedSEMapper.getInstance().marshal(scheduledTask);
|
||||
|
||||
try {
|
||||
// Reserving the task.
|
||||
|
@ -363,7 +360,8 @@ public class SmartExecutorInitializator implements ApplicationManager {
|
|||
LaunchParameter launchParameter = scheduledTask.getLaunchParameter();
|
||||
|
||||
try {
|
||||
logger.info("({}) Going to schedule an already scheduled task with the following parameters {}", scope, mapper.writeValueAsString(launchParameter));
|
||||
logger.info("({}) Going to schedule an already scheduled task with the following parameters {}", scope,
|
||||
ExtendedSEMapper.getInstance().marshal(launchParameter));
|
||||
} catch (Exception e1) {
|
||||
|
||||
}
|
||||
|
|
|
@ -11,33 +11,43 @@ import org.gcube.common.authorization.library.provider.UserInfo;
|
|||
import org.gcube.vremanagement.executor.scheduledtask.ScheduledTask;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public class ObjectMapperManager {
|
||||
public class ExtendedSEMapper extends SEMapper {
|
||||
|
||||
static{
|
||||
|
||||
SEMapper.getObjectMapper().registerSubtypes(ScheduledTask.class);
|
||||
|
||||
SEMapper.getObjectMapper().addMixIn(ClientInfo.class, ClientInfoMixIn.class);
|
||||
SEMapper.getObjectMapper().registerSubtypes(UserInfo.class);
|
||||
SEMapper.getObjectMapper().registerSubtypes(ServiceInfo.class);
|
||||
SEMapper.getObjectMapper().registerSubtypes(ExternalServiceInfo.class);
|
||||
SEMapper.getObjectMapper().registerSubtypes(ContainerInfo.class);
|
||||
|
||||
protected static ExtendedSEMapper instance;
|
||||
|
||||
static {
|
||||
instance = new ExtendedSEMapper();
|
||||
}
|
||||
|
||||
public static ObjectMapper getObjectMapper() {
|
||||
return SEMapper.getObjectMapper();
|
||||
|
||||
public static ExtendedSEMapper getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property=SEMapper.CLASS_PROPERTY)
|
||||
class ClientInfoMixIn {
|
||||
|
||||
}
|
||||
|
||||
|
||||
ExtendedSEMapper() {
|
||||
super();
|
||||
|
||||
mapper.registerSubtypes(ScheduledTask.class);
|
||||
|
||||
mapper.addMixIn(ClientInfo.class, ClientInfoMixIn.class);
|
||||
mapper.registerSubtypes(UserInfo.class);
|
||||
mapper.registerSubtypes(ServiceInfo.class);
|
||||
mapper.registerSubtypes(ExternalServiceInfo.class);
|
||||
mapper.registerSubtypes(ContainerInfo.class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -14,7 +14,7 @@ import org.gcube.smartgears.ContextProvider;
|
|||
import org.gcube.vremanagement.executor.client.SmartExecutorClientImpl;
|
||||
import org.gcube.vremanagement.executor.exception.ExecutorException;
|
||||
import org.gcube.vremanagement.executor.exception.PluginInstanceNotFoundException;
|
||||
import org.gcube.vremanagement.executor.json.SEMapper;
|
||||
import org.gcube.vremanagement.executor.json.ExtendedSEMapper;
|
||||
import org.gcube.vremanagement.executor.plugin.Plugin;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginState;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginStateEvolution;
|
||||
|
@ -83,25 +83,21 @@ public abstract class SmartExecutorPersistenceConnector extends PluginStateNotif
|
|||
smartExecutorClient.setAddress(address);
|
||||
smartExecutorClient.setPluginName(pluginName);
|
||||
smartExecutorClient.getPluginStateEvolution(uuid);
|
||||
logger.trace("{} is not orphan.", SEMapper
|
||||
.getObjectMapper().writeValueAsString(scheduledTask));
|
||||
logger.trace("{} is not orphan.", ExtendedSEMapper.getInstance().marshal(scheduledTask));
|
||||
return false;
|
||||
} catch (DiscoveryException | WebApplicationException e) {
|
||||
// The instance was not found or the request failed.
|
||||
// The scheduledTask is considered orphan
|
||||
logger.trace("{} is considered orphan.", SEMapper
|
||||
.getObjectMapper().writeValueAsString(scheduledTask), e);
|
||||
logger.trace("{} is considered orphan.", ExtendedSEMapper.getInstance().marshal(scheduledTask), e);
|
||||
return true;
|
||||
} catch (Throwable e) {
|
||||
// The scheduledTask is NOT considered orphan
|
||||
logger.trace("{} is NOT considered orphan.", SEMapper
|
||||
.getObjectMapper().writeValueAsString(scheduledTask), e);
|
||||
logger.trace("{} is NOT considered orphan.", ExtendedSEMapper.getInstance().marshal(scheduledTask), e);
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
String string = SEMapper.getObjectMapper()
|
||||
.writeValueAsString(scheduledTask);
|
||||
String string = ExtendedSEMapper.getInstance().marshal(scheduledTask);
|
||||
logger.error("Error while checking orphanity of " + string
|
||||
+ ". Considering as not orphan.", e);
|
||||
}catch (Exception ex) {
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.gcube.vremanagement.executor.api.types.LaunchParameter;
|
|||
import org.gcube.vremanagement.executor.exception.ExecutorException;
|
||||
import org.gcube.vremanagement.executor.exception.PluginInstanceNotFoundException;
|
||||
import org.gcube.vremanagement.executor.exception.SchedulePersistenceException;
|
||||
import org.gcube.vremanagement.executor.json.ObjectMapperManager;
|
||||
import org.gcube.vremanagement.executor.json.ExtendedSEMapper;
|
||||
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConfiguration;
|
||||
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConnector;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginDeclaration;
|
||||
|
@ -34,61 +34,53 @@ import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
|
|||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public class OrientDBPersistenceConnector extends
|
||||
SmartExecutorPersistenceConnector {
|
||||
|
||||
private static final Logger logger = LoggerFactory
|
||||
.getLogger(OrientDBPersistenceConnector.class);
|
||||
|
||||
public class OrientDBPersistenceConnector extends SmartExecutorPersistenceConnector {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OrientDBPersistenceConnector.class);
|
||||
|
||||
protected final String SCOPE = "scope";
|
||||
protected final String UUID = "uuid";
|
||||
protected final String ITERATION = "iteration";
|
||||
protected final String TIMESTAMP = "timestamp";
|
||||
|
||||
protected final String RUN_ON = "runOn";
|
||||
|
||||
|
||||
protected ODatabasePool oDatabasePool;
|
||||
|
||||
public OrientDBPersistenceConnector(SmartExecutorPersistenceConfiguration configuration)
|
||||
throws Exception {
|
||||
|
||||
public OrientDBPersistenceConnector(SmartExecutorPersistenceConfiguration configuration) throws Exception {
|
||||
super();
|
||||
prepareConnection(configuration);
|
||||
}
|
||||
|
||||
protected void prepareConnection(
|
||||
SmartExecutorPersistenceConfiguration configuration)
|
||||
throws Exception {
|
||||
logger.debug("Preparing Connection for {}", this.getClass()
|
||||
.getSimpleName());
|
||||
|
||||
protected void prepareConnection(SmartExecutorPersistenceConfiguration configuration) throws Exception {
|
||||
logger.debug("Preparing Connection for {}", this.getClass().getSimpleName());
|
||||
String url = configuration.getURL();
|
||||
String username = configuration.getUsername();
|
||||
String password = configuration.getPassword();
|
||||
|
||||
oDatabasePool = new ODatabasePool(url, username, password);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void close() throws Exception {
|
||||
oDatabasePool.close();
|
||||
}
|
||||
|
||||
public PluginStateEvolution getPluginInstanceState(UUID uuid,
|
||||
Integer iterationNumber) throws PluginInstanceNotFoundException, ExecutorException {
|
||||
|
||||
public PluginStateEvolution getPluginInstanceState(UUID uuid, Integer iterationNumber)
|
||||
throws PluginInstanceNotFoundException, ExecutorException {
|
||||
ODatabaseSession oDatabaseSession = null;
|
||||
try {
|
||||
oDatabaseSession = oDatabasePool.acquire();
|
||||
String type = PluginStateEvolution.class.getSimpleName();
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
Map<String,Object> params = new HashMap<String,Object>();
|
||||
params.put(UUID, uuid.toString());
|
||||
params.put(SCOPE, SmartExecutorInitializator.getCurrentScope());
|
||||
|
||||
|
||||
OSQLSynchQuery<ODocument> query = null;
|
||||
if (iterationNumber != null && iterationNumber > 0) {
|
||||
query = new OSQLSynchQuery<ODocument>(
|
||||
String.format(
|
||||
"SELECT FROM %s WHERE %s = :%s AND %s = :%s AND %s = :%s ORDER BY %s DESC LIMIT 1",
|
||||
type, SCOPE, SCOPE, UUID, UUID, ITERATION,
|
||||
ITERATION, TIMESTAMP));
|
||||
if(iterationNumber != null && iterationNumber > 0) {
|
||||
query = new OSQLSynchQuery<ODocument>(String.format(
|
||||
"SELECT FROM %s WHERE %s = :%s AND %s = :%s AND %s = :%s ORDER BY %s DESC LIMIT 1", type, SCOPE,
|
||||
SCOPE, UUID, UUID, ITERATION, ITERATION, TIMESTAMP));
|
||||
params.put(ITERATION, iterationNumber);
|
||||
} else {
|
||||
/*
|
||||
|
@ -98,17 +90,16 @@ public class OrientDBPersistenceConnector extends
|
|||
type, SCOPE, SCOPE, UUID, UUID, ITERATION));
|
||||
*/
|
||||
query = new OSQLSynchQuery<ODocument>(
|
||||
String.format(
|
||||
"SELECT FROM %s WHERE %s = :%s AND %s = :%s ORDER BY %s DESC, %s DESC LIMIT 1",
|
||||
String.format("SELECT FROM %s WHERE %s = :%s AND %s = :%s ORDER BY %s DESC, %s DESC LIMIT 1",
|
||||
type, SCOPE, SCOPE, UUID, UUID, ITERATION, TIMESTAMP));
|
||||
}
|
||||
|
||||
|
||||
List<ODocument> result = query.execute(params);
|
||||
ODocument resDoc = result.get(0);
|
||||
|
||||
/*
|
||||
ODocument resDoc = null;
|
||||
|
||||
|
||||
if (iterationNumber != null) {
|
||||
resDoc = result.get(0);
|
||||
} else {
|
||||
|
@ -125,248 +116,226 @@ public class OrientDBPersistenceConnector extends
|
|||
*/
|
||||
|
||||
String json = resDoc.toJSON("class");
|
||||
PluginStateEvolution pluginStateEvolution = ObjectMapperManager.getObjectMapper().readValue(json,
|
||||
PluginStateEvolution.class);
|
||||
|
||||
PluginStateEvolution pluginStateEvolution = ExtendedSEMapper.getInstance()
|
||||
.unmarshal(PluginStateEvolution.class, json);
|
||||
|
||||
return pluginStateEvolution;
|
||||
} catch (Exception e) {
|
||||
} catch(Exception e) {
|
||||
throw new PluginInstanceNotFoundException();
|
||||
} finally {
|
||||
if(oDatabaseSession!=null) {
|
||||
if(oDatabaseSession != null) {
|
||||
oDatabaseSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void pluginStateEvolution(PluginStateEvolution pluginStateEvolution,
|
||||
Exception exception) throws Exception {
|
||||
public void pluginStateEvolution(PluginStateEvolution pluginStateEvolution, Exception exception) throws Exception {
|
||||
ODatabaseSession oDatabaseSession = null;
|
||||
try {
|
||||
oDatabaseSession = oDatabasePool.acquire();
|
||||
ODocument doc = new ODocument(
|
||||
PluginStateEvolution.class.getSimpleName());
|
||||
String json = ObjectMapperManager.getObjectMapper().writeValueAsString(pluginStateEvolution);
|
||||
ODocument doc = new ODocument(PluginStateEvolution.class.getSimpleName());
|
||||
String json = ExtendedSEMapper.getInstance().marshal(pluginStateEvolution);
|
||||
doc.fromJSON(json);
|
||||
doc.field(SCOPE, SmartExecutorInitializator.getCurrentScope());
|
||||
|
||||
|
||||
doc.save();
|
||||
oDatabaseSession.commit();
|
||||
} catch (Exception e) {
|
||||
if (oDatabaseSession != null) {
|
||||
} catch(Exception e) {
|
||||
if(oDatabaseSession != null) {
|
||||
oDatabaseSession.rollback();
|
||||
}
|
||||
throw e;
|
||||
} finally {
|
||||
if (oDatabaseSession != null) {
|
||||
if(oDatabaseSession != null) {
|
||||
oDatabaseSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addScheduledTask(ScheduledTask scheduledTask)
|
||||
throws SchedulePersistenceException {
|
||||
public void addScheduledTask(ScheduledTask scheduledTask) throws SchedulePersistenceException {
|
||||
ODatabaseSession oDatabaseSession = null;
|
||||
try {
|
||||
oDatabaseSession = oDatabasePool.acquire();
|
||||
|
||||
|
||||
ODocument doc = new ODocument(ScheduledTask.class.getSimpleName());
|
||||
|
||||
|
||||
long timestamp = Calendar.getInstance().getTimeInMillis();
|
||||
doc.field(TIMESTAMP, timestamp);
|
||||
|
||||
String json = ObjectMapperManager.getObjectMapper().writeValueAsString(scheduledTask);
|
||||
|
||||
String json = ExtendedSEMapper.getInstance().marshal(scheduledTask);
|
||||
doc.fromJSON(json);
|
||||
doc.save();
|
||||
|
||||
|
||||
oDatabaseSession.commit();
|
||||
} catch (Exception e) {
|
||||
if (oDatabaseSession != null) {
|
||||
} catch(Exception e) {
|
||||
if(oDatabaseSession != null) {
|
||||
oDatabaseSession.rollback();
|
||||
}
|
||||
throw new SchedulePersistenceException(e);
|
||||
} finally {
|
||||
if (oDatabaseSession != null) {
|
||||
if(oDatabaseSession != null) {
|
||||
oDatabaseSession.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ScheduledTask> getOrphanScheduledTasks(
|
||||
Collection<? extends PluginDeclaration> pluginDeclarations)
|
||||
public List<ScheduledTask> getOrphanScheduledTasks(Collection<? extends PluginDeclaration> pluginDeclarations)
|
||||
throws SchedulePersistenceException {
|
||||
ODatabaseSession oDatabaseSession = null;
|
||||
try {
|
||||
oDatabaseSession = oDatabasePool.acquire();
|
||||
String type = ScheduledTask.class.getSimpleName();
|
||||
|
||||
String queryString = String.format("SELECT * FROM %s WHERE %s = '%s'", type, "scope", SmartExecutorInitializator.getCurrentScope());
|
||||
if(pluginDeclarations!=null && pluginDeclarations.size()!=0){
|
||||
String queryString = String.format("SELECT * FROM %s WHERE %s = '%s'", type, "scope",
|
||||
SmartExecutorInitializator.getCurrentScope());
|
||||
if(pluginDeclarations != null && pluginDeclarations.size() != 0) {
|
||||
boolean first = true;
|
||||
for(PluginDeclaration pluginDeclaration : pluginDeclarations){
|
||||
if(first){
|
||||
for(PluginDeclaration pluginDeclaration : pluginDeclarations) {
|
||||
if(first) {
|
||||
first = false;
|
||||
queryString = String.format("%s AND ( (%s = '%s') ",
|
||||
queryString,
|
||||
ScheduledTask.LAUNCH_PARAMETER + "." + LaunchParameter.PLUGIN_NAME,
|
||||
queryString = String.format("%s AND ( (%s = '%s') ", queryString,
|
||||
ScheduledTask.LAUNCH_PARAMETER + "." + LaunchParameter.PLUGIN_NAME,
|
||||
pluginDeclaration.getName());
|
||||
}else{
|
||||
queryString = String.format("%s OR (%s = '%s') ",
|
||||
queryString,
|
||||
ScheduledTask.LAUNCH_PARAMETER + "." + LaunchParameter.PLUGIN_NAME,
|
||||
} else {
|
||||
queryString = String.format("%s OR (%s = '%s') ", queryString,
|
||||
ScheduledTask.LAUNCH_PARAMETER + "." + LaunchParameter.PLUGIN_NAME,
|
||||
pluginDeclaration.getName());
|
||||
}
|
||||
}
|
||||
queryString = queryString + ")";
|
||||
}
|
||||
|
||||
OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(queryString);
|
||||
|
||||
OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(
|
||||
queryString
|
||||
);
|
||||
|
||||
List<ODocument> result = query.execute();
|
||||
|
||||
|
||||
List<ScheduledTask> scheduledTasks = new ArrayList<>();
|
||||
|
||||
for (ODocument doc : result) {
|
||||
|
||||
for(ODocument doc : result) {
|
||||
String json = doc.toJSON("class");
|
||||
|
||||
ScheduledTask scheduledTask = ObjectMapperManager.getObjectMapper().readValue(json,
|
||||
ScheduledTask.class);
|
||||
|
||||
ScheduledTask scheduledTask = ExtendedSEMapper.getInstance().unmarshal(ScheduledTask.class, json);
|
||||
try {
|
||||
if (isOrphan(scheduledTask)) {
|
||||
if(isOrphan(scheduledTask)) {
|
||||
scheduledTasks.add(scheduledTask);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
"An Exception occurred while evaluating if {} is orphan",
|
||||
json, e);
|
||||
} catch(Exception e) {
|
||||
logger.error("An Exception occurred while evaluating if {} is orphan", json, e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return scheduledTasks;
|
||||
} catch (Exception e) {
|
||||
} catch(Exception e) {
|
||||
throw new SchedulePersistenceException(e);
|
||||
} finally {
|
||||
if (oDatabaseSession != null) {
|
||||
if(oDatabaseSession != null) {
|
||||
oDatabaseSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected ODocument getScheduledTaskDocument(UUID uuid) throws SchedulePersistenceException {
|
||||
try {
|
||||
String type = ScheduledTask.class.getSimpleName();
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
Map<String,Object> params = new HashMap<String,Object>();
|
||||
params.put(UUID, uuid.toString());
|
||||
|
||||
|
||||
OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(
|
||||
String.format("SELECT FROM %s WHERE %s = :%s", type, UUID,
|
||||
UUID));
|
||||
|
||||
String.format("SELECT FROM %s WHERE %s = :%s", type, UUID, UUID));
|
||||
|
||||
List<ODocument> result = query.execute(params);
|
||||
if (result.size() > 1) {
|
||||
String error = String.format(
|
||||
"Found more than one %s with UUID=%s. %s. %s.", type,
|
||||
uuid.toString(),
|
||||
if(result.size() > 1) {
|
||||
String error = String.format("Found more than one %s with UUID=%s. %s. %s.", type, uuid.toString(),
|
||||
"This is really strange and should not occur",
|
||||
"Please contact the smart-executor administrator");
|
||||
logger.error(error);
|
||||
throw new SchedulePersistenceException(error);
|
||||
} else if (result.size() == 0) {
|
||||
String error = String.format("No %s with UUID=%s found.", type,
|
||||
uuid.toString());
|
||||
} else if(result.size() == 0) {
|
||||
String error = String.format("No %s with UUID=%s found.", type, uuid.toString());
|
||||
logger.error(error);
|
||||
throw new SchedulePersistenceException(error);
|
||||
}
|
||||
|
||||
|
||||
return result.get(0);
|
||||
} catch (Exception e) {
|
||||
} catch(Exception e) {
|
||||
throw new SchedulePersistenceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ScheduledTask getScheduledTask(UUID uuid)
|
||||
throws SchedulePersistenceException {
|
||||
public ScheduledTask getScheduledTask(UUID uuid) throws SchedulePersistenceException {
|
||||
ODatabaseSession oDatabaseSession = null;
|
||||
try {
|
||||
oDatabaseSession = oDatabasePool.acquire();
|
||||
ODocument doc = getScheduledTaskDocument(uuid);
|
||||
String json = doc.toJSON("class");
|
||||
return ObjectMapperManager.getObjectMapper().readValue(json, ScheduledTask.class);
|
||||
} catch (Exception e) {
|
||||
return ExtendedSEMapper.getInstance().unmarshal(ScheduledTask.class, json);
|
||||
} catch(Exception e) {
|
||||
throw new SchedulePersistenceException(e);
|
||||
} finally {
|
||||
if (oDatabaseSession != null) {
|
||||
if(oDatabaseSession != null) {
|
||||
oDatabaseSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reserveScheduledTask(ScheduledTask scheduledTask)
|
||||
throws SchedulePersistenceException {
|
||||
public void reserveScheduledTask(ScheduledTask scheduledTask) throws SchedulePersistenceException {
|
||||
releaseScheduledTask(scheduledTask);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeScheduledTask(UUID uuid)
|
||||
throws SchedulePersistenceException {
|
||||
public void removeScheduledTask(UUID uuid) throws SchedulePersistenceException {
|
||||
ODatabaseSession oDatabaseSession = null;
|
||||
try {
|
||||
oDatabaseSession = oDatabasePool.acquire();
|
||||
ODocument doc = getScheduledTaskDocument(uuid);
|
||||
doc.delete();
|
||||
oDatabaseSession.commit();
|
||||
} catch (Exception e) {
|
||||
if (oDatabaseSession != null) {
|
||||
} catch(Exception e) {
|
||||
if(oDatabaseSession != null) {
|
||||
oDatabaseSession.rollback();
|
||||
}
|
||||
throw new SchedulePersistenceException(e);
|
||||
} finally {
|
||||
if (oDatabaseSession != null) {
|
||||
if(oDatabaseSession != null) {
|
||||
oDatabaseSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeScheduledTask(ScheduledTask scheduledTask)
|
||||
throws SchedulePersistenceException {
|
||||
public void removeScheduledTask(ScheduledTask scheduledTask) throws SchedulePersistenceException {
|
||||
removeScheduledTask(scheduledTask.getUUID());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void releaseScheduledTask(UUID uuid)
|
||||
throws SchedulePersistenceException {
|
||||
public void releaseScheduledTask(UUID uuid) throws SchedulePersistenceException {
|
||||
ODatabaseSession oDatabaseSession = null;
|
||||
try {
|
||||
oDatabaseSession = oDatabasePool.acquire();
|
||||
ODocument doc = getScheduledTaskDocument(uuid);
|
||||
doc.removeField(RUN_ON);
|
||||
doc.save();
|
||||
} catch (Exception e) {
|
||||
if (oDatabaseSession != null) {
|
||||
} catch(Exception e) {
|
||||
if(oDatabaseSession != null) {
|
||||
oDatabaseSession.rollback();
|
||||
}
|
||||
throw new SchedulePersistenceException(e);
|
||||
} finally {
|
||||
if (oDatabaseSession != null) {
|
||||
if(oDatabaseSession != null) {
|
||||
oDatabaseSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void releaseScheduledTask(ScheduledTask scheduledTask)
|
||||
throws SchedulePersistenceException {
|
||||
public void releaseScheduledTask(ScheduledTask scheduledTask) throws SchedulePersistenceException {
|
||||
releaseScheduledTask(scheduledTask.getUUID());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package org.gcube.vremanagement.executor.rest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
|
@ -27,10 +30,14 @@ import org.gcube.vremanagement.executor.exception.InputsNullException;
|
|||
import org.gcube.vremanagement.executor.exception.InvalidInputsException;
|
||||
import org.gcube.vremanagement.executor.exception.SchedulePersistenceException;
|
||||
import org.gcube.vremanagement.executor.exception.SchedulerNotFoundException;
|
||||
import org.gcube.vremanagement.executor.json.ExtendedSEMapper;
|
||||
import org.gcube.vremanagement.executor.json.SEMapper;
|
||||
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConnector;
|
||||
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceFactory;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginDeclaration;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginStateEvolution;
|
||||
import org.gcube.vremanagement.executor.pluginmanager.PluginManager;
|
||||
import org.gcube.vremanagement.executor.scheduledtask.ScheduledTask;
|
||||
import org.gcube.vremanagement.executor.scheduler.SmartExecutorScheduler;
|
||||
import org.gcube.vremanagement.executor.scheduler.SmartExecutorSchedulerFactory;
|
||||
import org.quartz.SchedulerException;
|
||||
|
@ -69,17 +76,70 @@ public class RestSmartExecutor implements SmartExecutor {
|
|||
@Override
|
||||
public String getAvailablePlugins() throws ExecutorException {
|
||||
setCalledMethod(HttpMethod.GET + " /" + RestConstants.PLUGINS_PATH_PART);
|
||||
return "[]";
|
||||
try {
|
||||
PluginManager pluginManager = PluginManager.getInstance();
|
||||
Map<String, PluginDeclaration> availablePlugins = pluginManager.getAvailablePlugins();
|
||||
List<PluginDeclaration> plugins = new ArrayList<PluginDeclaration>(availablePlugins.values());
|
||||
return ExtendedSEMapper.getInstance().marshal(plugins);
|
||||
}catch (Exception e) {
|
||||
throw new ExecutorException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/{" + PLUGIN_NAME_PATH_PARAM + "}/" + RestConstants.EXECUTIONS_PATH_PART)
|
||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||
@Override
|
||||
public String getLaunches(@PathParam(PLUGIN_NAME_PATH_PARAM) String pluginName) throws ExecutorException {
|
||||
public String getScheduled(@PathParam(PLUGIN_NAME_PATH_PARAM) String pluginName) throws ExecutorException {
|
||||
setCalledMethod(HttpMethod.GET + " /" + RestConstants.PLUGINS_PATH_PART + "/"
|
||||
+ pluginName + "/" + RestConstants.EXECUTIONS_PATH_PART);
|
||||
return "[]";
|
||||
try {
|
||||
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceFactory
|
||||
.getPersistenceConnector();
|
||||
|
||||
List<PluginDeclaration> pluginDeclarations = new ArrayList<>();
|
||||
|
||||
if(pluginName.compareTo(ORPHAN_PATH_PARAM)!=0) {
|
||||
PluginManager pluginManager = PluginManager.getInstance();
|
||||
Map<String, PluginDeclaration> availablePlugins = pluginManager.getAvailablePlugins();
|
||||
PluginDeclaration pluginDeclaration = availablePlugins.get(pluginName);
|
||||
if(pluginDeclaration==null) {
|
||||
String error = String.format("This SmartExecutor instace does not manage any plugin with name %s", pluginName);
|
||||
logger.error(error);
|
||||
throw new ExecutorException(error);
|
||||
}else {
|
||||
pluginDeclarations.add(pluginDeclaration);
|
||||
}
|
||||
}else {
|
||||
// TODO check role
|
||||
}
|
||||
|
||||
List<ScheduledTask> scheduledTasks = persistenceConnector.getOrphanScheduledTasks(pluginDeclarations);
|
||||
|
||||
|
||||
/*
|
||||
* Using SEMapper because the server must not return sensitive information like token
|
||||
* To achieve this we need to convert the list to the base ScheduledTask type
|
||||
* i.e.
|
||||
* from org.gcube.vremanagement.executor.scheduledtask.ScheduledTask
|
||||
* to org.gcube.vremanagement.executor.plugin.ScheduledTask
|
||||
*
|
||||
* This conversion is not possible using
|
||||
* List<org.gcube.vremanagement.executor.plugin.ScheduledTask> tasks = new ArrayList<>(scheduledTasks);
|
||||
*/
|
||||
List<org.gcube.vremanagement.executor.plugin.ScheduledTask> tasks = new ArrayList<>();
|
||||
for(ScheduledTask scheduledTask : scheduledTasks) {
|
||||
org.gcube.vremanagement.executor.plugin.ScheduledTask task = new org.gcube.vremanagement.executor.plugin.ScheduledTask(
|
||||
scheduledTask.getUUID(), scheduledTask.getRunOn(), scheduledTask.getLaunchParameter());
|
||||
tasks.add(task);
|
||||
}
|
||||
return SEMapper.getInstance().marshal(org.gcube.vremanagement.executor.plugin.ScheduledTask.class, tasks);
|
||||
|
||||
} catch(ExecutorException e) {
|
||||
throw e;
|
||||
} catch(Exception e) {
|
||||
throw new ExecutorException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
|
@ -94,7 +154,7 @@ public class RestSmartExecutor implements SmartExecutor {
|
|||
|
||||
try {
|
||||
logger.info("Requested to launch {} ({})", pluginName, launchParameterString);
|
||||
LaunchParameter launchParameter = SEMapper.unmarshal(LaunchParameter.class, launchParameterString);
|
||||
LaunchParameter launchParameter = ExtendedSEMapper.getInstance().unmarshal(LaunchParameter.class, launchParameterString);
|
||||
if(pluginName == null) {
|
||||
String error = String.format("Plugin Name provided in the URL (%s) cannot be null", pluginName);
|
||||
logger.error(error);
|
||||
|
@ -154,7 +214,7 @@ public class RestSmartExecutor implements SmartExecutor {
|
|||
}
|
||||
|
||||
try {
|
||||
return SEMapper.marshal(pluginStateEvolution);
|
||||
return ExtendedSEMapper.getInstance().marshal(pluginStateEvolution);
|
||||
} catch(JsonProcessingException e) {
|
||||
throw new ExecutorException(e);
|
||||
}
|
||||
|
|
|
@ -19,28 +19,18 @@ import org.gcube.vremanagement.executor.json.SEMapper;
|
|||
import org.gcube.vremanagement.executor.plugin.Ref;
|
||||
import org.gcube.vremanagement.executor.plugin.RunOn;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property=SEMapper.CLASS_PROPERTY)
|
||||
public class ScheduledTask {
|
||||
public class ScheduledTask extends org.gcube.vremanagement.executor.plugin.ScheduledTask {
|
||||
|
||||
public static final String LAUNCH_PARAMETER = "launchParameter";
|
||||
|
||||
protected UUID uuid;
|
||||
|
||||
@JsonProperty(value=LAUNCH_PARAMETER)
|
||||
protected LaunchParameter launchParameter;
|
||||
|
||||
protected String scope;
|
||||
protected String token;
|
||||
protected String scope;
|
||||
protected ClientInfo clientInfo;
|
||||
|
||||
protected RunOn runOn;
|
||||
|
||||
protected ScheduledTask(){}
|
||||
|
||||
public ScheduledTask(UUID uuid, LaunchParameter launchParameter) {
|
||||
|
@ -57,10 +47,10 @@ public class ScheduledTask {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return the uuid
|
||||
* @return the token
|
||||
*/
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,13 +60,6 @@ public class ScheduledTask {
|
|||
return scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the token
|
||||
*/
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the clientInfo
|
||||
*/
|
||||
|
@ -84,13 +67,6 @@ public class ScheduledTask {
|
|||
return clientInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the runOn
|
||||
*/
|
||||
public RunOn getRunOn() {
|
||||
return runOn;
|
||||
}
|
||||
|
||||
public static final String LOCALHOST = "localhost";
|
||||
|
||||
public static RunOn generateRunOn() {
|
||||
|
@ -127,11 +103,4 @@ public class ScheduledTask {
|
|||
return runOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the launchParameter
|
||||
*/
|
||||
public LaunchParameter getLaunchParameter(){
|
||||
return launchParameter;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,9 +14,7 @@ import org.gcube.vremanagement.executor.plugin.PluginDeclaration;
|
|||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public interface ScheduledTaskPersistence {
|
||||
|
||||
public static final String SCOPE = "scope";
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve from the #SmartExecutorPersistenceConnector the orphaned
|
||||
* Scheduled tasks
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.gcube.vremanagement.executor.exception.LaunchException;
|
|||
import org.gcube.vremanagement.executor.exception.PluginNotFoundException;
|
||||
import org.gcube.vremanagement.executor.exception.SchedulerNotFoundException;
|
||||
import org.gcube.vremanagement.executor.exception.UnableToInterruptTaskException;
|
||||
import org.gcube.vremanagement.executor.json.SEMapper;
|
||||
import org.gcube.vremanagement.executor.json.ExtendedSEMapper;
|
||||
import org.gcube.vremanagement.executor.pluginmanager.PluginManager;
|
||||
import org.gcube.vremanagement.executor.scheduledtask.ScheduledTask;
|
||||
import org.gcube.vremanagement.executor.scheduledtask.ScheduledTaskPersistence;
|
||||
|
@ -44,10 +44,8 @@ import org.slf4j.LoggerFactory;
|
|||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class SmartExecutorScheduler {
|
||||
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(SmartExecutorScheduler.class);
|
||||
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(SmartExecutorScheduler.class);
|
||||
|
||||
protected Set<UUID> scheduledJobs;
|
||||
protected final Scheduler scheduler;
|
||||
|
@ -58,36 +56,33 @@ public class SmartExecutorScheduler {
|
|||
this.scheduledJobs = new HashSet<>();
|
||||
}
|
||||
|
||||
protected TriggerBuilder<? extends Trigger> createTriggerBuilder(UUID uuid, ScheduleBuilder<? extends Trigger> sb){
|
||||
return TriggerBuilder.newTrigger().withIdentity(uuid.toString())
|
||||
.withSchedule(sb);
|
||||
protected TriggerBuilder<? extends Trigger> createTriggerBuilder(UUID uuid, ScheduleBuilder<? extends Trigger> sb) {
|
||||
return TriggerBuilder.newTrigger().withIdentity(uuid.toString()).withSchedule(sb);
|
||||
}
|
||||
|
||||
protected TriggerBuilder<? extends Trigger> getTriggerBuilderWithScheduling(UUID uuid, Scheduling scheduling) throws LaunchException{
|
||||
protected TriggerBuilder<? extends Trigger> getTriggerBuilderWithScheduling(UUID uuid, Scheduling scheduling)
|
||||
throws LaunchException {
|
||||
|
||||
final int times = scheduling.getSchedulingTimes();
|
||||
|
||||
if (scheduling.getCronExpression() != null) {
|
||||
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder
|
||||
.cronSchedule(scheduling.getCronExpression());
|
||||
if(scheduling.getCronExpression() != null) {
|
||||
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(scheduling.getCronExpression());
|
||||
|
||||
return createTriggerBuilder(uuid, cronScheduleBuilder);
|
||||
}
|
||||
|
||||
if (scheduling.getDelay() != null) {
|
||||
SimpleScheduleBuilder simpleScheduleBuilder;
|
||||
if(scheduling.getDelay() != null) {
|
||||
SimpleScheduleBuilder simpleScheduleBuilder;
|
||||
|
||||
if (times != 0) {
|
||||
simpleScheduleBuilder = SimpleScheduleBuilder
|
||||
.repeatSecondlyForTotalCount(times, scheduling.getDelay());
|
||||
}else{
|
||||
simpleScheduleBuilder = SimpleScheduleBuilder.
|
||||
repeatSecondlyForever(scheduling.getDelay());
|
||||
if(times != 0) {
|
||||
simpleScheduleBuilder = SimpleScheduleBuilder.repeatSecondlyForTotalCount(times, scheduling.getDelay());
|
||||
} else {
|
||||
simpleScheduleBuilder = SimpleScheduleBuilder.repeatSecondlyForever(scheduling.getDelay());
|
||||
}
|
||||
|
||||
return createTriggerBuilder(uuid, simpleScheduleBuilder);
|
||||
}
|
||||
|
||||
|
||||
throw new LaunchException("Invalid Scheduling");
|
||||
|
||||
}
|
||||
|
@ -101,11 +96,11 @@ public class SmartExecutorScheduler {
|
|||
* @throws SchedulerException if the scheduler cannot be created by the
|
||||
* scheduler factory
|
||||
*/
|
||||
protected void reallySchedule(final UUID uuid, LaunchParameter parameter) throws LaunchException, SchedulerException {
|
||||
protected void reallySchedule(final UUID uuid, LaunchParameter parameter)
|
||||
throws LaunchException, SchedulerException {
|
||||
|
||||
JobKey jobKey = new JobKey(uuid.toString());
|
||||
JobDetail jobDetail = JobBuilder.newJob(SmartExecutorTask.class).
|
||||
withIdentity(jobKey).build();
|
||||
JobDetail jobDetail = JobBuilder.newJob(SmartExecutorTask.class).withIdentity(jobKey).build();
|
||||
JobDataMap jobDataMap = jobDetail.getJobDataMap();
|
||||
jobDataMap.put(SmartExecutorTask.UUID, uuid);
|
||||
jobDataMap.put(SmartExecutorTask.LAUNCH_PARAMETER, parameter);
|
||||
|
@ -114,25 +109,26 @@ public class SmartExecutorScheduler {
|
|||
jobDataMap.put(SmartExecutorTask.TOKEN, token);
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
TriggerBuilder triggerBuilder = TriggerBuilder.newTrigger()
|
||||
.withIdentity(uuid.toString());
|
||||
|
||||
TriggerBuilder triggerBuilder = TriggerBuilder.newTrigger().withIdentity(uuid.toString());
|
||||
|
||||
Scheduling scheduling = parameter.getScheduling();
|
||||
|
||||
if (scheduling != null) {
|
||||
if(scheduling != null) {
|
||||
|
||||
try {
|
||||
logger.info("Going to schedule Taks with UUID {} with the following {} : {}", uuid, LaunchParameter.class.getSimpleName(), SEMapper.getObjectMapper().writeValueAsString(parameter));
|
||||
} catch (Exception e) {
|
||||
logger.info("Going to schedule Taks with UUID {} with the following {} : {}", uuid,
|
||||
LaunchParameter.class.getSimpleName(),
|
||||
ExtendedSEMapper.getInstance().marshal(parameter));
|
||||
} catch(Exception e) {
|
||||
|
||||
}
|
||||
|
||||
triggerBuilder = getTriggerBuilderWithScheduling(uuid, scheduling);
|
||||
|
||||
if (scheduling.getFirstStartTime() != null && scheduling.getFirstStartTime().longValue()!=0) {
|
||||
if(scheduling.getFirstStartTime() != null && scheduling.getFirstStartTime().longValue() != 0) {
|
||||
Date triggerStartTime = new Date(scheduling.getFirstStartTime());
|
||||
triggerBuilder.startAt(triggerStartTime);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
else {
|
||||
|
@ -141,7 +137,7 @@ public class SmartExecutorScheduler {
|
|||
}
|
||||
*/
|
||||
|
||||
if (scheduling.getEndTime() != null && scheduling.getEndTime().longValue()!=0) {
|
||||
if(scheduling.getEndTime() != null && scheduling.getEndTime().longValue() != 0) {
|
||||
Date triggerEndTime = new Date(scheduling.getEndTime());
|
||||
triggerBuilder.endAt(triggerEndTime);
|
||||
}
|
||||
|
@ -149,17 +145,18 @@ public class SmartExecutorScheduler {
|
|||
try {
|
||||
ScheduledTaskPersistence stc = ScheduledTaskPersistenceFactory.getScheduledTaskPersistence();
|
||||
ScheduledTask scheduledTask = new ScheduledTask(uuid, parameter);
|
||||
logger.debug("Going to persist Scheduled Task {} ",
|
||||
scheduledTask);
|
||||
logger.debug("Going to persist Scheduled Task {} ", scheduledTask);
|
||||
stc.addScheduledTask(scheduledTask);
|
||||
} catch (Exception e) {
|
||||
} catch(Exception e) {
|
||||
logger.error("Unable to persist Scheduled Task {}", uuid.toString(), e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
try {
|
||||
logger.info("Starting Taks with UUID {} immediately with the following {} : {}", uuid, LaunchParameter.class.getSimpleName(), SEMapper.getObjectMapper().writeValueAsString(parameter));
|
||||
} catch (Exception e) {
|
||||
logger.info("Starting Taks with UUID {} immediately with the following {} : {}", uuid,
|
||||
LaunchParameter.class.getSimpleName(),
|
||||
ExtendedSEMapper.getInstance().marshal(parameter));
|
||||
} catch(Exception e) {
|
||||
|
||||
}
|
||||
triggerBuilder.startNow();
|
||||
|
@ -169,7 +166,7 @@ public class SmartExecutorScheduler {
|
|||
SmartExecutorTaskListener sejl = new SmartExecutorTaskListener();
|
||||
scheduler.getListenerManager().addJobListener(sejl);
|
||||
scheduler.scheduleJob(jobDetail, triggerBuilder.build());
|
||||
} catch (SchedulerException e) {
|
||||
} catch(SchedulerException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
@ -184,10 +181,10 @@ public class SmartExecutorScheduler {
|
|||
* @throws PluginNotFoundException if the request plugin is not available on
|
||||
* this smart executor instance
|
||||
*/
|
||||
public synchronized UUID schedule(LaunchParameter parameter, UUID uuid)
|
||||
public synchronized UUID schedule(LaunchParameter parameter, UUID uuid)
|
||||
throws InputsNullException, PluginNotFoundException, LaunchException {
|
||||
Map<String, Object> inputs = parameter.getInputs();
|
||||
if (inputs == null) {
|
||||
Map<String,Object> inputs = parameter.getInputs();
|
||||
if(inputs == null) {
|
||||
throw new InputsNullException();
|
||||
}
|
||||
|
||||
|
@ -197,63 +194,63 @@ public class SmartExecutorScheduler {
|
|||
*/
|
||||
PluginManager.getPluginDeclaration(parameter.getPluginName());
|
||||
|
||||
if(uuid==null){
|
||||
if(uuid == null) {
|
||||
uuid = UUID.randomUUID();
|
||||
}
|
||||
|
||||
try {
|
||||
reallySchedule(uuid, parameter);
|
||||
scheduledJobs.add(uuid);
|
||||
} catch (SchedulerException e) {
|
||||
} catch(SchedulerException e) {
|
||||
throw new LaunchException(e);
|
||||
}
|
||||
|
||||
return uuid;
|
||||
}
|
||||
|
||||
protected void stopTask(UUID uuid)
|
||||
throws UnableToInterruptTaskException{
|
||||
|
||||
protected void stopTask(UUID uuid) throws UnableToInterruptTaskException {
|
||||
|
||||
JobKey jobKey = new JobKey(uuid.toString());
|
||||
|
||||
try {
|
||||
logger.debug("Going to stop current SmartExecutor Task {} execution if any", uuid);
|
||||
if(!scheduler.checkExists(jobKey)){
|
||||
logger.trace("SmartExecutor Task {} does not have any instaces associated. Cleaning the environment. That's all folk.", uuid);
|
||||
if(!scheduler.checkExists(jobKey)) {
|
||||
logger.trace(
|
||||
"SmartExecutor Task {} does not have any instaces associated. Cleaning the environment. That's all folk.",
|
||||
uuid);
|
||||
scheduledJobs.remove(uuid);
|
||||
throw new SchedulerNotFoundException("Scheduler Not Found");
|
||||
}
|
||||
|
||||
boolean interrupted = scheduler.interrupt(jobKey);
|
||||
scheduler.deleteJob(jobKey);
|
||||
if (interrupted) {
|
||||
if(interrupted) {
|
||||
logger.debug("SmartExecutor Task {} interrupted successfully.", uuid);
|
||||
} else {
|
||||
logger.debug("SmartExecutor Task {} was not interrupted.", uuid);
|
||||
}
|
||||
|
||||
} catch(Exception e){
|
||||
} catch(Exception e) {
|
||||
throw new UnableToInterruptTaskException(uuid, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected List<JobExecutionContext> getCurrentlyExecutingJobs(Scheduler scheduler) throws SchedulerException{
|
||||
protected List<JobExecutionContext> getCurrentlyExecutingJobs(Scheduler scheduler) throws SchedulerException {
|
||||
logger.trace("Getting {} list", JobExecutionContext.class.getSimpleName());
|
||||
List<JobExecutionContext> cej = scheduler.getCurrentlyExecutingJobs();
|
||||
logger.trace("{} list got {}", JobExecutionContext.class.getSimpleName(), cej);
|
||||
return cej;
|
||||
}
|
||||
|
||||
public LaunchParameter getLaunchParameter(JobKey jobKey) throws SchedulerException{
|
||||
public LaunchParameter getLaunchParameter(JobKey jobKey) throws SchedulerException {
|
||||
JobDetail jobDetail = scheduler.getJobDetail(jobKey);
|
||||
if(jobDetail==null){
|
||||
if(jobDetail == null) {
|
||||
return null;
|
||||
}
|
||||
JobDataMap jobDataMap = jobDetail.getJobDataMap();
|
||||
return (LaunchParameter) jobDataMap.get(SmartExecutorTask.LAUNCH_PARAMETER);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stop the execution of the Task identified by UUID
|
||||
* @param uuid which identify the Task
|
||||
|
@ -263,12 +260,11 @@ public class SmartExecutorScheduler {
|
|||
* @throws Exception
|
||||
* @throws SchedulerNotFoundException
|
||||
*/
|
||||
public synchronized void stop(UUID uuid, boolean remove)
|
||||
throws Exception {
|
||||
public synchronized void stop(UUID uuid, boolean remove) throws Exception {
|
||||
|
||||
JobKey jobKey = new JobKey(uuid.toString());
|
||||
LaunchParameter launchParameter = getLaunchParameter(jobKey);
|
||||
if(launchParameter==null) {
|
||||
if(launchParameter == null) {
|
||||
throw new ExecutorException("No plugin with UUID " + uuid.toString() + " found.");
|
||||
}
|
||||
Scheduling scheduling = launchParameter.getScheduling();
|
||||
|
@ -278,28 +274,29 @@ public class SmartExecutorScheduler {
|
|||
|
||||
ScheduledTaskPersistence stc = ScheduledTaskPersistenceFactory.getScheduledTaskPersistence();
|
||||
|
||||
if(scheduled){
|
||||
if(remove){
|
||||
if(scheduled) {
|
||||
if(remove) {
|
||||
logger.debug("Going to remove the SmartExecutor Scheduled Task {} from global scheduling", uuid);
|
||||
stc.removeScheduledTask(uuid);
|
||||
}else{
|
||||
if(scheduling.getGlobal()){
|
||||
logger.debug("Going to release the SmartExecutor Scheduled Task {}. The Task can be take in charge from another SmartExecutor instance", uuid);
|
||||
} else {
|
||||
if(scheduling.getGlobal()) {
|
||||
logger.debug(
|
||||
"Going to release the SmartExecutor Scheduled Task {}. The Task can be take in charge from another SmartExecutor instance",
|
||||
uuid);
|
||||
stc.releaseScheduledTask(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void stopAll() throws SchedulerException {
|
||||
List<UUID> set = new ArrayList<UUID>(scheduledJobs);
|
||||
for (UUID uuid : set) {
|
||||
for(UUID uuid : set) {
|
||||
try {
|
||||
stop(uuid, false);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error stopping plugin instace with UUID {}",
|
||||
uuid, e);
|
||||
} catch(Exception e) {
|
||||
logger.error("Error stopping plugin instace with UUID {}", uuid, e);
|
||||
}
|
||||
}
|
||||
scheduler.clear();
|
||||
|
|
|
@ -10,7 +10,10 @@ import java.util.Properties;
|
|||
import org.gcube.common.authorization.client.Constants;
|
||||
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
||||
import org.gcube.common.authorization.library.provider.ClientInfo;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.authorization.library.utils.Caller;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -25,69 +28,56 @@ public class ContextTest {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ContextTest.class);
|
||||
|
||||
protected static final String PROPERTIES_FILENAME = "token.properties";
|
||||
protected static Properties properties;
|
||||
protected static final String PROPERTIES_FILENAME = "token.properties";
|
||||
|
||||
private static final String GCUBE_DEVNEXT_VARNAME = "GCUBE_DEVNEXT";
|
||||
public static final String GCUBE_DEVNEXT;
|
||||
|
||||
private static final String GCUBE_DEVNEXT_NEXTNEXT_VARNAME = "GCUBE_DEVNEXT_NEXTNEXT";
|
||||
public static final String GCUBE_DEVNEXT_NEXTNEXT;
|
||||
|
||||
public static final String GCUBE_DEVSEC_VARNAME = "GCUBE_DEVSEC";
|
||||
public static final String GCUBE_DEVSEC;
|
||||
|
||||
public static final String GCUBE_DEVSEC_DEVVRE_VARNAME = "GCUBE_DEVSEC_DEVVRE";
|
||||
public static final String GCUBE_DEVSEC_DEVVRE;
|
||||
|
||||
public static final String DEFAULT_TEST_SCOPE;
|
||||
public static final String ALTERNATIVE_TEST_SCOPE;
|
||||
|
||||
public static final String ROOT_VARNAME = "ROOT";
|
||||
public static final String ROOT;
|
||||
public static final String DEFAULT_TEST_SCOPE_NAME;
|
||||
|
||||
static {
|
||||
Properties properties = new Properties();
|
||||
properties = new Properties();
|
||||
InputStream input = ContextTest.class.getClassLoader().getResourceAsStream(PROPERTIES_FILENAME);
|
||||
|
||||
|
||||
try {
|
||||
// load the properties file
|
||||
properties.load(input);
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
GCUBE_DEVNEXT = properties.getProperty(GCUBE_DEVNEXT_VARNAME);
|
||||
GCUBE_DEVNEXT_NEXTNEXT = properties.getProperty(GCUBE_DEVNEXT_NEXTNEXT_VARNAME);
|
||||
|
||||
GCUBE_DEVSEC = properties.getProperty(GCUBE_DEVSEC_VARNAME);
|
||||
GCUBE_DEVSEC_DEVVRE = properties.getProperty(GCUBE_DEVSEC_DEVVRE_VARNAME);
|
||||
|
||||
DEFAULT_TEST_SCOPE = GCUBE_DEVSEC;
|
||||
ALTERNATIVE_TEST_SCOPE = GCUBE_DEVNEXT;
|
||||
|
||||
ROOT = properties.getProperty(ROOT_VARNAME);
|
||||
//DEFAULT_TEST_SCOPE_NAME = "/pred4s/preprod/preVRE";
|
||||
DEFAULT_TEST_SCOPE_NAME = "/gcube/devNext/NextNext";
|
||||
}
|
||||
|
||||
public static String getCurrentScope(String token) throws ObjectNotFound, Exception{
|
||||
public static String getCurrentScope(String token) throws ObjectNotFound, Exception {
|
||||
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
||||
String context = authorizationEntry.getContext();
|
||||
logger.info("Context of token {} is {}", token, context);
|
||||
return context;
|
||||
}
|
||||
|
||||
public static void setContextByName(String fullContextName) throws ObjectNotFound, Exception {
|
||||
String token = ContextTest.properties.getProperty(fullContextName);
|
||||
setContext(token);
|
||||
}
|
||||
|
||||
public static void setContext(String token) throws ObjectNotFound, Exception{
|
||||
public static void setContext(String token) throws ObjectNotFound, Exception {
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
||||
ClientInfo clientInfo = authorizationEntry.getClientInfo();
|
||||
logger.debug("User : {} - Type : {}", clientInfo.getId(), clientInfo.getType().name());
|
||||
String qualifier = authorizationEntry.getQualifier();
|
||||
Caller caller = new Caller(clientInfo, qualifier);
|
||||
AuthorizationProvider.instance.set(caller);
|
||||
ScopeProvider.instance.set(getCurrentScope(token));
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception{
|
||||
setContext(DEFAULT_TEST_SCOPE);
|
||||
public static void beforeClass() throws Exception {
|
||||
setContextByName(DEFAULT_TEST_SCOPE_NAME);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception{
|
||||
public static void afterClass() throws Exception {
|
||||
SecurityTokenProvider.instance.reset();
|
||||
ScopeProvider.instance.reset();
|
||||
}
|
||||
|
|
|
@ -4,21 +4,26 @@
|
|||
package org.gcube.vremanagement.executor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.acme.HelloWorldPluginDeclaration;
|
||||
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
|
||||
import org.gcube.vremanagement.executor.api.types.Scheduling;
|
||||
import org.gcube.vremanagement.executor.exception.InvalidPluginStateEvolutionException;
|
||||
import org.gcube.vremanagement.executor.json.ExtendedSEMapper;
|
||||
import org.gcube.vremanagement.executor.json.SEMapper;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginDeclaration;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginState;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginStateEvolution;
|
||||
import org.gcube.vremanagement.executor.plugin.Ref;
|
||||
import org.gcube.vremanagement.executor.plugin.RunOn;
|
||||
import org.gcube.vremanagement.executor.pluginmanager.PluginManager;
|
||||
import org.gcube.vremanagement.executor.scheduledtask.ScheduledTask;
|
||||
import org.gcube.vremanagement.helloworld.HelloWorldPluginDeclaration;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -32,12 +37,12 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
*
|
||||
*/
|
||||
public class SerializationTest extends ContextTest {
|
||||
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(SerializationTest.class);
|
||||
|
||||
@Test
|
||||
public void testScheduling() throws JsonGenerationException, JsonMappingException, IOException {
|
||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||
Map<String,Object> inputs = new HashMap<String,Object>();
|
||||
inputs.put("Hello", "World");
|
||||
long sleepTime = 10000;
|
||||
inputs.put("sleepTime", sleepTime);
|
||||
|
@ -52,13 +57,14 @@ public class SerializationTest extends ContextTest {
|
|||
String launchParameterJSONString = objectMapper.writeValueAsString(launchParameter);
|
||||
logger.debug("Marshalled : {}", launchParameterJSONString);
|
||||
|
||||
LaunchParameter launchParameterUnmarshalled = objectMapper.readValue(launchParameterJSONString, LaunchParameter.class);
|
||||
logger.debug("UnMarshalled : {}", launchParameterUnmarshalled);
|
||||
LaunchParameter launchParameterUnmarshalled = objectMapper.readValue(launchParameterJSONString,
|
||||
LaunchParameter.class);
|
||||
logger.debug("UnMarshalled : {}", launchParameterUnmarshalled);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScheduledTask() throws JsonGenerationException, JsonMappingException, IOException {
|
||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||
Map<String,Object> inputs = new HashMap<String,Object>();
|
||||
inputs.put("Hello", "World");
|
||||
long sleepTime = 10000;
|
||||
inputs.put("sleepTime", sleepTime);
|
||||
|
@ -74,31 +80,79 @@ public class SerializationTest extends ContextTest {
|
|||
ScheduledTask scheduledTask = new ScheduledTask(uuid, launchParameter, runOn);
|
||||
logger.debug("{} to be Marshalled : {}", scheduledTask.getClass().getSimpleName(), launchParameter);
|
||||
|
||||
|
||||
ObjectMapper mapper = SEMapper.getObjectMapper();
|
||||
String scheduledTaskJSONString = mapper.writeValueAsString(scheduledTask);
|
||||
String scheduledTaskJSONString = ExtendedSEMapper.getInstance().marshal(scheduledTask);
|
||||
logger.debug("Marshalled : {}", scheduledTaskJSONString);
|
||||
|
||||
ScheduledTask scheduledTaskUnmarshalled = mapper.readValue(scheduledTaskJSONString, ScheduledTask.class);
|
||||
logger.debug("UnMarshalled : {}", scheduledTaskUnmarshalled);
|
||||
|
||||
|
||||
|
||||
|
||||
ScheduledTask scheduledTaskUnmarshalled = ExtendedSEMapper.getInstance().unmarshal(ScheduledTask.class,
|
||||
scheduledTaskJSONString);
|
||||
logger.debug("UnMarshalled : {}", scheduledTaskUnmarshalled);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPluginEvolutionState() throws JsonGenerationException, JsonMappingException, IOException, InvalidPluginStateEvolutionException {
|
||||
public void testPluginEvolutionState()
|
||||
throws JsonGenerationException, JsonMappingException, IOException, InvalidPluginStateEvolutionException {
|
||||
|
||||
PluginStateEvolution pes = new PluginStateEvolution(UUID.randomUUID(), 1, Calendar.getInstance().getTimeInMillis(), new HelloWorldPluginDeclaration(), PluginState.RUNNING, 10);
|
||||
PluginStateEvolution pes = new PluginStateEvolution(UUID.randomUUID(), 1,
|
||||
Calendar.getInstance().getTimeInMillis(), new HelloWorldPluginDeclaration(), PluginState.RUNNING, 10);
|
||||
logger.debug("{} to be Marshalled : {}", pes.getClass().getSimpleName(), pes);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String scheduledTaskJSONString = objectMapper.writeValueAsString(pes);
|
||||
logger.debug("Marshalled : {}", scheduledTaskJSONString);
|
||||
|
||||
PluginStateEvolution pesUnmarshalled = objectMapper.readValue(scheduledTaskJSONString, PluginStateEvolution.class);
|
||||
logger.debug("UnMarshalled : {}", pesUnmarshalled);
|
||||
PluginStateEvolution pesUnmarshalled = objectMapper.readValue(scheduledTaskJSONString,
|
||||
PluginStateEvolution.class);
|
||||
logger.debug("UnMarshalled : {}", pesUnmarshalled);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAvailablePluginMarshalling() throws Exception {
|
||||
HelloWorldPluginDeclaration helloWorldPluginDeclaration = new HelloWorldPluginDeclaration();
|
||||
logger.debug("{}", ExtendedSEMapper.getInstance().marshal(helloWorldPluginDeclaration));
|
||||
|
||||
PluginManager pluginManager = PluginManager.getInstance();
|
||||
Map<String,PluginDeclaration> availablePlugins = pluginManager.getAvailablePlugins();
|
||||
List<PluginDeclaration> plugins = new ArrayList<PluginDeclaration>(availablePlugins.values());
|
||||
String list = ExtendedSEMapper.getInstance().marshal(PluginDeclaration.class, plugins);
|
||||
logger.debug("Plugins are :\n{}", list);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
String scheduled = "[{" + "\"@class\":\"ScheduledTask\"," + "\"uuid\":\"d9d9bc94-b1ac-43e2-ada7-0da8045b637f\","
|
||||
+ "\"scope\":\"/gcube/devNext/NextNext\","
|
||||
+ "\"token\":\"abcdef-7f6e-49cd-9a34-909cd3832f3e-98187548\"," + "\"clientInfo\":{"
|
||||
+ " \"@class\":\"UserInfo\",\"roles\":[\"OrganizationMember\"],\"id\":null,\"type\":\"USER\"" + "},"
|
||||
+ "\"runOn\":{" + " \"@class\":\"RunOn\"," + " \"hostingNode\":{"
|
||||
+ " \"@class\":\"Ref\",\"id\":\"5f51c684-dd23-4d0e-a19d-9710ce34056a\","
|
||||
+ " \"address\":\"pc-frosini.isti.cnr.it:8080\"" + " }," + " \"eService\":{"
|
||||
+ " \"@class\":\"Ref\",\"id\":\"5f51c684-dd23-4d0e-a19d-9710ce34056a\","
|
||||
+ " \"address\":\"pc-frosini.isti.cnr.it:8080\"" + " }" + "}," + "\"launchParameter\":{"
|
||||
+ " \"@class\":\"LaunchParameter\",\"pluginCapabilities\":null," + " \"inputs\":{"
|
||||
+ " \"Hello\":\"World\",\"sleepTime\":10000" + " },"
|
||||
+ " \"pluginStateNotifications\":{" + " \"org.acme.HWPluginStateNotification\":{"
|
||||
+ " \"Hello\":\"Hello World Notification :) :)\"" + " }},"
|
||||
+ " \"scheduling\":{" + " \"@class\":\"Scheduling\",\"cronExpression\":null,"
|
||||
+ " \"delay\":120,\"schedulingTimes\":4,\"firstStartTime\":null,\"endTime\":null,"
|
||||
+ " \"previuosExecutionsMustBeCompleted\":true,\"global\":false" + " },"
|
||||
+ " \"pluginName\":\"HelloWorld\"," + " \"pluginVersion\":null" + " }" + "}]";
|
||||
List<ScheduledTask> scheduledTasks = ExtendedSEMapper.getInstance().unmarshalList(ScheduledTask.class,
|
||||
scheduled);
|
||||
|
||||
String complete = ExtendedSEMapper.getInstance().marshal(ScheduledTask.class, scheduledTasks);
|
||||
logger.debug("ExtendedSEMapper : {}", complete);
|
||||
|
||||
List<org.gcube.vremanagement.executor.plugin.ScheduledTask> tasks = new ArrayList<>();
|
||||
for(ScheduledTask scheduledTask : scheduledTasks) {
|
||||
org.gcube.vremanagement.executor.plugin.ScheduledTask task = new org.gcube.vremanagement.executor.plugin.ScheduledTask(
|
||||
scheduledTask.getUUID(), scheduledTask.getRunOn(), scheduledTask.getLaunchParameter());
|
||||
tasks.add(task);
|
||||
}
|
||||
|
||||
String marshalled = SEMapper.getInstance().marshal(org.gcube.vremanagement.executor.plugin.ScheduledTask.class,
|
||||
tasks);
|
||||
logger.debug("SEMapper : {}", marshalled);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,11 +7,11 @@ package org.gcube.vremanagement.executor;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.acme.HelloWorldPlugin;
|
||||
import org.acme.HelloWorldPluginDeclaration;
|
||||
import org.gcube.vremanagement.executor.plugin.Plugin;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginDeclaration;
|
||||
import org.gcube.vremanagement.executor.pluginmanager.PluginManager;
|
||||
import org.gcube.vremanagement.helloworld.HelloWorldPlugin;
|
||||
import org.gcube.vremanagement.helloworld.HelloWorldPluginDeclaration;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
|
|||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.gcube.resources.discovery.icclient.ICFactory;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -73,10 +72,10 @@ public class SmartExecutorInizializatorTest {
|
|||
logger.debug("{} with ID {} removed successfully", resource.getClass().getSimpleName(), id);
|
||||
}
|
||||
|
||||
@Test
|
||||
// @Test
|
||||
public void removeOldInstances() throws Exception{
|
||||
try {
|
||||
setContext(ContextTest.ROOT);
|
||||
//ContextTest.setContextByName("/d4science.research-infrastructures.eu");
|
||||
|
||||
SimpleQuery query = ICFactory.queryFor(ServiceEndpoint.class)
|
||||
.addCondition(String.format("$resource/Profile/Category/text() eq '%s'", "VREManagement"))
|
||||
|
|
|
@ -8,7 +8,6 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.acme.HelloWorldPluginDeclaration;
|
||||
import org.gcube.vremanagement.executor.ContextTest;
|
||||
import org.gcube.vremanagement.executor.persistence.orientdb.OrientDBPersistenceConnector;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginState;
|
||||
|
@ -16,6 +15,7 @@ import org.gcube.vremanagement.executor.plugin.PluginStateEvolution;
|
|||
import org.gcube.vremanagement.executor.scheduledtask.ScheduledTask;
|
||||
import org.gcube.vremanagement.executor.scheduledtask.ScheduledTaskPersistence;
|
||||
import org.gcube.vremanagement.executor.scheduledtask.ScheduledTaskPersistenceFactory;
|
||||
import org.gcube.vremanagement.helloworld.HelloWorldPluginDeclaration;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
@ -2,8 +2,8 @@ package org.gcube.vremanagement.executor.pluginmanager;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.acme.HelloWorldPluginDeclaration;
|
||||
import org.gcube.vremanagement.executor.ContextTest;
|
||||
import org.gcube.vremanagement.helloworld.HelloWorldPluginDeclaration;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.acme.HelloWorldPlugin;
|
||||
import org.acme.HelloWorldPluginDeclaration;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.vremanagement.executor.ContextTest;
|
||||
import org.gcube.vremanagement.executor.exception.InputsNullException;
|
||||
|
@ -17,6 +15,8 @@ import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConn
|
|||
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceFactory;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginState;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginStateNotification;
|
||||
import org.gcube.vremanagement.helloworld.HelloWorldPlugin;
|
||||
import org.gcube.vremanagement.helloworld.HelloWorldPluginDeclaration;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
@ -8,8 +8,6 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.acme.HelloWorldPlugin;
|
||||
import org.acme.HelloWorldPluginDeclaration;
|
||||
import org.gcube.vremanagement.executor.ContextTest;
|
||||
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
|
||||
import org.gcube.vremanagement.executor.api.types.Scheduling;
|
||||
|
@ -21,6 +19,8 @@ import org.gcube.vremanagement.executor.plugin.PluginState;
|
|||
import org.gcube.vremanagement.executor.plugin.PluginStateEvolution;
|
||||
import org.gcube.vremanagement.executor.scheduler.SmartExecutorScheduler;
|
||||
import org.gcube.vremanagement.executor.scheduler.SmartExecutorSchedulerFactory;
|
||||
import org.gcube.vremanagement.helloworld.HelloWorldPlugin;
|
||||
import org.gcube.vremanagement.helloworld.HelloWorldPluginDeclaration;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.quartz.CronExpression;
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
*.gcubekey
|
||||
token.properties
|
|
@ -9,7 +9,8 @@
|
|||
</appender>
|
||||
|
||||
|
||||
<logger name="org.gcube" level="TRACE" />
|
||||
<logger name="org.gcube" level="INFO" />
|
||||
<logger name="org.gcube.vremanagement.executor" level="TRACE" />
|
||||
|
||||
<root level="WARN">
|
||||
<appender-ref ref="STDOUT" />
|
||||
|
|
Loading…
Reference in New Issue