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@119453 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1adb55d4e0
commit
745267b3c8
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package org.gcube.vremanagement.executor.persistence.couchdb;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
|
@ -10,6 +11,7 @@ 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.SmartExecutorInitalizator;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginDeclaration;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginStateEvolution;
|
||||
|
||||
/**
|
||||
|
@ -22,7 +24,13 @@ public class PluginStateEvolutionObjectNode {
|
|||
|
||||
public final static String UUID_FIELD = "uuid";
|
||||
public final static String ITERATION_FIELD = "iteration";
|
||||
public final static String PLUGIN_NAME_FIELD = "pluginName";
|
||||
|
||||
public final static String PLUGIN_DECLARATION_FIELD = "pluginDeclaration";
|
||||
public final static String PLUGIN_DECLARATION_NAME_FIELD = "name";
|
||||
public final static String PLUGIN_DECLARATION_DESCRIPTION_FIELD = "description";
|
||||
public final static String PLUGIN_DECLARATION_VERSION_FIELD = "version";
|
||||
public final static String PLUGIN_DECLARATION_HOST_DISCOVERED_CAPABILITIES_FIELD = "hostDiscoveredCapabilities";
|
||||
|
||||
public final static String TIMESTAMP_FIELD = "timestamp";
|
||||
public final static String STATE_FIELD = "state";
|
||||
|
||||
|
@ -48,6 +56,25 @@ public class PluginStateEvolutionObjectNode {
|
|||
return objectNode;
|
||||
}
|
||||
|
||||
protected static ObjectNode getPluginInfo(PluginDeclaration pluginDeclaration){
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
ObjectNode objectNode = objectMapper.createObjectNode();
|
||||
objectNode.put(PLUGIN_DECLARATION_NAME_FIELD, pluginDeclaration.getName());
|
||||
objectNode.put(PLUGIN_DECLARATION_DESCRIPTION_FIELD, pluginDeclaration.getDescription());
|
||||
objectNode.put(PLUGIN_DECLARATION_VERSION_FIELD, pluginDeclaration.getVersion());
|
||||
|
||||
Map<String, String> capabilites = pluginDeclaration.getSupportedCapabilities();
|
||||
ObjectNode capabilitiesObjectNode = objectMapper.createObjectNode();
|
||||
if(capabilites!=null){
|
||||
for(String key : capabilites.keySet()){
|
||||
capabilitiesObjectNode.put(key, capabilites.get(key));
|
||||
}
|
||||
}
|
||||
objectNode.put(PLUGIN_DECLARATION_HOST_DISCOVERED_CAPABILITIES_FIELD, capabilitiesObjectNode);
|
||||
|
||||
return objectNode;
|
||||
}
|
||||
|
||||
public static void addScope(ObjectNode objectNode){
|
||||
objectNode.put(SCOPE_FIELD, ScopeProvider.instance.get());
|
||||
}
|
||||
|
@ -58,7 +85,9 @@ public class PluginStateEvolutionObjectNode {
|
|||
objectNode.put(UUID_FIELD, pluginStateEvolution.getUuid().toString());
|
||||
objectNode.put(ITERATION_FIELD, pluginStateEvolution.getIteration());
|
||||
objectNode.put(TIMESTAMP_FIELD, pluginStateEvolution.getTimestamp());
|
||||
objectNode.put(PLUGIN_NAME_FIELD, pluginStateEvolution.getPluginDeclaration().getName());
|
||||
|
||||
objectNode.put(PLUGIN_DECLARATION_FIELD, getPluginInfo(pluginStateEvolution.getPluginDeclaration()));
|
||||
|
||||
objectNode.put(STATE_FIELD, pluginStateEvolution.getPluginState().toString());
|
||||
|
||||
addScope(objectNode);
|
||||
|
|
Loading…
Reference in New Issue