http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/listener/AiravataExperimentStatusUpdator.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/listener/AiravataExperimentStatusUpdator.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/listener/AiravataExperimentStatusUpdator.java index f59179e..5f25f8a 100644 --- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/listener/AiravataExperimentStatusUpdator.java +++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/listener/AiravataExperimentStatusUpdator.java @@ -38,8 +38,8 @@ import org.apache.airavata.model.messaging.event.WorkflowNodeStatusChangeEvent; import org.apache.airavata.model.util.ExecutionType; import org.apache.airavata.model.workspace.experiment.Experiment; import org.apache.airavata.model.workspace.experiment.ExperimentState; -import org.apache.airavata.registry.cpi.Registry; -import org.apache.airavata.registry.cpi.RegistryModelType; +import org.apache.airavata.registry.cpi.ExperimentCatalog; +import org.apache.airavata.registry.cpi.ExperimentCatalogModelType; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.utils.ZKPaths; import org.slf4j.Logger; @@ -50,18 +50,18 @@ import java.util.Calendar; public class AiravataExperimentStatusUpdator implements AbstractActivityListener { private final static Logger logger = LoggerFactory.getLogger(AiravataExperimentStatusUpdator.class); - private Registry airavataRegistry; + private ExperimentCatalog airavataExperimentCatalog; private MonitorPublisher monitorPublisher; private Publisher publisher; private CuratorFramework curatorClient; private RabbitMQTaskLaunchConsumer consumer; - public Registry getAiravataRegistry() { - return airavataRegistry; + public ExperimentCatalog getAiravataExperimentCatalog() { + return airavataExperimentCatalog; } - public void setAiravataRegistry(Registry airavataRegistry) { - this.airavataRegistry = airavataRegistry; + public void setAiravataExperimentCatalog(ExperimentCatalog airavataExperimentCatalog) { + this.airavataExperimentCatalog = airavataExperimentCatalog; } @Subscribe @@ -69,7 +69,7 @@ public class AiravataExperimentStatusUpdator implements AbstractActivityListener try { boolean updateExperimentStatus=true; boolean clean= false; - ExecutionType executionType = DataModelUtils.getExecutionType((Experiment) airavataRegistry.get(RegistryModelType.EXPERIMENT, nodeStatus.getWorkflowNodeIdentity().getExperimentId())); + ExecutionType executionType = DataModelUtils.getExecutionType((Experiment) airavataExperimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT, nodeStatus.getWorkflowNodeIdentity().getExperimentId())); String experimentNode = ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_EXPERIMENT_NODE, "/gfac-experiments"); String experimentPath = experimentNode + File.separator + ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_SERVER_NAME) + File.separator + nodeStatus.getWorkflowNodeIdentity().getExperimentId(); @@ -183,7 +183,7 @@ public class AiravataExperimentStatusUpdator implements AbstractActivityListener } public ExperimentState updateExperimentStatus(String experimentId, ExperimentState state) throws Exception { - Experiment details = (Experiment)airavataRegistry.get(RegistryModelType.EXPERIMENT, experimentId); + Experiment details = (Experiment) airavataExperimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT, experimentId); if(details == null) { details = new Experiment(); details.setExperimentID(experimentId); @@ -194,15 +194,15 @@ public class AiravataExperimentStatusUpdator implements AbstractActivityListener status.setExperimentState(state); details.setExperimentStatus(status); logger.info("Updating the experiment status of experiment: " + experimentId + " to " + status.getExperimentState().toString()); - airavataRegistry.update(RegistryModelType.EXPERIMENT_STATUS, status, experimentId); + airavataExperimentCatalog.update(ExperimentCatalogModelType.EXPERIMENT_STATUS, status, experimentId); return details.getExperimentStatus().getExperimentState(); } public void setup(Object... configurations) { for (Object configuration : configurations) { - if (configuration instanceof Registry){ - this.airavataRegistry=(Registry)configuration; + if (configuration instanceof ExperimentCatalog){ + this.airavataExperimentCatalog =(ExperimentCatalog)configuration; } else if (configuration instanceof MonitorPublisher){ this.monitorPublisher=(MonitorPublisher) configuration; } else if (configuration instanceof Publisher){
http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DataModelUtils.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DataModelUtils.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DataModelUtils.java index 8af8956..8ca5c8c 100644 --- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DataModelUtils.java +++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DataModelUtils.java @@ -21,8 +21,8 @@ package org.apache.airavata.api.server.util; -import org.airavata.appcatalog.cpi.AppCatalogException; -import org.airavata.appcatalog.cpi.ApplicationInterface; +import org.apache.airavata.registry.cpi.AppCatalogException; +import org.apache.airavata.registry.cpi.ApplicationInterface; import org.apache.aiaravata.application.catalog.data.impl.AppCatalogFactory; import org.apache.airavata.common.utils.ServerSettings; import org.apache.airavata.model.util.ExecutionType; http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DatabaseCreator.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DatabaseCreator.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DatabaseCreator.java index 0d857ba..3a62688 100644 --- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DatabaseCreator.java +++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DatabaseCreator.java @@ -266,10 +266,10 @@ public class DatabaseCreator { DatabaseType databaseType = DatabaseCreator.getDatabaseType(conn); if(databaseType.equals(DatabaseType.derby)){ is = Thread.currentThread().getContextClassLoader() - .getResourceAsStream("registry-derby.sql"); + .getResourceAsStream("registry-core/src/main/resources/registry-derby.sql"); }else if(databaseType.equals(DatabaseType.derby)){ is = Thread.currentThread().getContextClassLoader() - .getResourceAsStream("registry-mysql.sql"); + .getResourceAsStream("registry-core/src/main/resources/registry-mysql.sql"); } } reader = new BufferedReader(new InputStreamReader(is)); http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java index d7c100b..438bc6a 100644 --- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java +++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java @@ -29,12 +29,12 @@ import java.sql.SQLException; import org.apache.airavata.common.exception.ApplicationSettingsException; import org.apache.airavata.common.utils.ServerSettings; -import org.apache.airavata.experiment.catalog.ResourceType; -import org.apache.airavata.experiment.catalog.ResourceUtils; -import org.apache.airavata.experiment.catalog.resources.GatewayResource; -import org.apache.airavata.experiment.catalog.resources.ProjectResource; -import org.apache.airavata.experiment.catalog.resources.UserResource; -import org.apache.airavata.experiment.catalog.resources.WorkerResource; +import org.apache.airavata.registry.core.experiment.catalog.ResourceType; +import org.apache.airavata.registry.core.experiment.catalog.ResourceUtils; +import org.apache.airavata.registry.core.experiment.catalog.resources.GatewayResource; +import org.apache.airavata.registry.core.experiment.catalog.resources.ProjectResource; +import org.apache.airavata.registry.core.experiment.catalog.resources.UserResource; +import org.apache.airavata.registry.core.experiment.catalog.resources.WorkerResource; import org.apache.derby.drda.NetworkServerControl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/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 5809122..dd7856e 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 @@ -83,7 +83,7 @@ public class CreateLaunchExperiment { airavataClient = AiravataClientFactory.createAiravataClient(THRIFT_SERVER_HOST, THRIFT_SERVER_PORT); AuthzToken token = new AuthzToken("empty_token"); System.out.println("API version is " + airavataClient.getAPIVersion(token)); -// registerApplications(); // run this only the first time + registerApplications(); // run this only the first time createAndLaunchExp(); } http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/AppCatalog.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/AppCatalog.java b/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/AppCatalog.java deleted file mode 100644 index 8ae92c9..0000000 --- a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/AppCatalog.java +++ /dev/null @@ -1,54 +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.airavata.appcatalog.cpi; - -public interface AppCatalog { - /** - * Get ComputeResource interface - * @return ComputeResource interface - */ - ComputeResource getComputeResource() throws AppCatalogException; - - /** - * Get application interface - * @return application interface - */ - ApplicationInterface getApplicationInterface() throws AppCatalogException; - - /** - * Get application deployment interface - * @return application deployment interface - */ - ApplicationDeployment getApplicationDeployment() throws AppCatalogException; - - /** - * Get Gateway profile interface - * @return Gateway profile interface - * @throws AppCatalogException - */ - GwyResourceProfile getGatewayProfile() throws AppCatalogException; - - /** - * Get workflow catalog interface - * @return workflow catalog interface - * @throws AppCatalogException - */ - WorkflowCatalog getWorkflowCatalog() throws AppCatalogException; -} http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/AppCatalogException.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/AppCatalogException.java b/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/AppCatalogException.java deleted file mode 100644 index c1a3c9b..0000000 --- a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/AppCatalogException.java +++ /dev/null @@ -1,36 +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.airavata.appcatalog.cpi; - -public class AppCatalogException extends Exception{ - private static final long serialVersionUID = -2849422320139467602L; - - public AppCatalogException(Throwable e) { - super(e); - } - - public AppCatalogException(String message) { - super(message, null); - } - - public AppCatalogException(String message, Throwable e) { - super(message, e); - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ApplicationDeployment.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ApplicationDeployment.java b/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ApplicationDeployment.java deleted file mode 100644 index b3dfcba..0000000 --- a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ApplicationDeployment.java +++ /dev/null @@ -1,72 +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.airavata.appcatalog.cpi; - -import org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription; - -import java.util.List; -import java.util.Map; - -public interface ApplicationDeployment { - /** - * Add application deployment - * @param deploymentDescription application deployment - * @return unique id for application deployment - */ - String addApplicationDeployment (ApplicationDeploymentDescription deploymentDescription, String gatewayId) throws AppCatalogException; - - /** - * This method will update application deployment - * @param deploymentId unique deployment id - * @param updatedDeployment updated deployment - */ - void updateApplicationDeployment (String deploymentId, ApplicationDeploymentDescription updatedDeployment) throws AppCatalogException;; - - /** - * This method will retrive application deployement - * @param deploymentId unique deployment id - * @return application deployment - */ - ApplicationDeploymentDescription getApplicationDeployement (String deploymentId) throws AppCatalogException; - - /** - * This method will return a list of application deployments according to given search criteria - * @param filters map should be provided as the field name and it's value - * @return list of application deployments - */ - List<ApplicationDeploymentDescription> getApplicationDeployements (Map<String, String> filters) throws AppCatalogException; - - List<ApplicationDeploymentDescription> getAllApplicationDeployements (String gatewayId) throws AppCatalogException; - - List<String> getAllApplicationDeployementIds () throws AppCatalogException; - - /** - * Check whether application deployment exists - * @param deploymentId unique deployment id - * @return true or false - */ - boolean isAppDeploymentExists (String deploymentId) throws AppCatalogException; - - /** - * Remove application deployment - * @param deploymentId unique deployment id - */ - void removeAppDeployment (String deploymentId) throws AppCatalogException; -} http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ApplicationInterface.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ApplicationInterface.java b/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ApplicationInterface.java deleted file mode 100644 index 6b5a42d..0000000 --- a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ApplicationInterface.java +++ /dev/null @@ -1,148 +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.airavata.appcatalog.cpi; - -import org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule; -import org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription; -import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType; -import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType; - -import java.util.List; -import java.util.Map; - -public interface ApplicationInterface { - /** - * This method will add an application module - * @param applicationModule application module - * @return unique module id - */ - String addApplicationModule (ApplicationModule applicationModule, String gatewayId) throws AppCatalogException; - - /** - * This method will add application interface description - * @param applicationInterfaceDescription application interface - * @return unique app interface id - */ - String addApplicationInterface(ApplicationInterfaceDescription applicationInterfaceDescription, String gatewayId) throws AppCatalogException; - - /** - * This method will add an application module mapping - * @param moduleId unique module Id - * @param interfaceId unique interface id - */ - void addApplicationModuleMapping (String moduleId, String interfaceId) throws AppCatalogException; - - /** - * This method will update application module - * @param moduleId unique module Id - * @param updatedModule updated module - * @throws AppCatalogException - */ - void updateApplicationModule (String moduleId, ApplicationModule updatedModule) throws AppCatalogException; - - /** - * This method will update application interface - * @param interfaceId unique interface id - * @param updatedInterface updated app interface - * @throws AppCatalogException - */ - void updateApplicationInterface (String interfaceId, ApplicationInterfaceDescription updatedInterface) throws AppCatalogException; - - /** - * This method will retrieve application module by given module id - * @param moduleId unique module Id - * @return application module object - */ - ApplicationModule getApplicationModule (String moduleId) throws AppCatalogException; - - /** - * This method will retrieve application interface by given interface id - * @param interfaceId unique interface id - * @return application interface desc - */ - ApplicationInterfaceDescription getApplicationInterface(String interfaceId) throws AppCatalogException; - - /** - * This method will return a list of application modules according to given search criteria - * @param filters map should be provided as the field name and it's value - * @return list of application modules - */ - List<ApplicationModule> getApplicationModules(Map<String, String> filters) throws AppCatalogException; - - List<ApplicationModule> getAllApplicationModules(String gatewayId) throws AppCatalogException; - - /** - * This method will return a list of application interfaces according to given search criteria - * @param filters map should be provided as the field name and it's value - * @return list of application interfaces - */ - List<ApplicationInterfaceDescription> getApplicationInterfaces(Map<String, String> filters) throws AppCatalogException; - - /** - * This method will return all the application interfaces - * @return list of all the application interfaces - */ - List<ApplicationInterfaceDescription> getAllApplicationInterfaces(String gatewayId) throws AppCatalogException; - - List<String> getAllApplicationInterfaceIds() throws AppCatalogException; - - /** - * Remove application interface - * @param interfaceId unique interface id - */ - boolean removeApplicationInterface (String interfaceId) throws AppCatalogException; - - /** - * Remove application module - * @param moduleId unique module Id - */ - boolean removeApplicationModule (String moduleId) throws AppCatalogException; - - /** - * Check whether application interface exists - * @param interfaceId unique interface id - * @return true or false - */ - boolean isApplicationInterfaceExists(String interfaceId) throws AppCatalogException; - - /** - * Check whether application module exists - * @param moduleId unique module Id - * @return true or false - */ - boolean isApplicationModuleExists(String moduleId) throws AppCatalogException; - - /** - * This method will retrieve application inputs for given application interface - * @param interfaceId application interface id - * @return list of inputs - * @throws AppCatalogException - */ - List<InputDataObjectType> getApplicationInputs(String interfaceId) throws AppCatalogException; - - /** - * This method will retrieve application outputs for given application interface - * @param interfaceId application interface id - * @return list of output - * @throws AppCatalogException - */ - List<OutputDataObjectType> getApplicationOutputs(String interfaceId) throws AppCatalogException; - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ComputeResource.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ComputeResource.java b/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ComputeResource.java deleted file mode 100644 index c17da17..0000000 --- a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ComputeResource.java +++ /dev/null @@ -1,249 +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.airavata.appcatalog.cpi; - -import java.util.List; -import java.util.Map; - -import org.apache.airavata.model.appcatalog.computeresource.*; - -public interface ComputeResource { - /** - * This function will add a compute resource description to the database - * @param description compute resource description - * @return unique resource ID generated by airavata - */ - String addComputeResource (ComputeResourceDescription description) throws AppCatalogException; - - /** - * This method will update compute resource - * @param computeResourceId unique compute resource id - * @param updatedComputeResource updated compute resource - */ - void updateComputeResource (String computeResourceId, ComputeResourceDescription updatedComputeResource) throws AppCatalogException; - /** - * This function will add a SSHJobSubmission to the database - * @param sshJobSubmission sshJobSubmission object - * @return unique submission ID generated by airavata - */ - String addSSHJobSubmission (SSHJobSubmission sshJobSubmission) throws AppCatalogException; - - - /** - * This function will add a SSHJobSubmission to the database - * @param sshJobSubmission sshJobSubmission object - * @return unique submission ID generated by airavata - */ - String addCloudJobSubmission (CloudJobSubmission sshJobSubmission) throws AppCatalogException; - - - String addResourceJobManager(ResourceJobManager resourceJobManager) throws AppCatalogException; - - void updateResourceJobManager (String resourceJobManagerId, ResourceJobManager updatedResourceJobManager) throws AppCatalogException; - - ResourceJobManager getResourceJobManager (String resourceJobManagerId) throws AppCatalogException; - - void deleteResourceJobManager (String resourceJobManagerId) throws AppCatalogException; - - /** - * This will add a SSHJobSubmission protocol to the database - * @param computeResourceId compute resource id - */ - String addJobSubmissionProtocol(String computeResourceId, JobSubmissionInterface jobSubmissionInterface) throws AppCatalogException; - - String addLocalJobSubmission (LOCALSubmission localSubmission) throws AppCatalogException; - - /** - * This method will add a GlobusJobSubmission to the database - * @param globusJobSubmission GSISSHJobSubmission object - * @return uniquely generated submission id - */ - String addGlobusJobSubmission (GlobusJobSubmission globusJobSubmission) throws AppCatalogException; - - /** - * This method will add a UNICOREJobSubmission to the database - * @param unicoreJobSubmission - * @return uniquely generated submission id - */ - String addUNICOREJobSubmission (UnicoreJobSubmission unicoreJobSubmission) throws AppCatalogException; - - - - String addLocalDataMovement (LOCALDataMovement localDataMovement) throws AppCatalogException; - - /** - * This method will add a SCPData movement to the database - * @param scpDataMovement SCPData movement object - * @return uniquely generated data move id - */ - String addScpDataMovement (SCPDataMovement scpDataMovement) throws AppCatalogException; - - String addUnicoreDataMovement (UnicoreDataMovement unicoreDataMovement) throws AppCatalogException; - - /** - * This will add a SCPDataMovement protocol to the database - * @param computeResourceId compute resource id - */ - String addDataMovementProtocol (String computeResourceId, DataMovementInterface dataMovementInterface) throws AppCatalogException; - - /** - * This method will add a GridFTP Data movement to the database - * @param gridFTPDataMovement GridFTP Data movement object - * @return uniquely generated data move id - */ - String addGridFTPDataMovement (GridFTPDataMovement gridFTPDataMovement) throws AppCatalogException; - - /** - * This method will retrieve compute resource object on given resource id - * @param resourceId unique resource id - * @return ComputeResource object - */ - ComputeResourceDescription getComputeResource (String resourceId) throws AppCatalogException; - - /** - * This method will return a list of computeResource descriptions according to given search criteria - * @param filters map should be provided as the field name and it's value - * @return list of compute resources - */ - List<ComputeResourceDescription> getComputeResourceList (Map<String, String> filters) throws AppCatalogException; - - /** - * This method will retrieve all the compute resources - * @return list of compute resources - * @throws AppCatalogException - */ - List<ComputeResourceDescription> getAllComputeResourceList () throws AppCatalogException; - - /** - * This method will retrieve all the compute resource id with it's name - * @return map of compute resource ids + name - * @throws AppCatalogException - */ - Map<String, String> getAllComputeResourceIdList () throws AppCatalogException; - - - -// /** -// * This method will retrieve GlobusJobSubmission object -// * @param submissionId unique submission id -// * @return GlobusJobSubmission object -// */ -// GlobusJobSubmission getGlobusJobSubmission (String submissionId) throws AppCatalogException; -// -// /** -// * This method will return a list of GlobusJobSubmission objects according to given search criteria -// * @param filters map should be provided as the field name and it's value -// * @return list of GlobusJobSubmission objects -// */ -// List<GlobusJobSubmission> getGlobusJobSubmissionList (Map<String, String> filters) throws AppCatalogException; - - /** - * This method will retrieve GSISSHJobSubmission object - * @param submissionId unique submission id - * @return GSISSHSubmission object - */ - SSHJobSubmission getSSHJobSubmission (String submissionId) throws AppCatalogException; - - /** - * This method will retrieve UnicoreJobSubmission object - * @param submissionId unique submission id - * @return UnicoreSubmission object - */ - UnicoreJobSubmission getUNICOREJobSubmission (String submissionId) throws AppCatalogException; - UnicoreDataMovement getUNICOREDataMovement (String dataMovementId) throws AppCatalogException; - - - - /** - * This method will retrieve GSISSHJobSubmission object - * @param submissionId unique submission id - * @return GSISSHSubmission object - */ - CloudJobSubmission getCloudJobSubmission (String submissionId) throws AppCatalogException; -// /** -// * This method will return a list of GSISSHSubmission objects according to given search criteria -// * @param filters map should be provided as the field name and it's value -// * @return list of GSISSHSubmission objects -// */ -// List<SSHJobSubmission> getSSHJobSubmissionList (Map<String, String> filters) throws AppCatalogException; - /** - * This method will retrieve SCP Data movement object - * @param dataMoveId unique data move id - * @return SCPDataMovement object - */ - SCPDataMovement getSCPDataMovement (String dataMoveId) throws AppCatalogException; - -// /** -// * This method will return a list of SCPDataMovement objects according to given search criteria -// * @param filters map should be provided as the field name and it's value -// * @return list of SCPDataMovement objects -// */ -// List<SCPDataMovement> getSCPDataMovementList (Map<String, String> filters) throws AppCatalogException; - - /** - * This method will retrieve GridFTPDataMovement object - * @param dataMoveId unique data move id - * @return GridFTPDataMovement object - */ - GridFTPDataMovement getGridFTPDataMovement (String dataMoveId) throws AppCatalogException; - -// /** -// * This method will return a list of GridFTPDataMovement objects according to given search criteria -// * @param filters map should be provided as the field name and it's value -// * @return list of GridFTPDataMovement objects -// */ -// List<GridFTPDataMovement> getGridFTPDataMovementList (Map<String, String> filters) throws AppCatalogException; - - /** - * This method will check whether the given resource already exists in the system - * @param resourceId unique resource id - * @return true or false - */ - boolean isComputeResourceExists (String resourceId) throws AppCatalogException; - - /** - * This method will remove given resource from the system - * @param resourceId unique resource id - */ - void removeComputeResource (String resourceId) throws AppCatalogException; - - /** - * This method will remove job submission interface - * @param jobSubmissionInterfaceId unique job submission interface id - * @throws AppCatalogException - */ - void removeJobSubmissionInterface(String computeResourceId, String jobSubmissionInterfaceId) throws AppCatalogException; - - /** - * This method will remove data movement interface - * @param dataMovementInterfaceId unique data movement id - * @throws AppCatalogException - */ - void removeDataMovementInterface(String computeResourceId, String dataMovementInterfaceId) throws AppCatalogException; - - void removeBatchQueue(String computeResourceId, String queueName) throws AppCatalogException; - - - - LOCALSubmission getLocalJobSubmission(String submissionId) throws AppCatalogException; - - LOCALDataMovement getLocalDataMovement(String datamovementId) throws AppCatalogException; - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/GwyResourceProfile.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/GwyResourceProfile.java b/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/GwyResourceProfile.java deleted file mode 100644 index d6d04fc..0000000 --- a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/GwyResourceProfile.java +++ /dev/null @@ -1,81 +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.airavata.appcatalog.cpi; - -import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference; -import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile; - -import java.util.List; - -public interface GwyResourceProfile { - /** - * This method will add a gateway profile - * @param gatewayProfile gateway profile - * @return gateway id - */ - String addGatewayResourceProfile(GatewayResourceProfile gatewayProfile) throws AppCatalogException; - - /** - * This method will update a gateway profile - * @param gatewayId unique gateway id - * @param updatedProfile updated profile - */ - void updateGatewayResourceProfile(String gatewayId, GatewayResourceProfile updatedProfile) throws AppCatalogException; - - /** - * - * @param gatewayId - * @return - */ - GatewayResourceProfile getGatewayProfile (String gatewayId) throws AppCatalogException; - - /** - * This method will remove a gateway profile - * @param gatewayId unique gateway id - * @return true or false - */ - boolean removeGatewayResourceProfile(String gatewayId) throws AppCatalogException; - boolean removeComputeResourcePreferenceFromGateway(String gatewayId, String preferenceId) throws AppCatalogException; - - /** - * This method will check whether gateway profile exists - * @param gatewayId unique gateway id - * @return true or false - */ - boolean isGatewayResourceProfileExists(String gatewayId) throws AppCatalogException; - - /** - * - * @param gatewayId - * @param hostId - * @return ComputeResourcePreference - */ - ComputeResourcePreference getComputeResourcePreference (String gatewayId, String hostId) throws AppCatalogException; - - /** - * - * @param gatewayId - * @return - */ - List<ComputeResourcePreference> getAllComputeResourcePreferences (String gatewayId) throws AppCatalogException; - - List<String> getGatewayProfileIds (String gatewayName) throws AppCatalogException; - List<GatewayResourceProfile> getAllGatewayProfiles () throws AppCatalogException; -} http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/WorkflowCatalog.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/WorkflowCatalog.java b/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/WorkflowCatalog.java deleted file mode 100644 index 6beeb60..0000000 --- a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/WorkflowCatalog.java +++ /dev/null @@ -1,45 +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.airavata.appcatalog.cpi; - -import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType; - -import java.util.List; - -public interface WorkflowCatalog { - - public List<String> getAllWorkflows(String gatewayId) throws AppCatalogException; - - public org.apache.airavata.model.Workflow getWorkflow(String workflowTemplateId) throws AppCatalogException; - - public void deleteWorkflow(String workflowTemplateId) throws AppCatalogException; - - public String registerWorkflow(org.apache.airavata.model.Workflow workflow, String gatewayId) throws AppCatalogException; - - public void updateWorkflow(String workflowTemplateId, org.apache.airavata.model.Workflow workflow) throws AppCatalogException; - - public String getWorkflowTemplateId(String workflowName) throws AppCatalogException; - - public boolean isWorkflowExistWithName(String workflowName) throws AppCatalogException; - - public void updateWorkflowOutputs(String workflowTemplateId, List<OutputDataObjectType> workflowOutputs) throws AppCatalogException; -} http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/AppCatalogFactory.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/AppCatalogFactory.java b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/AppCatalogFactory.java deleted file mode 100644 index 34e0976..0000000 --- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/AppCatalogFactory.java +++ /dev/null @@ -1,46 +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.aiaravata.application.catalog.data.impl; - -import org.airavata.appcatalog.cpi.AppCatalog; -import org.airavata.appcatalog.cpi.AppCatalogException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AppCatalogFactory { - private static AppCatalog appCatalog; - - private static Logger logger = LoggerFactory.getLogger(AppCatalogFactory.class); - - public static AppCatalog getAppCatalog() throws AppCatalogException{ - try { - if (appCatalog == null){ - appCatalog = new AppCatalogImpl(); - } - - }catch (Exception e){ - logger.error("Unable to create app catalog instance", e); - throw new AppCatalogException(e); - } - return appCatalog; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/AppCatalogImpl.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/AppCatalogImpl.java b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/AppCatalogImpl.java deleted file mode 100644 index 246554b..0000000 --- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/AppCatalogImpl.java +++ /dev/null @@ -1,52 +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.aiaravata.application.catalog.data.impl; - -import org.airavata.appcatalog.cpi.*; -import org.airavata.appcatalog.cpi.GwyResourceProfile; - -public class AppCatalogImpl implements AppCatalog { - @Override - public ComputeResource getComputeResource() { - return new ComputeResourceImpl(); - } - - @Override - public ApplicationInterface getApplicationInterface() { - return new ApplicationInterfaceImpl(); - } - - @Override - public ApplicationDeployment getApplicationDeployment() { - return new ApplicationDeploymentImpl(); - } - - @Override - public GwyResourceProfile getGatewayProfile() throws AppCatalogException { - return new GwyResourceProfileImpl(); - } - - @Override - public WorkflowCatalog getWorkflowCatalog() throws AppCatalogException { - return new WorkflowCatalogImpl(); - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/ec8c6202/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationDeploymentImpl.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationDeploymentImpl.java b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationDeploymentImpl.java deleted file mode 100644 index f0027ab..0000000 --- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationDeploymentImpl.java +++ /dev/null @@ -1,414 +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.aiaravata.application.catalog.data.impl; - -import org.airavata.appcatalog.cpi.AppCatalogException; -import org.airavata.appcatalog.cpi.ApplicationDeployment; -import org.apache.aiaravata.application.catalog.data.resources.*; -import org.apache.aiaravata.application.catalog.data.util.AppCatalogThriftConversion; -import org.apache.aiaravata.application.catalog.data.util.AppCatalogUtils; -import org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription; -import org.apache.airavata.model.appcatalog.appdeployment.ApplicationParallelismType; -import org.apache.airavata.model.appcatalog.appdeployment.SetEnvPaths; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class ApplicationDeploymentImpl implements ApplicationDeployment { - private final static Logger logger = LoggerFactory.getLogger(ApplicationDeploymentImpl.class); - - @Override - public String addApplicationDeployment(ApplicationDeploymentDescription deploymentDescription, String gatewayId) throws AppCatalogException { - try { - AppDeploymentResource deploymentResource = new AppDeploymentResource(); - ComputeResourceResource computeHostResource = new ComputeResourceResource(); - AppModuleResource moduleResource = new AppModuleResource(); - if (!computeHostResource.isExists(deploymentDescription.getComputeHostId())){ - logger.error("Compute host does not exist in the system. Please create a Compute host first..."); - throw new AppCatalogException("Compute host does not exist in the system. Please create a Compute host first..."); - } - if (!moduleResource.isExists(deploymentDescription.getAppModuleId())){ - logger.error("Application module does not exist in the system. Please create an application module first..."); - throw new AppCatalogException("Application module does not exist in the system. Please create an application module first..."); - } - AppModuleResource module = (AppModuleResource)moduleResource.get(deploymentDescription.getAppModuleId()); - ComputeResourceResource hostResource = (ComputeResourceResource) computeHostResource.get(deploymentDescription.getComputeHostId()); - deploymentResource.setDeploymentId(hostResource.getHostName() + "_" + deploymentDescription.getAppModuleId()); - deploymentResource.setAppModuleId(deploymentDescription.getAppModuleId()); - deploymentResource.setModuleResource(module); - deploymentResource.setHostId(deploymentDescription.getComputeHostId()); - deploymentResource.setHostResource(hostResource); - deploymentResource.setAppDes(deploymentDescription.getAppDeploymentDescription()); - deploymentResource.setExecutablePath(deploymentDescription.getExecutablePath()); - deploymentResource.setGatewayId(gatewayId); - ApplicationParallelismType parallelism = deploymentDescription.getParallelism(); - if (parallelism != null){ - deploymentResource.setParallelism(parallelism.toString()); - } - deploymentResource.save(); - deploymentDescription.setAppDeploymentId(deploymentResource.getDeploymentId()); - - List<String> moduleLoadCmds = deploymentDescription.getModuleLoadCmds(); - if (moduleLoadCmds != null && !moduleLoadCmds.isEmpty()){ - for (String cmd : moduleLoadCmds){ - ModuleLoadCmdResource cmdResource = new ModuleLoadCmdResource(); - cmdResource.setAppDeploymentId(deploymentDescription.getAppDeploymentId()); - cmdResource.setCmd(cmd); - cmdResource.save(); - } - } - - List<String> preJobCommands = deploymentDescription.getPreJobCommands(); - if (preJobCommands != null && !preJobCommands.isEmpty()){ - for (String cmd : preJobCommands){ - PreJobCommandResource cmdResource = new PreJobCommandResource(); - cmdResource.setAppDeploymentId(deploymentDescription.getAppDeploymentId()); - cmdResource.setCommand(cmd); - cmdResource.save(); - } - } - - List<String> postJobCommands = deploymentDescription.getPostJobCommands(); - if (postJobCommands != null && !postJobCommands.isEmpty()){ - for (String cmd : postJobCommands){ - PostJobCommandResource cmdResource = new PostJobCommandResource(); - cmdResource.setAppDeploymentId(deploymentDescription.getAppDeploymentId()); - cmdResource.setCommand(cmd); - cmdResource.save(); - } - } - - List<SetEnvPaths> libPrependPaths = deploymentDescription.getLibPrependPaths(); - if (libPrependPaths != null && !libPrependPaths.isEmpty()){ - for (SetEnvPaths path : libPrependPaths){ - LibraryPrepandPathResource prepandPathResource = new LibraryPrepandPathResource(); - prepandPathResource.setAppDeploymentResource(deploymentResource); - prepandPathResource.setName(path.getName()); - prepandPathResource.setValue(path.getValue()); - prepandPathResource.setDeploymentId(deploymentResource.getDeploymentId()); - prepandPathResource.save(); - } - } - - List<SetEnvPaths> libApendPaths = deploymentDescription.getLibAppendPaths(); - if (libApendPaths != null && !libApendPaths.isEmpty()){ - for (SetEnvPaths path : libApendPaths){ - LibraryApendPathResource apendPathResource = new LibraryApendPathResource(); - apendPathResource.setAppDeploymentResource(deploymentResource); - apendPathResource.setName(path.getName()); - apendPathResource.setValue(path.getValue()); - apendPathResource.setDeploymentId(deploymentResource.getDeploymentId()); - apendPathResource.save(); - } - } - List<SetEnvPaths> setEnvironment = deploymentDescription.getSetEnvironment(); - if (setEnvironment != null && !setEnvironment.isEmpty()){ - for (SetEnvPaths path : setEnvironment){ - AppEnvironmentResource environmentResource = new AppEnvironmentResource(); - environmentResource.setAppDeploymentResource(deploymentResource); - environmentResource.setName(path.getName()); - environmentResource.setValue(path.getValue()); - environmentResource.setDeploymentId(deploymentResource.getDeploymentId()); - environmentResource.save(); - } - } - return deploymentResource.getDeploymentId(); - }catch (Exception e) { - logger.error("Error while saving application deployment...", e); - throw new AppCatalogException(e); - } - } - - @Override - public void updateApplicationDeployment(String deploymentId, ApplicationDeploymentDescription updatedDeployment) throws AppCatalogException { - try { - AppDeploymentResource deploymentResource = new AppDeploymentResource(); - AppDeploymentResource existingDep = (AppDeploymentResource)deploymentResource.get(deploymentId); - ComputeResourceResource computeHostResource = new ComputeResourceResource(); - AppModuleResource moduleResource = new AppModuleResource(); - if (!computeHostResource.isExists(updatedDeployment.getComputeHostId())){ - logger.error("Compute host does not exist in the system. Please create a Compute host first..."); - throw new AppCatalogException("Compute host does not exist in the system. Please create a Compute host first..."); - } - if (!moduleResource.isExists(updatedDeployment.getAppModuleId())){ - logger.error("Application module does not exist in the system. Please create an application module first..."); - throw new AppCatalogException("Application module does not exist in the system. Please create an application module first..."); - } - AppModuleResource module = (AppModuleResource)moduleResource.get(updatedDeployment.getAppModuleId()); - existingDep.setAppModuleId(updatedDeployment.getAppModuleId()); - existingDep.setModuleResource(module); - existingDep.setHostId(updatedDeployment.getComputeHostId()); - existingDep.setHostResource((ComputeResourceResource)computeHostResource.get(updatedDeployment.getComputeHostId())); - existingDep.setAppDes(updatedDeployment.getAppDeploymentDescription()); - existingDep.setExecutablePath(updatedDeployment.getExecutablePath()); - if (updatedDeployment.getParallelism() != null){ - deploymentResource.setParallelism(updatedDeployment.getParallelism().toString()); - } - - existingDep.save(); - - // remove existing module load commands - ModuleLoadCmdResource cmdResource = new ModuleLoadCmdResource(); - Map<String, String> ids = new HashMap<String, String>(); - ids.put(AbstractResource.ModuleLoadCmdConstants.APP_DEPLOYMENT_ID, deploymentId); - cmdResource.remove(ids); - List<String> moduleLoadCmds = updatedDeployment.getModuleLoadCmds(); - if (moduleLoadCmds != null && !moduleLoadCmds.isEmpty()){ - for (String cmd : moduleLoadCmds){ - ids = new HashMap<String, String>(); - ids.put(AbstractResource.ModuleLoadCmdConstants.APP_DEPLOYMENT_ID, deploymentId); - ids.put(AbstractResource.ModuleLoadCmdConstants.CMD, cmd); - if (cmdResource.isExists(ids)){ - cmdResource = (ModuleLoadCmdResource)cmdResource.get(ids); - } - cmdResource.setCmd(cmd); - cmdResource.setAppDeploymentResource(existingDep); - cmdResource.setAppDeploymentId(deploymentId); - cmdResource.save(); - } - } - - PreJobCommandResource preJobCommandResource = new PreJobCommandResource(); - ids = new HashMap<String, String>(); - ids.put(AbstractResource.PreJobCommandConstants.DEPLOYMENT_ID, deploymentId); - preJobCommandResource.remove(ids); - List<String> preJobCommands = updatedDeployment.getPreJobCommands(); - if (preJobCommands != null && !preJobCommands.isEmpty()){ - for (String cmd : preJobCommands){ - ids = new HashMap<String, String>(); - ids.put(AbstractResource.PreJobCommandConstants.DEPLOYMENT_ID, deploymentId); - ids.put(AbstractResource.PreJobCommandConstants.COMMAND, cmd); - if (preJobCommandResource.isExists(ids)){ - preJobCommandResource = (PreJobCommandResource)preJobCommandResource.get(ids); - } - preJobCommandResource.setCommand(cmd); - preJobCommandResource.setAppDeploymentResource(existingDep); - preJobCommandResource.setAppDeploymentId(deploymentId); - preJobCommandResource.save(); - } - } - - PostJobCommandResource postJobCommandResource = new PostJobCommandResource(); - ids = new HashMap<String, String>(); - ids.put(AbstractResource.PostJobCommandConstants.DEPLOYMENT_ID, deploymentId); - postJobCommandResource.remove(ids); - List<String> postJobCommands = updatedDeployment.getPostJobCommands(); - if (postJobCommands != null && !postJobCommands.isEmpty()){ - for (String cmd : postJobCommands){ - ids = new HashMap<String, String>(); - ids.put(AbstractResource.PostJobCommandConstants.DEPLOYMENT_ID, deploymentId); - ids.put(AbstractResource.PostJobCommandConstants.COMMAND, cmd); - if (postJobCommandResource.isExists(ids)){ - postJobCommandResource = (PostJobCommandResource)postJobCommandResource.get(ids); - } - postJobCommandResource.setCommand(cmd); - postJobCommandResource.setAppDeploymentResource(existingDep); - postJobCommandResource.setAppDeploymentId(deploymentId); - postJobCommandResource.save(); - } - } - - // remove existing lib prepand paths - LibraryPrepandPathResource prepandPathResource = new LibraryPrepandPathResource(); - ids = new HashMap<String, String>(); - ids.put(AbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID, deploymentId); - prepandPathResource.remove(ids); - List<SetEnvPaths> libPrependPaths = updatedDeployment.getLibPrependPaths(); - if (libPrependPaths != null && !libPrependPaths.isEmpty()){ - for (SetEnvPaths path : libPrependPaths){ - ids = new HashMap<String, String>(); - ids.put(AbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID, deploymentId); - ids.put(AbstractResource.LibraryPrepandPathConstants.NAME, path.getName()); - if (prepandPathResource.isExists(ids)){ - prepandPathResource = (LibraryPrepandPathResource)prepandPathResource.get(ids); - } - prepandPathResource.setAppDeploymentResource(existingDep); - prepandPathResource.setName(path.getName()); - prepandPathResource.setValue(path.getValue()); - prepandPathResource.setDeploymentId(deploymentId); - prepandPathResource.save(); - } - } - - List<SetEnvPaths> libApendPaths = updatedDeployment.getLibAppendPaths(); - // remove lib append paths - LibraryApendPathResource apendPathResource = new LibraryApendPathResource(); - ids = new HashMap<String, String>(); - ids.put(AbstractResource.LibraryApendPathConstants.DEPLOYMENT_ID, deploymentId); - apendPathResource.remove(ids); - if (libApendPaths != null && !libApendPaths.isEmpty()){ - for (SetEnvPaths path : libApendPaths){ - ids = new HashMap<String, String>(); - ids.put(AbstractResource.LibraryApendPathConstants.DEPLOYMENT_ID, deploymentId); - ids.put(AbstractResource.LibraryApendPathConstants.NAME, path.getName()); - if (apendPathResource.isExists(ids)){ - apendPathResource = (LibraryApendPathResource)apendPathResource.get(ids); - } - apendPathResource.setAppDeploymentResource(existingDep); - apendPathResource.setName(path.getName()); - apendPathResource.setValue(path.getValue()); - apendPathResource.setDeploymentId(deploymentId); - apendPathResource.save(); - } - } - - List<SetEnvPaths> setEnvironment = updatedDeployment.getSetEnvironment(); - // remove existing setEnvPaths - AppEnvironmentResource environmentResource = new AppEnvironmentResource(); - ids = new HashMap<String, String>(); - ids.put(AbstractResource.AppEnvironmentConstants.DEPLOYMENT_ID, deploymentId); - environmentResource.remove(ids); - if (setEnvironment != null && !setEnvironment.isEmpty()){ - for (SetEnvPaths path : setEnvironment){ - ids = new HashMap<String, String>(); - ids.put(AbstractResource.AppEnvironmentConstants.DEPLOYMENT_ID, deploymentId); - ids.put(AbstractResource.AppEnvironmentConstants.NAME, path.getName()); - if (environmentResource.isExists(ids)){ - environmentResource = (AppEnvironmentResource)environmentResource.get(ids); - } - environmentResource.setAppDeploymentResource(existingDep); - environmentResource.setName(path.getName()); - environmentResource.setValue(path.getValue()); - environmentResource.setDeploymentId(deploymentId); - environmentResource.save(); - } - } - }catch (Exception e) { - logger.error("Error while updating application deployment...", e); - throw new AppCatalogException(e); - } - } - - @Override - public ApplicationDeploymentDescription getApplicationDeployement(String deploymentId) throws AppCatalogException { - try { - AppDeploymentResource deploymentResource = new AppDeploymentResource(); - AppDeploymentResource appDep = (AppDeploymentResource)deploymentResource.get(deploymentId); - return AppCatalogThriftConversion.getApplicationDeploymentDescription(appDep); - }catch (Exception e) { - logger.error("Error while retrieving application deployment...", e); - throw new AppCatalogException(e); - } - } - - @Override - public List<ApplicationDeploymentDescription> getApplicationDeployements(Map<String, String> filters) throws AppCatalogException { - List<ApplicationDeploymentDescription> deploymentDescriptions = new ArrayList<ApplicationDeploymentDescription>(); - try { - AppDeploymentResource resource = new AppDeploymentResource(); - boolean firstTry=true; - for (String fieldName : filters.keySet() ){ - List<ApplicationDeploymentDescription> tmpDescriptions = new ArrayList<ApplicationDeploymentDescription>(); - if (fieldName.equals(AbstractResource.ApplicationDeploymentConstants.APP_MODULE_ID)){ - List<Resource> resources = resource.get(AbstractResource.ApplicationDeploymentConstants.APP_MODULE_ID, filters.get(fieldName)); - if (resources != null && !resources.isEmpty()){ - tmpDescriptions = AppCatalogThriftConversion.getAppDepDescList(resources); - } - }else if (fieldName.equals(AbstractResource.ApplicationDeploymentConstants.COMPUTE_HOST_ID)){ - List<Resource> resources = resource.get(AbstractResource.ApplicationDeploymentConstants.COMPUTE_HOST_ID, filters.get(fieldName)); - if (resources != null && !resources.isEmpty()){ - tmpDescriptions = AppCatalogThriftConversion.getAppDepDescList(resources); - } - } else { - logger.error("Unsupported field name for app deployment.", new IllegalArgumentException()); - throw new IllegalArgumentException("Unsupported field name for app deployment."); - } - if (firstTry){ - deploymentDescriptions.addAll(tmpDescriptions); - firstTry=false; - }else{ - List<String> ids=new ArrayList<String>(); - for (ApplicationDeploymentDescription applicationDeploymentDescription : deploymentDescriptions) { - ids.add(applicationDeploymentDescription.getAppDeploymentId()); - } - List<ApplicationDeploymentDescription> tmp2Descriptions = new ArrayList<ApplicationDeploymentDescription>(); - for (ApplicationDeploymentDescription applicationDeploymentDescription : tmpDescriptions) { - if (ids.contains(applicationDeploymentDescription.getAppDeploymentId())){ - tmp2Descriptions.add(applicationDeploymentDescription); - } - } - deploymentDescriptions.clear(); - deploymentDescriptions.addAll(tmp2Descriptions); - } - } - }catch (Exception e){ - logger.error("Error while retrieving app deployment list...", e); - throw new AppCatalogException(e); - } - return deploymentDescriptions; - } - - @Override - public List<ApplicationDeploymentDescription> getAllApplicationDeployements(String gatewayId) throws AppCatalogException { - List<ApplicationDeploymentDescription> deploymentDescriptions = new ArrayList<ApplicationDeploymentDescription>(); - try { - AppDeploymentResource resource = new AppDeploymentResource(); - resource.setGatewayId(gatewayId); - List<Resource> resources = resource.getAll(); - if (resources != null && !resources.isEmpty()){ - deploymentDescriptions = AppCatalogThriftConversion.getAppDepDescList(resources); - } - - }catch (Exception e){ - logger.error("Error while retrieving app deployment list...", e); - throw new AppCatalogException(e); - } - return deploymentDescriptions; - } - - @Override - public List<String> getAllApplicationDeployementIds() throws AppCatalogException { - try { - AppDeploymentResource resource = new AppDeploymentResource(); - return resource.getAllIds(); - }catch (Exception e){ - logger.error("Error while retrieving app deployment list...", e); - throw new AppCatalogException(e); - } - } - - @Override - public boolean isAppDeploymentExists(String deploymentId) throws AppCatalogException { - try { - AppDeploymentResource deploymentResource = new AppDeploymentResource(); - return deploymentResource.isExists(deploymentId); - }catch (Exception e){ - logger.error("Error while retrieving app deployment...", e); - throw new AppCatalogException(e); - } - } - - @Override - public void removeAppDeployment(String deploymentId) throws AppCatalogException { - try { - AppDeploymentResource deploymentResource = new AppDeploymentResource(); - deploymentResource.remove(deploymentId); - }catch (Exception e){ - logger.error("Error while deleting app deployment...", e); - throw new AppCatalogException(e); - } - } -}
