diff --git a/.classpath b/.classpath
index 9d886d5..ace8266 100644
--- a/.classpath
+++ b/.classpath
@@ -27,7 +27,7 @@
-
+
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..29abf99
--- /dev/null
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,6 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding//src/main/resources=UTF-8
+encoding//src/test/java=UTF-8
+encoding//src/test/resources=UTF-8
+encoding/=UTF-8
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..714351a
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/pom.xml b/pom.xml
index 4d658a8..1878df6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
org.gcube.vremanagement
smart-executor
- 2.0.0-SNAPSHOT
+ 2.0.0
SmartExecutor
Smart Executor Service
war
@@ -22,7 +22,12 @@
${project.basedir}/distro
VREManagement
https://wiki.gcube-system.org/gcube/SmartExecutor
- 2.2.3
+ 3.0.15
+
+ 2.6.0
+ 2.6.0
@@ -33,24 +38,10 @@
-
- org.gcube.distribution
- gcube-bom
- LATEST
- pom
- import
-
org.gcube.distribution
gcube-smartgears-bom
- LATEST
- pom
- import
-
-
- org.gcube.information-system
- information-system-bom
- LATEST
+ 1.1.0
pom
import
@@ -62,84 +53,42 @@
org.gcube.resources.discovery
ic-client
- provided
org.gcube.resources.discovery
discovery-client
- provided
-
- org.gcube.core
- common-scope
- provided
-
-
org.gcube.core
common-smartgears
- provided
org.gcube.core
common-encryption
- provided
- org.gcube.resources
- common-gcore-resources
- provided
+ org.gcube.core
+ common-smartgears-app
+
- org.gcube.common
- authorization-client
- provided
+ com.orientechnologies
+ orientdb-client
+ ${orientdb.version}
+
- org.gcube.common
- common-authorization
- provided
+ org.gcube.vremanagement
+ smart-executor-api
+ [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)
org.gcube.vremanagement
smart-executor-client
[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)
-
- com.fasterxml.jackson.core
- jackson-databind
- provided
-
-
- com.fasterxml.jackson.core
- jackson-annotations
- provided
-
-
-
- com.fasterxml.jackson.core
- jackson-core
- provided
-
-
-
-
- org.gcube.core
- common-generic-clients
-
-
- org.gcube.core
- common-smartgears-app
-
-
- com.orientechnologies
- orientdb-client
-
-
- org.gcube.vremanagement
- smart-executor-api
- [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)
-
+
+
@@ -161,7 +110,6 @@
org.slf4j
slf4j-api
- provided
@@ -209,7 +157,6 @@
org.apache.maven.plugins
maven-war-plugin
- 2.6
${artifactId}
false
diff --git a/src/main/java/org/gcube/vremanagement/executor/persistence/orientdb/OrientDBPersistenceConnector.java b/src/main/java/org/gcube/vremanagement/executor/persistence/orientdb/OrientDBPersistenceConnector.java
index e8b9931..bec3da8 100644
--- a/src/main/java/org/gcube/vremanagement/executor/persistence/orientdb/OrientDBPersistenceConnector.java
+++ b/src/main/java/org/gcube/vremanagement/executor/persistence/orientdb/OrientDBPersistenceConnector.java
@@ -66,6 +66,7 @@ public class OrientDBPersistenceConnector extends SmartExecutorPersistenceConnec
oDatabasePool.close();
}
+ @Override
public PluginStateEvolution getPluginInstanceState(UUID uuid, Integer iterationNumber)
throws PluginInstanceNotFoundException, ExecutorException {
ODatabaseSession oDatabaseSession = null;
@@ -121,7 +122,7 @@ public class OrientDBPersistenceConnector extends SmartExecutorPersistenceConnec
return pluginStateEvolution;
} catch(Exception e) {
- throw new PluginInstanceNotFoundException();
+ throw new PluginInstanceNotFoundException(uuid);
} finally {
if(oDatabaseSession != null) {
oDatabaseSession.close();
diff --git a/src/main/java/org/gcube/vremanagement/executor/rest/ExecutorExceptionMapper.java b/src/main/java/org/gcube/vremanagement/executor/rest/ExecutorExceptionMapper.java
index 834f9a5..3c43e7f 100644
--- a/src/main/java/org/gcube/vremanagement/executor/rest/ExecutorExceptionMapper.java
+++ b/src/main/java/org/gcube/vremanagement/executor/rest/ExecutorExceptionMapper.java
@@ -7,6 +7,11 @@ import javax.ws.rs.core.Response.Status;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
+import org.gcube.vremanagement.executor.exception.InputsNullException;
+import org.gcube.vremanagement.executor.exception.InvalidInputsException;
+import org.gcube.vremanagement.executor.exception.PluginInstanceNotFoundException;
+import org.gcube.vremanagement.executor.exception.PluginNotFoundException;
+
/**
* @author Luca Frosini (ISTI - CNR)
*/
@@ -20,12 +25,21 @@ public class ExecutorExceptionMapper implements ExceptionMapper {
String exceptionMessage = exception.getMessage();
MediaType mediaType = MediaType.TEXT_PLAIN_TYPE;
+ Class extends Exception> clz = exception.getClass();
- if(WebApplicationException.class.isAssignableFrom(exception.getClass())) {
+ if(WebApplicationException.class.isAssignableFrom(clz)) {
Response gotResponse = ((WebApplicationException) exception).getResponse();
status = Status.fromStatusCode(gotResponse.getStatusInfo().getStatusCode());
}
+ if(PluginInstanceNotFoundException.class.isAssignableFrom(clz)|| PluginNotFoundException.class.isAssignableFrom(clz)) {
+ status = Status.NOT_FOUND;
+ }
+
+ if(InputsNullException.class.isAssignableFrom(clz) || InvalidInputsException.class.isAssignableFrom(clz)) {
+ status = Status.BAD_REQUEST;
+ }
+
return Response.status(status).entity(exceptionMessage).type(mediaType).build();
}
diff --git a/src/main/java/org/gcube/vremanagement/executor/rest/RestSmartExecutor.java b/src/main/java/org/gcube/vremanagement/executor/rest/RestSmartExecutor.java
index bf50130..2d9531a 100644
--- a/src/main/java/org/gcube/vremanagement/executor/rest/RestSmartExecutor.java
+++ b/src/main/java/org/gcube/vremanagement/executor/rest/RestSmartExecutor.java
@@ -8,7 +8,6 @@ import java.util.UUID;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
-import javax.ws.rs.HttpMethod;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
@@ -16,14 +15,15 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
import org.gcube.vremanagement.executor.ResourceInitializer;
import org.gcube.vremanagement.executor.annotation.PURGE;
import org.gcube.vremanagement.executor.api.rest.RestConstants;
-import org.gcube.vremanagement.executor.api.rest.SmartExecutor;
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
import org.gcube.vremanagement.executor.exception.ExecutorException;
import org.gcube.vremanagement.executor.exception.InputsNullException;
@@ -47,7 +47,7 @@ import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonProcessingException;
@Path(RestConstants.PLUGINS_PATH_PART)
-public class RestSmartExecutor implements SmartExecutor {
+public class RestSmartExecutor {
private static Logger logger = LoggerFactory.getLogger(RestSmartExecutor.class);
@@ -73,9 +73,9 @@ public class RestSmartExecutor implements SmartExecutor {
@GET
@Path("")
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
- @Override
public String getAvailablePlugins() throws ExecutorException {
- setCalledMethod(HttpMethod.GET + " /" + RestConstants.PLUGINS_PATH_PART);
+ //setCalledMethod(HttpMethod.GET + " /" + RestConstants.PLUGINS_PATH_PART);
+ setCalledMethod("getAvailablePlugins");
try {
PluginManager pluginManager = PluginManager.getInstance();
Map availablePlugins = pluginManager.getAvailablePlugins();
@@ -89,17 +89,16 @@ public class RestSmartExecutor implements SmartExecutor {
@GET
@Path("/{" + PLUGIN_NAME_PATH_PARAM + "}/" + RestConstants.EXECUTIONS_PATH_PART)
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
- @Override
public String getScheduled(@PathParam(PLUGIN_NAME_PATH_PARAM) String pluginName) throws ExecutorException {
- setCalledMethod(HttpMethod.GET + " /" + RestConstants.PLUGINS_PATH_PART + "/"
- + pluginName + "/" + RestConstants.EXECUTIONS_PATH_PART);
+ // setCalledMethod(HttpMethod.GET + " /" + RestConstants.PLUGINS_PATH_PART + "/" + pluginName + "/" + RestConstants.EXECUTIONS_PATH_PART);
+ setCalledMethod("getScheduledExecution");
try {
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceFactory
.getPersistenceConnector();
List pluginDeclarations = new ArrayList<>();
- if(pluginName.compareTo(ORPHAN_PATH_PARAM)!=0) {
+ if(pluginName.compareTo(RestConstants.ORPHAN_PATH_PARAM)!=0) {
PluginManager pluginManager = PluginManager.getInstance();
Map availablePlugins = pluginManager.getAvailablePlugins();
PluginDeclaration pluginDeclaration = availablePlugins.get(pluginName);
@@ -146,11 +145,10 @@ public class RestSmartExecutor implements SmartExecutor {
@Path("/{" + PLUGIN_NAME_PATH_PARAM + "}/" + RestConstants.EXECUTIONS_PATH_PART)
@Consumes({MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8})
@Produces(MediaType.TEXT_PLAIN)
- @Override
public String launch(@PathParam(PLUGIN_NAME_PATH_PARAM) String pluginName, String launchParameterString)
throws ExecutorException {
- setCalledMethod(HttpMethod.POST + " /" + RestConstants.PLUGINS_PATH_PART + "/"
- + pluginName + "/" + RestConstants.EXECUTIONS_PATH_PART);
+ //setCalledMethod(HttpMethod.POST + " /" + RestConstants.PLUGINS_PATH_PART + "/" + pluginName + "/" + RestConstants.EXECUTIONS_PATH_PART);
+ setCalledMethod("execute");
try {
logger.info("Requested to launch {} ({})", pluginName, launchParameterString);
@@ -184,13 +182,12 @@ public class RestSmartExecutor implements SmartExecutor {
@GET
@Path("/{" + PLUGIN_NAME_PATH_PARAM + "}/" + RestConstants.EXECUTIONS_PATH_PART + "/" + "{" + UUID_PATH_PARAM + "}")
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
- @Override
public String getLaunchState(@PathParam(PLUGIN_NAME_PATH_PARAM) String pluginName,
@PathParam(UUID_PATH_PARAM) String executionIdentifier,
@QueryParam(RestConstants.ITERATION_PARAM) Integer iteration) throws ExecutorException {
- setCalledMethod(HttpMethod.GET + " /" + RestConstants.PLUGINS_PATH_PART + "/"
- + pluginName + "/" + RestConstants.EXECUTIONS_PATH_PART + "/{" + UUID_PATH_PARAM + "}");
+ // setCalledMethod(HttpMethod.GET + " /" + RestConstants.PLUGINS_PATH_PART + "/" + pluginName + "/" + RestConstants.EXECUTIONS_PATH_PART + "/{" + UUID_PATH_PARAM + "}");
+ setCalledMethod("getState");
PluginStateEvolution pluginStateEvolution = null;
try {
@@ -222,8 +219,7 @@ public class RestSmartExecutor implements SmartExecutor {
@DELETE
@Path("/{" + PLUGIN_NAME_PATH_PARAM + "}/" + RestConstants.EXECUTIONS_PATH_PART + "/" + "{" + UUID_PATH_PARAM + "}")
- @Override
- public boolean delete(@PathParam(PLUGIN_NAME_PATH_PARAM) String pluginName,
+ public Response delete(@PathParam(PLUGIN_NAME_PATH_PARAM) String pluginName,
@PathParam(UUID_PATH_PARAM) String executionIdentifier,
@QueryParam(RestConstants.UNSCHEDULE_PARAM) Boolean unschedule) throws ExecutorException {
@@ -232,6 +228,7 @@ public class RestSmartExecutor implements SmartExecutor {
unschedule = false;
}
+ /*
if(unschedule) {
setCalledMethod(PURGE.class.getSimpleName() + " /" + RestConstants.PLUGINS_PATH_PART + "/" + pluginName
+ "/" + RestConstants.EXECUTIONS_PATH_PART + "/{" + UUID_PATH_PARAM + "}");
@@ -239,6 +236,9 @@ public class RestSmartExecutor implements SmartExecutor {
setCalledMethod(HttpMethod.DELETE + " /" + RestConstants.PLUGINS_PATH_PART + "/"
+ pluginName + "/" + RestConstants.EXECUTIONS_PATH_PART + "/{" + UUID_PATH_PARAM + "}");
}
+ */
+
+ setCalledMethod("stop");
logger.info("Requested to delete for {} with UUID {}{}", pluginName, executionIdentifier,
unschedule ? "globally" : "");
@@ -269,7 +269,11 @@ public class RestSmartExecutor implements SmartExecutor {
}
logger.info("{} with UUID {} was{} stopped successfully", pluginName, executionIdentifier,
currentStopped ? "" : " NOT");
- return currentStopped;
+ if(currentStopped) {
+ return Response.status(Status.NO_CONTENT).build();
+ }else {
+ throw new ExecutorException(pluginName + " with UUID " + executionIdentifier + " was NOT stopped successfully");
+ }
} catch(ExecutorException e) {
throw e;
} catch(Exception e) {
@@ -279,8 +283,7 @@ public class RestSmartExecutor implements SmartExecutor {
@PURGE
@Path("/{" + PLUGIN_NAME_PATH_PARAM + "}/" + RestConstants.EXECUTIONS_PATH_PART + "/" + "{" + UUID_PATH_PARAM + "}")
- @Override
- public boolean purge(@PathParam(PLUGIN_NAME_PATH_PARAM) String pluginName,
+ public Response purge(@PathParam(PLUGIN_NAME_PATH_PARAM) String pluginName,
@PathParam(UUID_PATH_PARAM) String executionIdentifier) throws ExecutorException {
return delete(pluginName, executionIdentifier, true);
}
diff --git a/src/main/java/org/gcube/vremanagement/executor/scheduler/SmartExecutorScheduler.java b/src/main/java/org/gcube/vremanagement/executor/scheduler/SmartExecutorScheduler.java
index 37ed1ef..f35e66d 100644
--- a/src/main/java/org/gcube/vremanagement/executor/scheduler/SmartExecutorScheduler.java
+++ b/src/main/java/org/gcube/vremanagement/executor/scheduler/SmartExecutorScheduler.java
@@ -14,9 +14,9 @@ import java.util.UUID;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
import org.gcube.vremanagement.executor.api.types.Scheduling;
-import org.gcube.vremanagement.executor.exception.ExecutorException;
import org.gcube.vremanagement.executor.exception.InputsNullException;
import org.gcube.vremanagement.executor.exception.LaunchException;
+import org.gcube.vremanagement.executor.exception.PluginInstanceNotFoundException;
import org.gcube.vremanagement.executor.exception.PluginNotFoundException;
import org.gcube.vremanagement.executor.exception.SchedulerNotFoundException;
import org.gcube.vremanagement.executor.exception.UnableToInterruptTaskException;
@@ -276,7 +276,7 @@ public class SmartExecutorScheduler {
}
}
- throw new ExecutorException("No plugin with UUID " + uuid.toString() + " found.");
+ throw new PluginInstanceNotFoundException(uuid);
}
Scheduling scheduling = launchParameter.getScheduling();
boolean scheduled = scheduling != null ? true : false;