refs #579: Use Persistence to persist Scheduled Task configuration on smart-executor

https://support.d4science.org/issues/579

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/vre-management/smart-executor@119381 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2015-10-05 13:19:21 +00:00
parent 2ebec0abfe
commit bc827fe06c
4 changed files with 22 additions and 3 deletions

View File

@ -64,7 +64,7 @@ public class SmartExecutorInitalizator extends ApplicationLifecycleHandler {
/**
* The application context
*/
public static ApplicationContext ctx;
protected static ApplicationContext ctx;
/**
* the Smart executor Scheduler used for task execution

View File

@ -43,7 +43,7 @@ public class FileScheduledTaskConfiguration implements ScheduledTaskConfiguratio
public static final String CONFIG_TASK_FILENAME = "definedTasks.json";
public FileScheduledTaskConfiguration() throws Exception {
this(SmartExecutorInitalizator.ctx.persistence().location());
this(SmartExecutorInitalizator.getCtx().persistence().location());
}
public FileScheduledTaskConfiguration(String location) throws IOException, JSONException {

View File

@ -27,6 +27,9 @@ import org.ektorp.http.StdHttpClient;
import org.ektorp.http.StdHttpClient.Builder;
import org.ektorp.impl.StdCouchDbConnector;
import org.ektorp.impl.StdCouchDbInstance;
import org.gcube.common.resources.gcore.GCoreEndpoint;
import org.gcube.smartgears.configuration.container.ContainerConfiguration;
import org.gcube.vremanagement.executor.SmartExecutorInitalizator;
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
import org.gcube.vremanagement.executor.configuration.ScheduledTaskConfiguration;
import org.gcube.vremanagement.executor.configuration.jsonbased.JSONLaunchParameter;
@ -55,6 +58,8 @@ public class CouchDBPersistenceConnector extends SmartExecutorPersistenceConnect
protected static final String _REV_JSON_FIELD = "_rev";
protected static final String TYPE_JSON_FIELD = "type";
protected static final String USED_BY_FIELD = "usedBy";
protected static final String RESERVED_BY = "reservedBy";
@ -135,6 +140,19 @@ public class CouchDBPersistenceConnector extends SmartExecutorPersistenceConnect
public final static String TIMESTAMP_FIELD = "timestamp";
public final static String STATE_FIELD = "state";
protected static final String RUN_ON_FIELD = "runOn";
public final static String GHN_HOSTNAME_FIELD = "ghnHostname";
public final static String GHN_ID_FIELD = "ghnID";
protected static ObjectNode getRunOn(){
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode objectNode = objectMapper.createObjectNode();
GCoreEndpoint gCoreEndpoint = SmartExecutorInitalizator.getCtx().profile(GCoreEndpoint.class);
objectNode.put(GHN_ID_FIELD, gCoreEndpoint.profile().ghnId());
objectNode.put(GHN_HOSTNAME_FIELD, SmartExecutorInitalizator.getCtx().container().configuration().hostname());
return objectNode;
}
/**
* {@inheritDoc}
*/
@ -149,6 +167,7 @@ public class CouchDBPersistenceConnector extends SmartExecutorPersistenceConnect
objectNode.put(PLUGIN_NAME_FIELD, pluginName);
objectNode.put(STATE_FIELD, pluginState.toString());
objectNode.put(TYPE_JSON_FIELD, EVOLUTION_TYPE);
objectNode.put(RUN_ON_FIELD, getRunOn());
createItem(objectNode, null);
}

View File

@ -47,7 +47,7 @@ class JDBCPersistenceConnector extends SmartExecutorPersistenceConnector {
public final static String CATALINA_HOME = "CATALINA_HOME";
public JDBCPersistenceConnector() throws Exception {
this(SmartExecutorInitalizator.ctx.persistence().location());
this(SmartExecutorInitalizator.getCtx().persistence().location());
}
/**