Cleaning code
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/vre-management/smart-executor@119514 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f81ffa5377
commit
39f6dde527
|
@ -5,9 +5,6 @@
|
|||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
<dependent-module archiveName="common-smartgears-app-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/common-smartgears-app/common-smartgears-app">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module archiveName="smart-executor-api-1.2.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-executor-api/smart-executor-api">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
|
|
3
pom.xml
3
pom.xml
|
@ -52,14 +52,17 @@
|
|||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-smartgears</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-smartgears-app</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.vremanagement</groupId>
|
||||
|
|
|
@ -11,6 +11,7 @@ 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.SchedulePersistenceException;
|
||||
import org.gcube.vremanagement.executor.exception.SchedulerNotFoundException;
|
||||
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConnector;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginState;
|
||||
|
@ -57,12 +58,15 @@ public class SmartExecutorImpl implements SmartExecutor {
|
|||
smartExecutorScheduler.stop(uuid);
|
||||
} catch (SchedulerNotFoundException snfe) {
|
||||
currentStopped = true;
|
||||
logger.error(String.format("Error unscheduling task {}", executionIdentifier), snfe);
|
||||
} catch(SchedulerException e){
|
||||
currentStopped = false;
|
||||
logger.error(String.format("Error unscheduling task {}", executionIdentifier), e);
|
||||
} catch(SchedulePersistenceException ex){
|
||||
currentStopped = true;
|
||||
logger.error("Error removing scheduled task from persistence.", ex);
|
||||
}
|
||||
|
||||
// TODO Remove from configuration
|
||||
|
||||
return currentStopped;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.gcube.vremanagement.executor.api.types.Scheduling;
|
|||
import org.gcube.vremanagement.executor.exception.AlreadyInFinalStateException;
|
||||
import org.gcube.vremanagement.executor.exception.InputsNullException;
|
||||
import org.gcube.vremanagement.executor.exception.PluginNotFoundException;
|
||||
import org.gcube.vremanagement.executor.exception.SchedulePersistenceException;
|
||||
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConnector;
|
||||
import org.gcube.vremanagement.executor.plugin.Plugin;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginDeclaration;
|
||||
|
@ -179,7 +180,7 @@ public class SmartExecutorJob implements InterruptableJob {
|
|||
logger.debug("The Scheduled Max Number of execution ({}) is reached. The Job {} will be descheduled", maxExecutionNumber, uuid);
|
||||
try {
|
||||
deschedule();
|
||||
} catch (SchedulerException e) {
|
||||
} catch (SchedulerException | SchedulePersistenceException e) {
|
||||
throw new JobExecutionException(e);
|
||||
}
|
||||
return;
|
||||
|
@ -264,7 +265,7 @@ public class SmartExecutorJob implements InterruptableJob {
|
|||
return false;
|
||||
}
|
||||
|
||||
protected void deschedule() throws SchedulerException{
|
||||
protected void deschedule() throws SchedulerException, SchedulePersistenceException{
|
||||
SmartExecutorScheduler.getInstance().stop(uuid);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.gcube.vremanagement.executor.configuration.ScheduledTaskConfiguration
|
|||
import org.gcube.vremanagement.executor.exception.InputsNullException;
|
||||
import org.gcube.vremanagement.executor.exception.LaunchException;
|
||||
import org.gcube.vremanagement.executor.exception.PluginNotFoundException;
|
||||
import org.gcube.vremanagement.executor.exception.SchedulePersistenceException;
|
||||
import org.gcube.vremanagement.executor.exception.SchedulerNotFoundException;
|
||||
import org.quartz.CronScheduleBuilder;
|
||||
import org.quartz.JobBuilder;
|
||||
|
@ -186,7 +187,7 @@ public class SmartExecutorScheduler {
|
|||
return activeSchedulers.get(key);
|
||||
}
|
||||
|
||||
public synchronized void stop(UUID uuid) throws SchedulerException {
|
||||
public synchronized void stop(UUID uuid) throws SchedulerException, SchedulePersistenceException {
|
||||
Scheduler scheduler = activeSchedulers.get(uuid);
|
||||
if(scheduler==null){
|
||||
throw new SchedulerNotFoundException("Scheduler Not Found");
|
||||
|
@ -225,6 +226,21 @@ public class SmartExecutorScheduler {
|
|||
|
||||
activeSchedulers.remove(uuid);
|
||||
scheduler.clear();
|
||||
|
||||
|
||||
// TODO check if are
|
||||
boolean remove = true;
|
||||
try {
|
||||
ScheduledTaskConfiguration stc = ScheduledTaskConfigurationFactory.getLaunchConfiguration();
|
||||
if(remove){
|
||||
stc.removeScheduledTask(uuid);
|
||||
}else{
|
||||
stc.releaseScheduledTask(uuid);
|
||||
}
|
||||
}catch(Exception e){
|
||||
throw new SchedulePersistenceException(e.getCause());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void stopAll() {
|
||||
|
|
Loading…
Reference in New Issue