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:
parent
2ebec0abfe
commit
bc827fe06c
|
@ -64,7 +64,7 @@ public class SmartExecutorInitalizator extends ApplicationLifecycleHandler {
|
||||||
/**
|
/**
|
||||||
* The application context
|
* The application context
|
||||||
*/
|
*/
|
||||||
public static ApplicationContext ctx;
|
protected static ApplicationContext ctx;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the Smart executor Scheduler used for task execution
|
* the Smart executor Scheduler used for task execution
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class FileScheduledTaskConfiguration implements ScheduledTaskConfiguratio
|
||||||
public static final String CONFIG_TASK_FILENAME = "definedTasks.json";
|
public static final String CONFIG_TASK_FILENAME = "definedTasks.json";
|
||||||
|
|
||||||
public FileScheduledTaskConfiguration() throws Exception {
|
public FileScheduledTaskConfiguration() throws Exception {
|
||||||
this(SmartExecutorInitalizator.ctx.persistence().location());
|
this(SmartExecutorInitalizator.getCtx().persistence().location());
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileScheduledTaskConfiguration(String location) throws IOException, JSONException {
|
public FileScheduledTaskConfiguration(String location) throws IOException, JSONException {
|
||||||
|
|
|
@ -27,6 +27,9 @@ import org.ektorp.http.StdHttpClient;
|
||||||
import org.ektorp.http.StdHttpClient.Builder;
|
import org.ektorp.http.StdHttpClient.Builder;
|
||||||
import org.ektorp.impl.StdCouchDbConnector;
|
import org.ektorp.impl.StdCouchDbConnector;
|
||||||
import org.ektorp.impl.StdCouchDbInstance;
|
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.api.types.LaunchParameter;
|
||||||
import org.gcube.vremanagement.executor.configuration.ScheduledTaskConfiguration;
|
import org.gcube.vremanagement.executor.configuration.ScheduledTaskConfiguration;
|
||||||
import org.gcube.vremanagement.executor.configuration.jsonbased.JSONLaunchParameter;
|
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 _REV_JSON_FIELD = "_rev";
|
||||||
protected static final String TYPE_JSON_FIELD = "type";
|
protected static final String TYPE_JSON_FIELD = "type";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected static final String USED_BY_FIELD = "usedBy";
|
protected static final String USED_BY_FIELD = "usedBy";
|
||||||
|
|
||||||
protected static final String RESERVED_BY = "reservedBy";
|
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 TIMESTAMP_FIELD = "timestamp";
|
||||||
public final static String STATE_FIELD = "state";
|
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}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -149,6 +167,7 @@ public class CouchDBPersistenceConnector extends SmartExecutorPersistenceConnect
|
||||||
objectNode.put(PLUGIN_NAME_FIELD, pluginName);
|
objectNode.put(PLUGIN_NAME_FIELD, pluginName);
|
||||||
objectNode.put(STATE_FIELD, pluginState.toString());
|
objectNode.put(STATE_FIELD, pluginState.toString());
|
||||||
objectNode.put(TYPE_JSON_FIELD, EVOLUTION_TYPE);
|
objectNode.put(TYPE_JSON_FIELD, EVOLUTION_TYPE);
|
||||||
|
objectNode.put(RUN_ON_FIELD, getRunOn());
|
||||||
createItem(objectNode, null);
|
createItem(objectNode, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ class JDBCPersistenceConnector extends SmartExecutorPersistenceConnector {
|
||||||
public final static String CATALINA_HOME = "CATALINA_HOME";
|
public final static String CATALINA_HOME = "CATALINA_HOME";
|
||||||
|
|
||||||
public JDBCPersistenceConnector() throws Exception {
|
public JDBCPersistenceConnector() throws Exception {
|
||||||
this(SmartExecutorInitalizator.ctx.persistence().location());
|
this(SmartExecutorInitalizator.getCtx().persistence().location());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue