refs #2112: Port SmartExecutor to be compliant with new Authorization
https://support.d4science.org/issues/2112 Changed the way to retrieve ApplicationContext git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/vre-management/smart-executor@122910 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c371db1f4b
commit
ca24d6bea1
|
@ -5,7 +5,6 @@ import java.util.UUID;
|
|||
import javax.jws.WebService;
|
||||
|
||||
import org.gcube.smartgears.annotations.ManagedBy;
|
||||
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;
|
||||
|
@ -40,15 +39,6 @@ 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,
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
|||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.gcube.resources.discovery.icclient.ICFactory;
|
||||
import org.gcube.smartgears.ApplicationManager;
|
||||
import org.gcube.smartgears.ContextProvider;
|
||||
import org.gcube.smartgears.configuration.container.ContainerConfiguration;
|
||||
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceConnector;
|
||||
import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceFactory;
|
||||
|
@ -46,36 +47,6 @@ public class SmartExecutorInitializator implements ApplicationManager {
|
|||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @return the configuredTasks
|
||||
* /
|
||||
public static ScheduledTaskConfiguration getConfiguredTasks() {
|
||||
return launchConfiguration;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Publish the provided resource on all Service Scopes retrieved from
|
||||
* Context
|
||||
|
@ -176,13 +147,13 @@ public class SmartExecutorInitializator implements ApplicationManager {
|
|||
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(SmartExecutorImpl.ctx.configuration().serviceClass());
|
||||
profile.name(SmartExecutorImpl.ctx.configuration().name());
|
||||
String version = SmartExecutorImpl.ctx.configuration().version();
|
||||
profile.category(ContextProvider.get().configuration().serviceClass());
|
||||
profile.name(ContextProvider.get().configuration().name());
|
||||
String version = ContextProvider.get().configuration().version();
|
||||
profile.version(version);
|
||||
profile.description(SmartExecutorImpl.ctx.configuration().description());
|
||||
profile.description(ContextProvider.get().configuration().description());
|
||||
|
||||
String runningOn = getRunningOn(SmartExecutorImpl.ctx.container().configuration());
|
||||
String runningOn = getRunningOn(ContextProvider.get().container().configuration());
|
||||
Platform platform = profile.newPlatform();
|
||||
platform.name(runningOn);
|
||||
|
||||
|
@ -194,7 +165,7 @@ public class SmartExecutorInitializator implements ApplicationManager {
|
|||
|
||||
Runtime runtime = profile.newRuntime();
|
||||
runtime.hostedOn(runningOn);
|
||||
runtime.status(SmartExecutorImpl.ctx.configuration().mode().toString());
|
||||
runtime.status(ContextProvider.get().configuration().mode().toString());
|
||||
|
||||
Group<AccessPoint> accessPoints = profile.accessPoints();
|
||||
Map<String, PluginDeclaration> availablePlugins = pluginManager.getAvailablePlugins();
|
||||
|
@ -256,9 +227,9 @@ public class SmartExecutorInitializator implements ApplicationManager {
|
|||
private void cleanServiceEndpoints(){
|
||||
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())))
|
||||
.addCondition(String.format("$resource/Profile/Category/text() eq '%s'", ContextProvider.get().configuration().serviceClass()))
|
||||
.addCondition(String.format("$resource/Profile/Name/text() eq '%s'", ContextProvider.get().configuration().name()))
|
||||
.addCondition(String.format("$resource/Profile/RunTime/HostedOn/text() eq '%s'", getRunningOn(ContextProvider.get().container().configuration())))
|
||||
.setResult("$resource");
|
||||
|
||||
DiscoveryClient<ServiceEndpoint> client = ICFactory.clientFor(ServiceEndpoint.class);
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.gcube.vremanagement.executor.SmartExecutorImpl;
|
||||
import org.gcube.smartgears.ContextProvider;
|
||||
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(SmartExecutorImpl.getCtx().persistence().location());
|
||||
this(ContextProvider.get().persistence().location());
|
||||
}
|
||||
|
||||
public FileScheduledTaskConfiguration(String location) throws IOException, JSONException {
|
||||
|
|
|
@ -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.SmartExecutorImpl;
|
||||
import org.gcube.smartgears.ContextProvider;
|
||||
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 = SmartExecutorImpl.getCtx().profile(GCoreEndpoint.class);
|
||||
GCoreEndpoint gCoreEndpoint = ContextProvider.get().profile(GCoreEndpoint.class);
|
||||
objectNode.put(GHN_ID_FIELD, gCoreEndpoint.profile().ghnId());
|
||||
objectNode.put(GHN_HOSTNAME_FIELD, SmartExecutorImpl.getCtx().container().configuration().hostname());
|
||||
objectNode.put(GHN_HOSTNAME_FIELD, ContextProvider.get().container().configuration().hostname());
|
||||
}catch(Exception e){
|
||||
objectNode.put(GHN_ID_FIELD, LOCALHOST + "_" + UUID.randomUUID());
|
||||
objectNode.put(GHN_HOSTNAME_FIELD, LOCALHOST);
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Map;
|
|||
import java.util.UUID;
|
||||
|
||||
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
||||
import org.gcube.vremanagement.executor.SmartExecutorImpl;
|
||||
import org.gcube.smartgears.ContextProvider;
|
||||
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
|
||||
import org.gcube.vremanagement.executor.api.types.Scheduling;
|
||||
import org.gcube.vremanagement.executor.configuration.ScheduledTaskConfiguration;
|
||||
|
@ -150,7 +150,7 @@ public class SmartExecutorScheduler {
|
|||
}
|
||||
|
||||
try {
|
||||
String runningInstanceID = SmartExecutorImpl.getCtx().profile(GCoreEndpoint.class).id();
|
||||
String runningInstanceID = ContextProvider.get().profile(GCoreEndpoint.class).id();
|
||||
logger.debug("Going to persist Scheduled Task {} which will be assigned to Running Instance {}. LaunchParameters : {} ",
|
||||
uuid.toString(), runningInstanceID, parameter);
|
||||
ScheduledTaskConfiguration stc = ScheduledTaskConfigurationFactory.getLaunchConfiguration();
|
||||
|
|
Loading…
Reference in New Issue