Fixing lifecycle management

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/vre-management/smart-executor@119638 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2015-10-12 16:33:47 +00:00
parent 427e6161f7
commit 7d2f4c450d
12 changed files with 176 additions and 128 deletions

View File

@ -4,6 +4,7 @@ import java.util.UUID;
import javax.jws.WebService;
import org.gcube.smartgears.context.application.ApplicationContext;
import org.gcube.vremanagement.executor.api.SmartExecutor;
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
import org.gcube.vremanagement.executor.exception.ExecutorException;
@ -14,6 +15,7 @@ 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.persistence.SmartExecutorPersistenceFactory;
import org.gcube.vremanagement.executor.plugin.PluginState;
import org.gcube.vremanagement.executor.scheduler.SmartExecutorScheduler;
import org.quartz.SchedulerException;
@ -36,6 +38,16 @@ public class SmartExecutorImpl implements SmartExecutor {
*/
private static Logger logger = LoggerFactory.getLogger(SmartExecutorImpl.class);
protected static ApplicationContext ctx;
/**
* @return the ctx
*/
public static ApplicationContext getCtx() {
return ctx;
}
/**{@inheritDoc}*/
@Override
public String launch(LaunchParameter parameter) throws InputsNullException,
@ -76,7 +88,7 @@ public class SmartExecutorImpl implements SmartExecutor {
public PluginState getState(String executionIdentifier)
throws PluginInstanceNotFoundException, ExecutorException {
try {
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceConnector.getPersistenceConnector();
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceFactory.getPersistenceConnector();
return persistenceConnector.getLastPluginInstanceState(UUID.fromString(executionIdentifier));
} catch (Exception e) {
throw new PluginInstanceNotFoundException();
@ -88,7 +100,7 @@ public class SmartExecutorImpl implements SmartExecutor {
public PluginState getIterationState(String executionIdentifier, int iterationNumber)
throws PluginInstanceNotFoundException, ExecutorException {
try {
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceConnector.getPersistenceConnector();
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceFactory.getPersistenceConnector();
return persistenceConnector.getPluginInstanceState(UUID.fromString(executionIdentifier), iterationNumber);
} catch (Exception e) {
throw new PluginInstanceNotFoundException();

View File

@ -6,8 +6,10 @@ package org.gcube.vremanagement.executor;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.xml.bind.annotation.XmlRootElement;
@ -35,6 +37,7 @@ import org.gcube.smartgears.context.application.ApplicationContext;
import org.gcube.smartgears.handlers.application.ApplicationLifecycleEvent;
import org.gcube.smartgears.handlers.application.ApplicationLifecycleHandler;
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.pluginmanager.PluginManager;
import org.gcube.vremanagement.executor.scheduler.SmartExecutorScheduler;
@ -55,22 +58,24 @@ public class SmartExecutorInitializator extends ApplicationLifecycleHandler {
public static final long JOIN_TIMEOUT = 1000;
/**
/* *
* Contains the ServiceEnpoint Resource to be published/unpublished on IS
*/
* /
private static ServiceEndpoint serviceEndpoint;
*/
/**
/* *
* The application context
*/
* /
protected static ApplicationContext ctx;
/**
* @return the ctx
*/
* /
public static ApplicationContext getCtx() {
return ctx;
}
*/
/*
protected static ScheduledTaskConfiguration launchConfiguration;
@ -179,17 +184,17 @@ public class SmartExecutorInitializator extends ApplicationLifecycleHandler {
protected static ServiceEndpoint createServiceEndpoint(){
logger.debug("Getting Available Plugins and their own supported capabilities");
PluginManager pluginManager = PluginManager.getInstance();
logger.debug("Creating ServiceEndpoint to publish on IS available plugins and their own supported capabilities");
ServiceEndpoint serviceEndpoint = new ServiceEndpoint();
Profile profile = serviceEndpoint.newProfile();
profile.category(ctx.configuration().serviceClass());
profile.name(ctx.configuration().name());
String version = ctx.configuration().version();
profile.category(SmartExecutorImpl.ctx.configuration().serviceClass());
profile.name(SmartExecutorImpl.ctx.configuration().name());
String version = SmartExecutorImpl.ctx.configuration().version();
profile.version(version);
profile.description(ctx.configuration().description());
profile.description(SmartExecutorImpl.ctx.configuration().description());
String runningOn = getRunningOn(ctx.container().configuration());
String runningOn = getRunningOn(SmartExecutorImpl.ctx.container().configuration());
Platform platform = profile.newPlatform();
platform.name(runningOn);
@ -201,7 +206,7 @@ public class SmartExecutorInitializator extends ApplicationLifecycleHandler {
Runtime runtime = profile.newRuntime();
runtime.hostedOn(runningOn);
runtime.status(ctx.configuration().mode().toString());
runtime.status(SmartExecutorImpl.ctx.configuration().mode().toString());
Group<AccessPoint> accessPoints = profile.accessPoints();
Map<String, PluginDeclaration> availablePlugins = pluginManager.getAvailablePlugins();
@ -237,28 +242,55 @@ public class SmartExecutorInitializator extends ApplicationLifecycleHandler {
}
public static List<String> getScopes(ApplicationContext applicationContext){
Collection<String> scopes;
ScopeGroup<String> scopeGroup = applicationContext.profile(GCoreEndpoint.class).scopes();
Collection<String> scopes = scopeGroup.asCollection();
/*
Set<String> applicationScopes = applicationContext.configuration().startScopes();
Set<String> containerScopes = applicationContext.container().configuration().startScopes();
Set<String> scopes;
if(applicationScopes==null || applicationScopes.isEmpty()){
scopes = containerScopes;
logger.debug("Application Scopes ({}). The Container Scopes ({}) will be used.", applicationScopes, scopes);
} else{
logger.debug("Container Scopes ({}). Application Scopes ({}) will be used.", containerScopes, applicationScopes);
scopes = new HashSet<String>(applicationScopes);
if(scopeGroup==null || scopeGroup.isEmpty()){
Set<String> applicationScopes = applicationContext.configuration().startScopes();
Set<String> containerScopes = applicationContext.container().configuration().startScopes();
if(applicationScopes==null || applicationScopes.isEmpty()){
scopes = containerScopes;
logger.debug("Application Scopes ({}). The Container Scopes ({}) will be used.", applicationScopes, scopes);
} else{
logger.debug("Container Scopes ({}). Application Scopes ({}) will be used.", containerScopes, applicationScopes);
scopes = new HashSet<String>(applicationScopes);
}
}else {
scopes = scopeGroup.asCollection();
}
**/
return new ArrayList<String>(scopes);
}
/** {@inheritDoc} */
/*
private void cleanServiceEndpoints(String scope){
try {
SimpleQuery query = ICFactory.queryFor(ServiceEndpoint.class)
.addCondition(String.format("$resource/Profile/Category/text() eq '%s'", SmartExecutorImpl.ctx.configuration().serviceClass()))
.addCondition(String.format("$resource/Profile/Name/text() eq '%s'", SmartExecutorImpl.ctx.configuration().name()))
.addCondition(String.format("$resource/Profile/RunTime/HostedOn/text() eq '%s'", getRunningOn(SmartExecutorImpl.ctx.container().configuration())))
.setResult("$resource");
DiscoveryClient<ServiceEndpoint> client = ICFactory.clientFor(ServiceEndpoint.class);
List<ServiceEndpoint> serviceEndpoints = client.submit(query);
for (ServiceEndpoint serviceEndpoint : serviceEndpoints) {
try {
logger.debug("Trying to unpublish the old ServiceEndpoint with ID {} from scope {}",
serviceEndpoint.id(), scope);
unPublishScopedResource(serviceEndpoint);
} catch(Exception e){
logger.debug("Exception tryng to unpublish the old ServiceEndpoint with ID {} from scope {}",
serviceEndpoint.id(), scope, e);
}
}
}catch(Exception e){
logger.debug("An Exception occur while checking and/or unpublishing old ServiceEndpoint", e);
}
}
/**
* {@inheritDoc}
* The method discover the plugins available on classpath and their own
* supported capabilities and publish a ServiceEndpoint with the
* discovered information.
@ -271,41 +303,23 @@ public class SmartExecutorInitializator extends ApplicationLifecycleHandler {
+ "Smart Executor is Starting\n"
+ "-------------------------------------------------------");
ctx = applicationLifecycleEventStart.context();
SmartExecutorImpl.ctx = applicationLifecycleEventStart.context();
serviceEndpoint = createServiceEndpoint();
ServiceEndpoint serviceEndpoint = createServiceEndpoint();
// Checking if there are old unpublished ServiceEndpoints related to
// this vHN and trying to unpublish them
List<String> scopes = getScopes(ctx);
List<String> scopes = getScopes(SmartExecutorImpl.ctx);
for(String scope : scopes){
ScopeProvider.instance.set(scope);
cleanServiceEndpoints(scope);
try {
ScopeProvider.instance.set(scope);
SimpleQuery query = ICFactory.queryFor(ServiceEndpoint.class)
.addCondition(String.format("$resource/Profile/Category/text() eq '%s'", ctx.configuration().serviceClass()))
.addCondition(String.format("$resource/Profile/Name/text() eq '%s'", ctx.configuration().name()))
.addCondition(String.format("$resource/Profile/RunTime/HostedOn/text() eq '%s'", getRunningOn(ctx.container().configuration())))
.setResult("$resource");
DiscoveryClient<ServiceEndpoint> client = ICFactory.clientFor(ServiceEndpoint.class);
List<ServiceEndpoint> serviceEndpoints = client.submit(query);
for (ServiceEndpoint serviceEndpoint : serviceEndpoints) {
try {
logger.debug("Trying to unpublish the old ServiceEndpoint with ID {} from scope {}",
serviceEndpoint.id(), scope);
unPublishScopedResource(serviceEndpoint);
} catch(Exception e){
logger.debug("Exception tryng to unpublish the old ServiceEndpoint with ID {} from scope {}",
serviceEndpoint.id(), scope, e);
}
}
}catch(Exception e){
logger.debug("An Exception occur while checking and/or unpublishing old ServiceEndpoint", e);
SmartExecutorPersistenceFactory.getPersistenceConnector();
} catch (Exception e) {
logger.error("Unable to isntantiate {} for scope {}",
SmartExecutorPersistenceConnector.class.getSimpleName(), scope, e);
throw new RuntimeException(e);
}
}
@ -321,28 +335,19 @@ public class SmartExecutorInitializator extends ApplicationLifecycleHandler {
logger.error("Unable to Create ServiceEndpoint. the Service will be aborted", e);
return;
}
try {
SmartExecutorPersistenceConnector.getPersistenceConnector();
} catch (Exception e) {
logger.error("Unable to initialize PersistenceConnector. The Service will be aborted", e);
return;
}
logger.trace(
"\n-------------------------------------------------------\n"
+ "Smart Executor Started Successfully\n"
+ "-------------------------------------------------------");
// TODO
// TODO
// TODO Launch initializer thread
// TODO
// TODO
}
/** {@inheritDoc} */
/*
/**
* {@inheritDoc}
* This function is invoked before the service will stop and unpublish the
* resource from the IS to maintain the infrastructure integrity.
* Furthermore close the connection to DB.
@ -356,22 +361,17 @@ public class SmartExecutorInitializator extends ApplicationLifecycleHandler {
SmartExecutorScheduler.getInstance().stopAll();
try {
List<String> scopes = getScopes(ctx);
for(String scope : scopes){
ScopeProvider.instance.set(scope);
unPublishScopedResource(serviceEndpoint);
}
} catch (RegistryNotFoundException e) {
logger.error("Unable to unpublish Service Endpoint.", e);
} catch (Exception e) {
logger.error("Unable to unpublish Service Endpoint.", e);
}
List<String> scopes = getScopes(SmartExecutorImpl.ctx);
try {
SmartExecutorPersistenceConnector.getPersistenceConnector().close();
} catch (Exception e) {
logger.error("Unable to close Persistence", e);
for(String scope : scopes){
ScopeProvider.instance.set(scope);
cleanServiceEndpoints(scope);
try {
SmartExecutorPersistenceFactory.getPersistenceConnector().close();
} catch (Exception e) {
logger.error("Unable to correctly close {} for scope {}",
SmartExecutorPersistenceConnector.class.getSimpleName(), scope, e);
}
}
logger.trace(

View File

@ -3,7 +3,7 @@
*/
package org.gcube.vremanagement.executor.configuration;
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConnector;
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceFactory;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
@ -12,7 +12,7 @@ import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConn
public class ScheduledTaskConfigurationFactory {
public static ScheduledTaskConfiguration getLaunchConfiguration() throws Exception {
return (ScheduledTaskConfiguration) SmartExecutorPersistenceConnector.getPersistenceConnector();
return (ScheduledTaskConfiguration) SmartExecutorPersistenceFactory.getPersistenceConnector();
}
}

View File

@ -13,7 +13,7 @@ import java.util.List;
import java.util.UUID;
import org.apache.commons.io.FileUtils;
import org.gcube.vremanagement.executor.SmartExecutorInitializator;
import org.gcube.vremanagement.executor.SmartExecutorImpl;
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
import org.gcube.vremanagement.executor.api.types.Scheduling;
import org.gcube.vremanagement.executor.configuration.ScheduledTaskConfiguration;
@ -44,7 +44,7 @@ public class FileScheduledTaskConfiguration implements ScheduledTaskConfiguratio
public static final String CONFIG_TASK_FILENAME = "definedTasks.json";
public FileScheduledTaskConfiguration() throws Exception {
this(SmartExecutorInitializator.getCtx().persistence().location());
this(SmartExecutorImpl.getCtx().persistence().location());
}
public FileScheduledTaskConfiguration(String location) throws IOException, JSONException {

View File

@ -5,7 +5,6 @@ package org.gcube.vremanagement.executor.persistence;
import java.util.UUID;
import org.gcube.vremanagement.executor.persistence.couchdb.CouchDBPersistenceConnector;
import org.gcube.vremanagement.executor.plugin.Plugin;
import org.gcube.vremanagement.executor.plugin.PluginState;
import org.gcube.vremanagement.executor.plugin.PluginStateNotification;
@ -20,29 +19,7 @@ import org.gcube.vremanagement.executor.plugin.PluginStateNotification;
*/
public abstract class SmartExecutorPersistenceConnector implements PluginStateNotification {
protected static SmartExecutorPersistenceConnector persistenceConnector;
/**
* @return the persistenceConnector
*/
public static synchronized SmartExecutorPersistenceConnector getPersistenceConnector() throws Exception {
if(SmartExecutorPersistenceConnector.persistenceConnector==null){
SmartExecutorPersistenceConfiguration configuration =
new SmartExecutorPersistenceConfiguration(CouchDBPersistenceConnector.class.getSimpleName());
SmartExecutorPersistenceConnector.persistenceConnector = new CouchDBPersistenceConnector(configuration);
}
return SmartExecutorPersistenceConnector.persistenceConnector;
}
/**
* @param persistenceConnector the persistenceConnector to set
*/
public static synchronized void setPersistenceConnector(
SmartExecutorPersistenceConnector persistenceConnector) {
SmartExecutorPersistenceConnector.persistenceConnector = persistenceConnector;
}
/**
/**
* Close the connection to DB
* @throws Exception if fails
*/

View File

@ -0,0 +1,57 @@
/**
*
*/
package org.gcube.vremanagement.executor.persistence;
import java.util.HashMap;
import java.util.Map;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.vremanagement.executor.persistence.couchdb.CouchDBPersistenceConnector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public abstract class SmartExecutorPersistenceFactory {
private static final Logger logger = LoggerFactory.getLogger(SmartExecutorPersistenceFactory.class);
private static Map<String, SmartExecutorPersistenceConnector> persistenceConnectors;
static {
persistenceConnectors = new HashMap<String, SmartExecutorPersistenceConnector>();
}
/**
* @return the persistenceConnector
*/
public static synchronized SmartExecutorPersistenceConnector getPersistenceConnector() throws Exception {
String scope = ScopeProvider.instance.get();
if(scope==null){
String error = "No Scope available.";
logger.error(error);
throw new RuntimeException(error);
}
logger.trace("Retrieving {} for scope {}",
SmartExecutorPersistenceConnector.class.getSimpleName(), scope);
SmartExecutorPersistenceConnector persistence = persistenceConnectors.get(scope);
if(persistence==null){
logger.trace("Retrieving {} for scope {} not found on internal {}. Intializing it.",
SmartExecutorPersistenceConnector.class.getSimpleName(), scope, Map.class.getSimpleName());
SmartExecutorPersistenceConfiguration configuration =
new SmartExecutorPersistenceConfiguration(CouchDBPersistenceConnector.class.getSimpleName());
persistence = new CouchDBPersistenceConnector(configuration);
persistenceConnectors.put(scope, persistence);
}
return persistence;
}
}

View File

@ -10,7 +10,7 @@ import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.node.ObjectNode;
import org.gcube.common.resources.gcore.GCoreEndpoint;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.vremanagement.executor.SmartExecutorInitializator;
import org.gcube.vremanagement.executor.SmartExecutorImpl;
import org.gcube.vremanagement.executor.plugin.PluginDeclaration;
import org.gcube.vremanagement.executor.plugin.PluginStateEvolution;
@ -46,9 +46,9 @@ public class PluginStateEvolutionObjectNode {
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode objectNode = objectMapper.createObjectNode();
try {
GCoreEndpoint gCoreEndpoint = SmartExecutorInitializator.getCtx().profile(GCoreEndpoint.class);
GCoreEndpoint gCoreEndpoint = SmartExecutorImpl.getCtx().profile(GCoreEndpoint.class);
objectNode.put(GHN_ID_FIELD, gCoreEndpoint.profile().ghnId());
objectNode.put(GHN_HOSTNAME_FIELD, SmartExecutorInitializator.getCtx().container().configuration().hostname());
objectNode.put(GHN_HOSTNAME_FIELD, SmartExecutorImpl.getCtx().container().configuration().hostname());
}catch(Exception e){
objectNode.put(GHN_ID_FIELD, LOCALHOST + "_" + UUID.randomUUID());
objectNode.put(GHN_HOSTNAME_FIELD, LOCALHOST);

View File

@ -15,7 +15,7 @@ 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.persistence.SmartExecutorPersistenceFactory;
import org.gcube.vremanagement.executor.plugin.Plugin;
import org.gcube.vremanagement.executor.plugin.PluginDeclaration;
import org.gcube.vremanagement.executor.plugin.PluginState;
@ -127,7 +127,7 @@ public class SmartExecutorJob implements InterruptableJob {
this.interrupted = false;
this.initialized = false;
pluginStateNotifications = new ArrayList<PluginStateNotification>();
pluginStateNotifications.add(SmartExecutorPersistenceConnector.getPersistenceConnector());
pluginStateNotifications.add(SmartExecutorPersistenceFactory.getPersistenceConnector());
}
/**

View File

@ -12,7 +12,7 @@ import java.util.Map;
import java.util.UUID;
import org.gcube.common.resources.gcore.GCoreEndpoint;
import org.gcube.vremanagement.executor.SmartExecutorInitializator;
import org.gcube.vremanagement.executor.SmartExecutorImpl;
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
import org.gcube.vremanagement.executor.api.types.Scheduling;
import org.gcube.vremanagement.executor.configuration.ScheduledTaskConfiguration;
@ -139,7 +139,7 @@ public class SmartExecutorScheduler {
try {
ScheduledTaskConfiguration stc = ScheduledTaskConfigurationFactory.getLaunchConfiguration();
String runningInstanceID = SmartExecutorInitializator.getCtx().profile(GCoreEndpoint.class).id();
String runningInstanceID = SmartExecutorImpl.getCtx().profile(GCoreEndpoint.class).id();
stc.addScheduledTask(uuid, runningInstanceID, parameter);
} catch (Exception e) {
logger.error("Unable to persist the scheduling", e.getCause());

View File

@ -35,7 +35,7 @@ public class SmartExecutorPersistenceConnectorTest {
@Test
public void getConnectionTest() throws Exception {
ScopeProvider.instance.set(GCUBE_DEVSEC_SCOPE);
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceConnector.getPersistenceConnector();
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceFactory.getPersistenceConnector();
Assert.assertNotNull(persistenceConnector);
Assert.assertEquals(CouchDBPersistenceConnector.class, persistenceConnector.getClass());
persistenceConnector.close();
@ -44,7 +44,7 @@ public class SmartExecutorPersistenceConnectorTest {
@Test
public void getPluginInstanceStateTest() throws Exception {
ScopeProvider.instance.set(GCUBE_DEVSEC_SCOPE);
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceConnector.getPersistenceConnector();
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceFactory.getPersistenceConnector();
UUID uuid = UUID.randomUUID();
PluginState[] states = PluginState.values();

View File

@ -13,6 +13,7 @@ import org.gcube.vremanagement.executor.exception.InputsNullException;
import org.gcube.vremanagement.executor.exception.InvalidInputsException;
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConnector;
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConnectorTest;
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceFactory;
import org.gcube.vremanagement.executor.plugin.PluginState;
import org.gcube.vremanagement.executor.plugin.PluginStateNotification;
import org.junit.AfterClass;
@ -33,7 +34,7 @@ public class RunnablePluginTest {
public static void prepare() throws Exception{
try {
ScopeProvider.instance.set(SmartExecutorPersistenceConnectorTest.GCUBE_DEVSEC_SCOPE);
SmartExecutorPersistenceConnector.getPersistenceConnector();
SmartExecutorPersistenceFactory.getPersistenceConnector();
} catch (Exception e) {
logger.error("Unable to Create JDBCPersistenceConnector");
throw e;
@ -45,7 +46,7 @@ public class RunnablePluginTest {
System.out.println("Testing Null inputs");
UUID uuid = UUID.randomUUID();
HelloWorldPluginDeclaration hwpd = new HelloWorldPluginDeclaration();
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceConnector.getPersistenceConnector();
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceFactory.getPersistenceConnector();
List<PluginStateNotification> pluginStateNotifications = new ArrayList<PluginStateNotification>();
pluginStateNotifications.add(persistenceConnector);
HelloWorldPlugin helloWorldPlugin = new HelloWorldPlugin(hwpd);
@ -63,7 +64,7 @@ public class RunnablePluginTest {
Map<String, Object> inputs = new HashMap<String, Object>();
UUID uuid = UUID.randomUUID();
HelloWorldPluginDeclaration hwpd = new HelloWorldPluginDeclaration();
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceConnector.getPersistenceConnector();
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceFactory.getPersistenceConnector();
List<PluginStateNotification> pluginStateNotifications = new ArrayList<PluginStateNotification>();
pluginStateNotifications.add(persistenceConnector);
HelloWorldPlugin helloWorldPlugin = new HelloWorldPlugin(hwpd);
@ -87,7 +88,7 @@ public class RunnablePluginTest {
UUID uuid = UUID.randomUUID();
HelloWorldPluginDeclaration hwpd = new HelloWorldPluginDeclaration();
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceConnector.getPersistenceConnector();
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceFactory.getPersistenceConnector();
List<PluginStateNotification> pluginStateNotifications = new ArrayList<PluginStateNotification>();
pluginStateNotifications.add(persistenceConnector);
HelloWorldPlugin helloWorldPlugin = new HelloWorldPlugin(hwpd);
@ -102,7 +103,7 @@ public class RunnablePluginTest {
@AfterClass
public static void finish() throws Exception{
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceConnector.getPersistenceConnector();
SmartExecutorPersistenceConnector persistenceConnector = SmartExecutorPersistenceFactory.getPersistenceConnector();
persistenceConnector.close();
}
}

View File

@ -16,6 +16,7 @@ import org.gcube.vremanagement.executor.api.types.Scheduling;
import org.gcube.vremanagement.executor.exception.PluginStateNotRetrievedException;
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConnector;
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConnectorTest;
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceFactory;
import org.gcube.vremanagement.executor.plugin.PluginState;
import org.gcube.vremanagement.executor.scheduler.SmartExecutorScheduler;
import org.junit.AfterClass;
@ -46,7 +47,7 @@ public class SmartExecutorSchedulerTest {
pc = new JDBCPersistenceConnector(".");
SmartExecutorPersistenceConnector.setPersistenceConnector(pc);
*/
pc = SmartExecutorPersistenceConnector.getPersistenceConnector();
pc = SmartExecutorPersistenceFactory.getPersistenceConnector();
} catch (Exception e) {
logger.error("Unable to Create SmartExecutorPersistenceConnector");
throw e;