Repository: airavata Updated Branches: refs/heads/master 5153d0c82 -> 4b51e7f6a
fixing gfac service implementation Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/11b1b9a8 Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/11b1b9a8 Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/11b1b9a8 Branch: refs/heads/master Commit: 11b1b9a8488a31cabecc557893287af3a28eda15 Parents: 6ff2f69 Author: lahiru <[email protected]> Authored: Tue May 27 13:53:17 2014 -0400 Committer: lahiru <[email protected]> Committed: Tue May 27 13:53:17 2014 -0400 ---------------------------------------------------------------------- .../server/handler/AiravataServerHandler.java | 8 +- .../client/samples/CreateLaunchExperiment.java | 2 +- .../main/resources/airavata-server.properties | 7 +- modules/distribution/server/pom.xml | 5 ++ .../server/src/main/assembly/bin-assembly.xml | 1 + .../airavata/gfac/server/GfacServerHandler.java | 34 ++++---- .../AiravataExperimentStatusUpdator.java | 1 + .../AiravataWorkflowNodeStatusUpdator.java | 23 +----- .../gfac/local/provider/impl/LocalProvider.java | 7 -- .../src/test/resources/orchestrator.properties | 2 +- modules/orchestrator/orchestrator-core/pom.xml | 23 +++--- .../orchestrator/core/gfac/GFACInstance.java | 7 +- .../core/gfac/GFacClientFactory.java | 42 ++++++++++ .../core/impl/EmbeddedGFACJobSubmitter.java | 83 -------------------- .../core/impl/GFACEmbeddedJobSubmitter.java | 81 +++++++++++++++++++ .../core/impl/GFACServiceJobSubmitter.java | 63 +++++++++++++++ .../core/utils/OrchestratorUtils.java | 4 +- .../cpi/impl/SimpleOrchestratorImpl.java | 1 - 18 files changed, 245 insertions(+), 149 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/11b1b9a8/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java index e31faf1..c48f2bd 100644 --- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java +++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java @@ -853,15 +853,15 @@ public class AiravataServerHandler implements Airavata.Iface { final String expID = airavataExperimentId; synchronized (this) { if (orchestratorClient.validateExperiment(expID)) { -// (new Thread() { -// public void run() { + (new Thread() { + public void run() { try { orchestratorClient.launchExperiment(expID); } catch (TException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } -// } -// }).start(); + } + }).start(); } else { throw new InvalidRequestException("Experiment Validation Failed, please check the configuration"); } http://git-wip-us.apache.org/repos/asf/airavata/blob/11b1b9a8/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java index bca5d2a..70601d4 100644 --- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java +++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java @@ -57,7 +57,7 @@ public class CreateLaunchExperiment { try { AiravataUtils.setExecutionAsClient(); final Airavata.Client airavata = AiravataClientFactory.createAiravataClient(THRIFT_SERVER_HOST, THRIFT_SERVER_PORT); -// System.out.println("API version is " + airavata.getAPIVersion()); + System.out.println("API version is " + airavata.getAPIVersion()); addDescriptors(); // final String expId = createExperimentForSSHHost(airavata); http://git-wip-us.apache.org/repos/asf/airavata/blob/11b1b9a8/modules/configuration/server/src/main/resources/airavata-server.properties ---------------------------------------------------------------------- diff --git a/modules/configuration/server/src/main/resources/airavata-server.properties b/modules/configuration/server/src/main/resources/airavata-server.properties index ab2da7d..a617a21 100644 --- a/modules/configuration/server/src/main/resources/airavata-server.properties +++ b/modules/configuration/server/src/main/resources/airavata-server.properties @@ -93,7 +93,7 @@ appcatalog.validationQuery=SELECT 1 from COMPUTE_RESOURCE #class.user.workflow.registry.accessor=org.apache.airavata.persistance.registry.jpa.impl.AiravataJPARegistry #class.published.workflow.registry.accessor=org.apache.airavata.persistance.registry.jpa.impl.AiravataJPARegistry -############################################################ ############### +########################################################################### # Airavata Workflow Interpreter Configurations ########################################################################### @@ -110,7 +110,7 @@ gfac.embedded=true ########################################################################### # Airavata GFac MyProxy GSI credentials to access Grid Resources. ########################################################################### - +gfac=org.apache.airavata.gfac.server.GfacServer myproxy.server=myproxy.teragrid.org myproxy.username=ogce myproxy.password= @@ -278,7 +278,8 @@ connection.name=xsede activity.listeners=org.apache.airavata.gfac.core.monitor.AiravataJobStatusUpdator,org.apache.airavata.gfac.core.monitor.AiravataTaskStatusUpdator,org.apache.airavata.gfac.core.monitor.AiravataWorkflowNodeStatusUpdator,org.apache.airavata.gfac.core.monitor.AiravataExperimentStatusUpdator ###---------------------------Orchestrator module Configurations---------------------------### -job.submitter=org.apache.airavata.orchestrator.core.impl.EmbeddedGFACJobSubmitter +job.submitter=org.apache.airavata.orchestrator.core.impl.GFACEmbeddedJobSubmitter +#job.submitter=org.apache.airavata.orchestrator.core.impl.GFACServiceJobSubmitter job.validators=org.apache.airavata.orchestrator.core.validator.impl.SimpleAppDataValidator,org.apache.airavata.orchestrator.core.validator.impl.ExperimentStatusValidator submitter.interval=10000 threadpool.size=10 http://git-wip-us.apache.org/repos/asf/airavata/blob/11b1b9a8/modules/distribution/server/pom.xml ---------------------------------------------------------------------- diff --git a/modules/distribution/server/pom.xml b/modules/distribution/server/pom.xml index 32880bc..894f57d 100644 --- a/modules/distribution/server/pom.xml +++ b/modules/distribution/server/pom.xml @@ -326,6 +326,11 @@ </dependency> <dependency> <groupId>org.apache.airavata</groupId> + <artifactId>airavata-gfac-service</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.airavata</groupId> <artifactId>airavata-client-api</artifactId> <version>${project.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/airavata/blob/11b1b9a8/modules/distribution/server/src/main/assembly/bin-assembly.xml ---------------------------------------------------------------------- diff --git a/modules/distribution/server/src/main/assembly/bin-assembly.xml b/modules/distribution/server/src/main/assembly/bin-assembly.xml index 3435565..0c3e43a 100644 --- a/modules/distribution/server/src/main/assembly/bin-assembly.xml +++ b/modules/distribution/server/src/main/assembly/bin-assembly.xml @@ -196,6 +196,7 @@ <include>org.apache.airavata:airavata-data-models:jar</include> <include>org.apache.airavata:airavata-credential-store:jar</include> <include>org.apache.airavata:airavata-gfac-core:jar</include> + <include>org.apache.airavata:airavata-gfac-server:jar</include> <include>org.apache.airavata:airavata-gfac-ssh:jar</include> <include>org.apache.airavata:airavata-gfac-local:jar</include> <include>org.apache.airavata:airavata-gfac-gsissh:jar</include> http://git-wip-us.apache.org/repos/asf/airavata/blob/11b1b9a8/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java ---------------------------------------------------------------------- diff --git a/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java b/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java index 0013571..923163b 100644 --- a/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java +++ b/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java @@ -23,6 +23,7 @@ package org.apache.airavata.gfac.server; import org.apache.airavata.common.exception.AiravataConfigurationException; import org.apache.airavata.common.exception.ApplicationSettingsException; import org.apache.airavata.common.utils.ServerSettings; +import org.apache.airavata.gfac.GFacException; import org.apache.airavata.gfac.core.cpi.GFac; import org.apache.airavata.gfac.core.cpi.GFacImpl; import org.apache.airavata.gfac.cpi.GfacService; @@ -44,8 +45,6 @@ import org.slf4j.LoggerFactory; public class GfacServerHandler implements GfacService.Iface { private final static Logger logger = LoggerFactory.getLogger(GfacServerHandler.class); - private GFac gfac; - private Registry registry; private String registryURL; @@ -56,9 +55,6 @@ public class GfacServerHandler implements GfacService.Iface { registry = RegistryFactory.getDefaultRegistry(); try { setGatewayProperties(); - gfac = new GFacImpl(registry, null, - AiravataRegistryFactory.getRegistry(new Gateway(getGatewayName()), - new AiravataUser(getAiravataUserName()))); }catch (Exception e){ logger.error("Error initialising GFAC",e); } @@ -69,20 +65,18 @@ public class GfacServerHandler implements GfacService.Iface { } public boolean submitJob(String experimentId, String taskId) throws TException { - return false; + GFac gfac = getGfac(); + try { + return gfac.submitJob(experimentId, taskId); + } catch (GFacException e) { + throw new TException("Error launching the experiment : " + e.getMessage(), e); + } } public boolean cancelJob(String experimentId, String taskId) throws TException { - return false; - } - - public GFac getGfac() { - return gfac; + throw new TException("Operation not supported"); } - public void setGfac(GFac gfac) { - this.gfac = gfac; - } public Registry getRegistry() { return registry; @@ -120,4 +114,16 @@ public class GfacServerHandler implements GfacService.Iface { setGatewayName(ServerSettings.getProperties().getProperty("system.gateway")); setRegistryURL(ServerSettings.getProperties().getProperty("airavata.server.url")); } + + private GFac getGfac()throws TException{ + try { + return new GFacImpl(registry, null, + AiravataRegistryFactory.getRegistry(new Gateway(getGatewayName()), + new AiravataUser(getAiravataUserName()))); + } catch (RegistryException e) { + throw new TException("Error initializing gfac instance",e); + } catch (AiravataConfigurationException e) { + throw new TException("Error initializing gfac instance",e); + } + } } http://git-wip-us.apache.org/repos/asf/airavata/blob/11b1b9a8/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/monitor/AiravataExperimentStatusUpdator.java ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/monitor/AiravataExperimentStatusUpdator.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/monitor/AiravataExperimentStatusUpdator.java index e2064cf..4e3efa0 100644 --- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/monitor/AiravataExperimentStatusUpdator.java +++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/monitor/AiravataExperimentStatusUpdator.java @@ -58,6 +58,7 @@ public class AiravataExperimentStatusUpdator implements AbstractActivityListener } public void updateExperimentStatus(String experimentId, ExperimentState state) throws Exception { + logger.info("Updating the experiment status of experiment: " + experimentId + " to " + state.toString()); Experiment details = (Experiment)airavataRegistry.get(RegistryModelType.EXPERIMENT, experimentId); if(details == null) { details = new Experiment(); http://git-wip-us.apache.org/repos/asf/airavata/blob/11b1b9a8/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/monitor/AiravataWorkflowNodeStatusUpdator.java ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/monitor/AiravataWorkflowNodeStatusUpdator.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/monitor/AiravataWorkflowNodeStatusUpdator.java index 65cc2f2..657a9b7 100644 --- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/monitor/AiravataWorkflowNodeStatusUpdator.java +++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/monitor/AiravataWorkflowNodeStatusUpdator.java @@ -63,28 +63,7 @@ public class AiravataWorkflowNodeStatusUpdator implements AbstractActivityListen } } - @Subscribe - public void setupExperimentStatus(WorkflowNodeStatusChangeRequest nodeStatus){ - ExperimentState state=ExperimentState.UNKNOWN; - switch(nodeStatus.getState()){ - case CANCELED: - state=ExperimentState.CANCELED; break; - case COMPLETED: - state=ExperimentState.COMPLETED; break; - case INVOKED: - state=ExperimentState.LAUNCHED; break; - case FAILED: - state=ExperimentState.FAILED; break; - case EXECUTING: - state=ExperimentState.EXECUTING; break; - case CANCELING: - state=ExperimentState.CANCELING; break; - default: - break; - } - logger.debug("Publishing Experiment Status "+state.toString()); - monitorPublisher.publish(new ExperimentStatusChangeRequest(nodeStatus.getIdentity(),state)); - } + public void updateWorkflowNodeStatus(String workflowNodeId, WorkflowNodeState state) throws Exception { WorkflowNodeDetails details = (WorkflowNodeDetails)airavataRegistry.get(RegistryModelType.WORKFLOW_NODE_DETAIL, workflowNodeId); http://git-wip-us.apache.org/repos/asf/airavata/blob/11b1b9a8/modules/gfac/gfac-local/src/main/java/org/apache/airavata/gfac/local/provider/impl/LocalProvider.java ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-local/src/main/java/org/apache/airavata/gfac/local/provider/impl/LocalProvider.java b/modules/gfac/gfac-local/src/main/java/org/apache/airavata/gfac/local/provider/impl/LocalProvider.java index 6443260..805f8a6 100644 --- a/modules/gfac/gfac-local/src/main/java/org/apache/airavata/gfac/local/provider/impl/LocalProvider.java +++ b/modules/gfac/gfac-local/src/main/java/org/apache/airavata/gfac/local/provider/impl/LocalProvider.java @@ -167,13 +167,6 @@ public class LocalProvider extends AbstractProvider { .append(" tempDirectory = ").append(app.getScratchWorkingDirectory()).append(" With the status ") .append(String.valueOf(returnValue)); log.info(buf.toString()); - MonitorID monitorID = new MonitorID(jobExecutionContext.getApplicationContext().getHostDescription(),jobId, - jobExecutionContext.getTaskData().getTaskID(), - jobExecutionContext.getWorkflowNodeDetails().getNodeInstanceId(),jobExecutionContext.getExperimentID(), - jobExecutionContext.getExperiment().getUserName()); - JobStatusChangeRequest jobStatusChangeRequest = new JobStatusChangeRequest(monitorID); - jobStatusChangeRequest.setState(JobState.COMPLETE); - this.getMonitorPublisher().publish(jobStatusChangeRequest); } catch (IOException io) { throw new GFacProviderException(io.getMessage(), io); } catch (InterruptedException e) { http://git-wip-us.apache.org/repos/asf/airavata/blob/11b1b9a8/modules/orchestrator/airavata-orchestrator-service/src/test/resources/orchestrator.properties ---------------------------------------------------------------------- diff --git a/modules/orchestrator/airavata-orchestrator-service/src/test/resources/orchestrator.properties b/modules/orchestrator/airavata-orchestrator-service/src/test/resources/orchestrator.properties index 5ebfe4f..a1f0169 100644 --- a/modules/orchestrator/airavata-orchestrator-service/src/test/resources/orchestrator.properties +++ b/modules/orchestrator/airavata-orchestrator-service/src/test/resources/orchestrator.properties @@ -17,7 +17,7 @@ # specific language governing permissions and limitations # under the License. # -job.submitter=org.apache.airavata.orchestrator.core.impl.EmbeddedGFACJobSubmitter +job.submitter=org.apache.airavata.orchestrator.core.impl.GFACEmbeddedJobSubmitter job.validators=org.apache.airavata.orchestrator.core.validator.impl.SimpleAppDataValidator submitter.interval=10000 threadpool.size=0 http://git-wip-us.apache.org/repos/asf/airavata/blob/11b1b9a8/modules/orchestrator/orchestrator-core/pom.xml ---------------------------------------------------------------------- diff --git a/modules/orchestrator/orchestrator-core/pom.xml b/modules/orchestrator/orchestrator-core/pom.xml index e3de0b7..5b99207 100644 --- a/modules/orchestrator/orchestrator-core/pom.xml +++ b/modules/orchestrator/orchestrator-core/pom.xml @@ -60,17 +60,10 @@ the License. --> <artifactId>airavata-gfac-core</artifactId> <version>${project.version}</version> </dependency> - <dependency> - <groupId>org.apache.airavata</groupId> - <artifactId>airavata-gfac-local</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> <dependency> <groupId>org.apache.airavata</groupId> - <artifactId>airavata-gfac-gsissh</artifactId> + <artifactId>airavata-gfac-service</artifactId> <version>${project.version}</version> - <scope>test</scope> </dependency> <dependency> <groupId>org.apache.airavata</groupId> @@ -88,7 +81,19 @@ the License. --> <artifactId>airavata-model-utils</artifactId> <version>${project.version}</version> </dependency> - <dependency> + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>airavata-gfac-local</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>airavata-gfac-gsissh</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.apache.derby</groupId> <artifactId>derby</artifactId> <version>${derby.version}</version> http://git-wip-us.apache.org/repos/asf/airavata/blob/11b1b9a8/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFACInstance.java ---------------------------------------------------------------------- diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFACInstance.java b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFACInstance.java index 8166747..1b69ad3 100644 --- a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFACInstance.java +++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFACInstance.java @@ -36,9 +36,12 @@ public class GFACInstance { private int currentLoad; - public GFACInstance(String gfacURL, int currentLoad) { + private int gfacPort; + + + public GFACInstance(String gfacURL, int gfacPort) { this.gfacURL = gfacURL; - this.currentLoad = currentLoad; + this.gfacPort = gfacPort; } public String getGfacURL() { http://git-wip-us.apache.org/repos/asf/airavata/blob/11b1b9a8/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFacClientFactory.java ---------------------------------------------------------------------- diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFacClientFactory.java b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFacClientFactory.java new file mode 100644 index 0000000..60ecd58 --- /dev/null +++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFacClientFactory.java @@ -0,0 +1,42 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.orchestrator.core.gfac; + +import org.apache.airavata.gfac.cpi.GfacService; +import org.apache.thrift.protocol.TBinaryProtocol; +import org.apache.thrift.protocol.TProtocol; +import org.apache.thrift.transport.TSocket; +import org.apache.thrift.transport.TTransport; +import org.apache.thrift.transport.TTransportException; + +public class GFacClientFactory { + public static GfacService.Client createOrchestratorClient(String serverHost, int serverPort){ + try { + TTransport transport = new TSocket(serverHost, serverPort); + transport.open(); + TProtocol protocol = new TBinaryProtocol(transport); + return new GfacService.Client(protocol); + } catch (TTransportException e) { + e.printStackTrace(); + } + return null; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/11b1b9a8/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/EmbeddedGFACJobSubmitter.java ---------------------------------------------------------------------- diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/EmbeddedGFACJobSubmitter.java b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/EmbeddedGFACJobSubmitter.java deleted file mode 100644 index ed69226..0000000 --- a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/EmbeddedGFACJobSubmitter.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ -package org.apache.airavata.orchestrator.core.impl; - - -import org.apache.airavata.gfac.GFacException; -import org.apache.airavata.gfac.core.context.JobExecutionContext; -import org.apache.airavata.gfac.core.cpi.GFac; -import org.apache.airavata.gfac.core.cpi.GFacImpl; -import org.apache.airavata.orchestrator.core.context.OrchestratorContext; -import org.apache.airavata.orchestrator.core.exception.OrchestratorException; -import org.apache.airavata.orchestrator.core.gfac.GFACInstance; -import org.apache.airavata.orchestrator.core.job.JobSubmitter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This is the simplest implementation for JobSubmitter, - * This is calling gfac invocation methods to invoke the gfac embedded mode,so this does not really implement - * the selectGFACInstance method - */ -public class EmbeddedGFACJobSubmitter implements JobSubmitter { - private final static Logger logger = LoggerFactory.getLogger(EmbeddedGFACJobSubmitter.class); - - private OrchestratorContext orchestratorContext; - - private GFac gfac; - - - public void initialize(OrchestratorContext orchestratorContext) throws OrchestratorException { - this.orchestratorContext = orchestratorContext; - gfac = new GFacImpl(orchestratorContext.getNewRegistry(), null, orchestratorContext.getRegistry()); - } - - public GFACInstance selectGFACInstance() throws OrchestratorException { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - - public boolean submit(String experimentID, String taskID) throws OrchestratorException { - try { - return gfac.submitJob(experimentID, taskID); - } catch (Exception e) { - String error = "Error launching the job : " + experimentID; - logger.error(error); - throw new OrchestratorException(error); - } - } - - public GFac getGfac() { - return gfac; - } - - public void setGfac(GFac gfac) { - this.gfac = gfac; - } - - public OrchestratorContext getOrchestratorContext() { - return orchestratorContext; - } - - public void setOrchestratorContext(OrchestratorContext orchestratorContext) { - this.orchestratorContext = orchestratorContext; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/11b1b9a8/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/GFACEmbeddedJobSubmitter.java ---------------------------------------------------------------------- diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/GFACEmbeddedJobSubmitter.java b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/GFACEmbeddedJobSubmitter.java new file mode 100644 index 0000000..925251b --- /dev/null +++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/GFACEmbeddedJobSubmitter.java @@ -0,0 +1,81 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.orchestrator.core.impl; + + +import org.apache.airavata.gfac.core.cpi.GFac; +import org.apache.airavata.gfac.core.cpi.GFacImpl; +import org.apache.airavata.orchestrator.core.context.OrchestratorContext; +import org.apache.airavata.orchestrator.core.exception.OrchestratorException; +import org.apache.airavata.orchestrator.core.gfac.GFACInstance; +import org.apache.airavata.orchestrator.core.job.JobSubmitter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This is the simplest implementation for JobSubmitter, + * This is calling gfac invocation methods to invoke the gfac embedded mode,so this does not really implement + * the selectGFACInstance method + */ +public class GFACEmbeddedJobSubmitter implements JobSubmitter { + private final static Logger logger = LoggerFactory.getLogger(GFACEmbeddedJobSubmitter.class); + + private OrchestratorContext orchestratorContext; + + private GFac gfac; + + + public void initialize(OrchestratorContext orchestratorContext) throws OrchestratorException { + this.orchestratorContext = orchestratorContext; + gfac = new GFacImpl(orchestratorContext.getNewRegistry(), null, orchestratorContext.getRegistry()); + } + + public GFACInstance selectGFACInstance() throws OrchestratorException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + + public boolean submit(String experimentID, String taskID) throws OrchestratorException { + try { + return gfac.submitJob(experimentID, taskID); + } catch (Exception e) { + String error = "Error launching the job : " + experimentID; + logger.error(error); + throw new OrchestratorException(error); + } + } + + public GFac getGfac() { + return gfac; + } + + public void setGfac(GFac gfac) { + this.gfac = gfac; + } + + public OrchestratorContext getOrchestratorContext() { + return orchestratorContext; + } + + public void setOrchestratorContext(OrchestratorContext orchestratorContext) { + this.orchestratorContext = orchestratorContext; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/11b1b9a8/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/GFACServiceJobSubmitter.java ---------------------------------------------------------------------- diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/GFACServiceJobSubmitter.java b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/GFACServiceJobSubmitter.java new file mode 100644 index 0000000..6167134 --- /dev/null +++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/GFACServiceJobSubmitter.java @@ -0,0 +1,63 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.orchestrator.core.impl; + +import org.apache.airavata.common.utils.ServerSettings; +import org.apache.airavata.gfac.cpi.GfacService; +import org.apache.airavata.gfac.util.Constants; +import org.apache.airavata.orchestrator.core.context.OrchestratorContext; +import org.apache.airavata.orchestrator.core.exception.OrchestratorException; +import org.apache.airavata.orchestrator.core.gfac.GFACInstance; +import org.apache.airavata.orchestrator.core.gfac.GFacClientFactory; +import org.apache.airavata.orchestrator.core.job.JobSubmitter; +import org.apache.thrift.TException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/* + * this class is responsible for submitting a job to gfac in service mode, + * it will select a gfac instance based on the incoming request and submit to that + * gfac instance. + */ +public class GFACServiceJobSubmitter implements JobSubmitter { + private final static Logger logger = LoggerFactory.getLogger(GFACServiceJobSubmitter.class); + + private OrchestratorContext orchestratorContext; + + public void initialize(OrchestratorContext orchestratorContext) throws OrchestratorException { + this.orchestratorContext = orchestratorContext; + } + + public GFACInstance selectGFACInstance() throws OrchestratorException { + // currently we only support one instance but future we have to pick an instance + return null; + } + + public boolean submit(String experimentID, String taskID) throws OrchestratorException { + GfacService.Client localhost = GFacClientFactory.createOrchestratorClient("localhost", + Integer.parseInt(ServerSettings.getSetting(Constants.GFAC_SERVER_PORT, "8950"))); + try { + return localhost.submitJob(experimentID, taskID); + } catch (TException e) { + throw new OrchestratorException(e); + } + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/11b1b9a8/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java ---------------------------------------------------------------------- diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java index 0af1ed8..624ced7 100644 --- a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java +++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java @@ -30,7 +30,7 @@ import org.apache.airavata.model.workspace.experiment.ComputationalResourceSched import org.apache.airavata.model.workspace.experiment.TaskDetails; import org.apache.airavata.orchestrator.core.OrchestratorConfiguration; import org.apache.airavata.orchestrator.core.exception.OrchestratorException; -import org.apache.airavata.orchestrator.core.impl.EmbeddedGFACJobSubmitter; +import org.apache.airavata.orchestrator.core.impl.GFACEmbeddedJobSubmitter; import org.apache.airavata.orchestrator.core.job.JobSubmitter; import org.apache.airavata.orchestrator.cpi.Orchestrator; import org.apache.airavata.orchestrator.cpi.impl.SimpleOrchestratorImpl; @@ -61,7 +61,7 @@ public class OrchestratorUtils { public static HostDescription getHostDescription(Orchestrator orchestrator, TaskDetails taskDetails)throws OrchestratorException { JobSubmitter jobSubmitter = ((SimpleOrchestratorImpl) orchestrator).getJobSubmitter(); - AiravataRegistry2 registry = ((EmbeddedGFACJobSubmitter) jobSubmitter).getOrchestratorContext().getRegistry(); + AiravataRegistry2 registry = ((GFACEmbeddedJobSubmitter) jobSubmitter).getOrchestratorContext().getRegistry(); ComputationalResourceScheduling taskScheduling = taskDetails.getTaskScheduling(); String resourceHostId = taskScheduling.getResourceHostId(); try { http://git-wip-us.apache.org/repos/asf/airavata/blob/11b1b9a8/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/SimpleOrchestratorImpl.java ---------------------------------------------------------------------- diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/SimpleOrchestratorImpl.java b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/SimpleOrchestratorImpl.java index 4c9f81c..5f19c2f 100644 --- a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/SimpleOrchestratorImpl.java +++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/SimpleOrchestratorImpl.java @@ -151,7 +151,6 @@ public class SimpleOrchestratorImpl extends AbstractOrchestrator{ vResult.setResult(false); vResult.setErrorDetails("Error loading the validation class: " + e.getMessage()); validationResults.setValidationState(false); - } validationResults.addToValidationResultList(vResult); }
