You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2016/03/03 19:15:21 UTC
[11/14] airavata git commit: adding parallelism type
adding parallelism type
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/d66d1698
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/d66d1698
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/d66d1698
Branch: refs/heads/master
Commit: d66d16980be161817dd9c24048a99bc50183605c
Parents: f0c730c
Author: Chathuri Wimalasena <ch...@apache.org>
Authored: Fri Feb 26 16:38:47 2016 -0500
Committer: Chathuri Wimalasena <ch...@apache.org>
Committed: Fri Feb 26 16:38:47 2016 -0500
----------------------------------------------------------------------
.../ApplicationParallelismType.java | 90 -----
.../apache/airavata/gfac/core/GFacUtils.java | 2 +-
.../app/catalog/impl/ComputeResourceImpl.java | 33 ++
.../catalog/model/ParallelismPrefixCommand.java | 78 +++++
.../model/ParallelismPrefixCommand_PK.java | 62 ++++
.../resources/AppCatAbstractResource.java | 7 +
.../ParallelismPrefixCommandResource.java | 350 +++++++++++++++++++
.../app/catalog/util/AppCatalogJPAUtils.java | 18 +
.../catalog/util/AppCatalogResourceType.java | 1 +
.../util/AppCatalogThriftConversion.java | 12 +
.../src/main/resources/appcatalog-derby.sql | 9 +
.../src/main/resources/appcatalog-mysql.sql | 9 +
12 files changed, 580 insertions(+), 91 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/d66d1698/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/appdeployment/ApplicationParallelismType.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/appdeployment/ApplicationParallelismType.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/appdeployment/ApplicationParallelismType.java
deleted file mode 100644
index 11323d2..0000000
--- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/appdeployment/ApplicationParallelismType.java
+++ /dev/null
@@ -1,90 +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.
- */
-
-/**
- * Autogenerated by Thrift Compiler (0.9.3)
- *
- * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
- * @generated
- */
-package org.apache.airavata.model.appcatalog.appdeployment;
-
-
-import java.util.Map;
-import java.util.HashMap;
-import org.apache.thrift.TEnum;
-
-/**
- * Enumeration of application parallelism supported by Airavata
- *
- * SERIAL:
- * Single processor applications without any parallelization.
- *
- * MPI:
- * Messaging Passing Interface.
- *
- * OPENMP:
- * Shared Memory Implementtaion.
- *
- * OPENMP_MPI:
- * Hybrid Applications.
- *
- */
-public enum ApplicationParallelismType implements org.apache.thrift.TEnum {
- SERIAL(0),
- MPI(1),
- OPENMP(2),
- OPENMP_MPI(3),
- CCM(4),
- CRAY_MPI(5);
-
- private final int value;
-
- private ApplicationParallelismType(int value) {
- this.value = value;
- }
-
- /**
- * Get the integer value of this enum value, as defined in the Thrift IDL.
- */
- public int getValue() {
- return value;
- }
-
- /**
- * Find a the enum type by its integer value, as defined in the Thrift IDL.
- * @return null if the value is not found.
- */
- public static ApplicationParallelismType findByValue(int value) {
- switch (value) {
- case 0:
- return SERIAL;
- case 1:
- return MPI;
- case 2:
- return OPENMP;
- case 3:
- return OPENMP_MPI;
- case 4:
- return CCM;
- case 5:
- return CRAY_MPI;
- default:
- return null;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d66d1698/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
index 54f3715..1325659 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/GFacUtils.java
@@ -28,7 +28,6 @@ import org.apache.airavata.gfac.core.context.ProcessContext;
import org.apache.airavata.gfac.core.context.TaskContext;
import org.apache.airavata.messaging.core.MessageContext;
import org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription;
-import org.apache.airavata.model.appcatalog.appdeployment.ApplicationParallelismType;
import org.apache.airavata.model.appcatalog.appdeployment.CommandObject;
import org.apache.airavata.model.appcatalog.computeresource.*;
import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference;
@@ -39,6 +38,7 @@ import org.apache.airavata.model.commons.ErrorModel;
import org.apache.airavata.model.experiment.ExperimentModel;
import org.apache.airavata.model.job.JobModel;
import org.apache.airavata.model.messaging.event.*;
+import org.apache.airavata.model.parallelism.ApplicationParallelismType;
import org.apache.airavata.model.process.ProcessModel;
import org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel;
import org.apache.airavata.model.status.*;
http://git-wip-us.apache.org/repos/asf/airavata/blob/d66d1698/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ComputeResourceImpl.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ComputeResourceImpl.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ComputeResourceImpl.java
index 3dbf671..e0e260c 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ComputeResourceImpl.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ComputeResourceImpl.java
@@ -24,6 +24,8 @@ package org.apache.airavata.registry.core.app.catalog.impl;
import org.apache.airavata.model.appcatalog.computeresource.*;
import org.apache.airavata.model.data.movement.*;
import org.apache.airavata.model.data.movement.DMType;
+import org.apache.airavata.model.parallelism.ApplicationParallelismType;
+import org.apache.airavata.registry.core.app.catalog.model.ParallelismPrefixCommand;
import org.apache.airavata.registry.core.app.catalog.resources.*;
import org.apache.airavata.registry.core.app.catalog.util.AppCatalogThriftConversion;
import org.apache.airavata.registry.core.app.catalog.util.AppCatalogUtils;
@@ -829,6 +831,17 @@ public class ComputeResourceImpl implements ComputeResource {
r.save();
}
}
+
+ Map<ApplicationParallelismType, String> parallelismPrefix = resourceJobManager.getParallelismPrefix();
+ if (parallelismPrefix!=null && parallelismPrefix.size() != 0) {
+ for (ApplicationParallelismType commandType : parallelismPrefix.keySet()) {
+ ParallelismPrefixCommandResource r = new ParallelismPrefixCommandResource();
+ r.setCommandType(commandType.toString());
+ r.setCommand(parallelismPrefix.get(commandType));
+ r.setResourceJobManagerId(resource.getResourceJobManagerId());
+ r.save();
+ }
+ }
return resource.getResourceJobManagerId();
}
@@ -857,6 +870,26 @@ public class ComputeResourceImpl implements ComputeResource {
existingCommand.save();
}
}
+
+ Map<ApplicationParallelismType, String> parallelismPrefix = updatedResourceJobManager.getParallelismPrefix();
+ if (parallelismPrefix!=null && parallelismPrefix.size() != 0) {
+ for (ApplicationParallelismType commandType : parallelismPrefix.keySet()) {
+ ParallelismPrefixCommandResource r = new ParallelismPrefixCommandResource();
+ Map<String, String> ids = new HashMap<String, String>();
+ ids.put(AppCatAbstractResource.ParallelismCommandConstants.RESOURCE_JOB_MANAGER_ID, resourceJobManagerId);
+ ids.put(AppCatAbstractResource.ParallelismCommandConstants.COMMAND_TYPE, commandType.toString());
+ ParallelismPrefixCommandResource existingCommand;
+ if (r.isExists(ids)){
+ existingCommand = (ParallelismPrefixCommandResource)r.get(ids);
+ }else {
+ existingCommand = new ParallelismPrefixCommandResource();
+ }
+ existingCommand.setCommandType(commandType.toString());
+ existingCommand.setCommand(parallelismPrefix.get(commandType));
+ existingCommand.setResourceJobManagerId(resource.getResourceJobManagerId());
+ existingCommand.save();
+ }
+ }
}catch (Exception e){
logger.error("Error while updating resource job manager..", e);
throw new AppCatalogException(e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/d66d1698/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/ParallelismPrefixCommand.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/ParallelismPrefixCommand.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/ParallelismPrefixCommand.java
new file mode 100644
index 0000000..17409bd
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/ParallelismPrefixCommand.java
@@ -0,0 +1,78 @@
+/*
+ *
+ * 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.registry.core.app.catalog.model;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Entity
+@Table(name = "PARALLELISM_COMMAND")
+@IdClass(ParallelismPrefixCommand_PK.class)
+public class ParallelismPrefixCommand implements Serializable {
+
+ @Id
+ @Column(name = "RESOURCE_JOB_MANAGER_ID")
+ private String resourceJobManagerId;
+
+ @ManyToOne(cascade= CascadeType.MERGE)
+ @JoinColumn(name = "RESOURCE_JOB_MANAGER_ID")
+ private ResourceJobManager resourceJobManager;
+
+ @Id
+ @Column(name = "COMMAND_TYPE")
+ private String commandType;
+
+ @Column(name = "COMMAND")
+ private String command;
+
+ public String getResourceJobManagerId() {
+ return resourceJobManagerId;
+ }
+
+ public ResourceJobManager getResourceJobManager() {
+ return resourceJobManager;
+ }
+
+ public String getCommandType() {
+ return commandType;
+ }
+
+ public String getCommand() {
+ return command;
+ }
+
+ public void setResourceJobManagerId(String resourceJobManagerId) {
+ this.resourceJobManagerId=resourceJobManagerId;
+ }
+
+ public void setResourceJobManager(ResourceJobManager resourceJobManager) {
+ this.resourceJobManager=resourceJobManager;
+ }
+
+ public void setCommandType(String commandType) {
+ this.commandType=commandType;
+ }
+
+ public void setCommand(String command) {
+ this.command=command;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d66d1698/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/ParallelismPrefixCommand_PK.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/ParallelismPrefixCommand_PK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/ParallelismPrefixCommand_PK.java
new file mode 100644
index 0000000..cea91f0
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/ParallelismPrefixCommand_PK.java
@@ -0,0 +1,62 @@
+/*
+ *
+ * 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.registry.core.app.catalog.model;
+
+import java.io.Serializable;
+
+public class ParallelismPrefixCommand_PK implements Serializable {
+ private String resourceJobManagerId;
+ private String commandType;
+ public ParallelismPrefixCommand_PK(String resourceJobManagerId, String commandType){
+ this.resourceJobManagerId = resourceJobManagerId;
+ this.commandType = commandType;
+ }
+
+ public ParallelismPrefixCommand_PK() {
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return 1;
+ }
+
+ public String getResourceJobManagerId() {
+ return resourceJobManagerId;
+ }
+
+ public String getCommandType() {
+ return commandType;
+ }
+
+ public void setResourceJobManagerId(String resourceJobManagerId) {
+ this.resourceJobManagerId=resourceJobManagerId;
+ }
+
+ public void setCommandType(String commandType) {
+ this.commandType=commandType;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d66d1698/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java
index 1766f00..2fb4a77 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java
@@ -62,6 +62,7 @@ public abstract class AppCatAbstractResource implements AppCatalogResource {
public static final String DATA_MOVEMENT_INTERFACE = "DataMovementInterface";
public static final String RESOURCE_JOB_MANAGER = "ResourceJobManager";
public static final String JOB_MANAGER_COMMAND = "JobManagerCommand";
+ public static final String PARALLELISM_PREFIX_COMMAND = "ParallelismPrefixCommand";
public static final String LOCAL_SUBMISSION = "LocalSubmission";
public static final String LOCAL_DATA_MOVEMENT = "LocalDataMovement";
public static final String SSH_JOB_SUBMISSION = "SshJobSubmission";
@@ -361,6 +362,12 @@ public abstract class AppCatAbstractResource implements AppCatalogResource {
public static final String COMMAND_TYPE = "commandType";
public static final String COMMAND = "command";
}
+
+ public final class ParallelismCommandConstants {
+ public static final String RESOURCE_JOB_MANAGER_ID = "resourceJobManagerId";
+ public static final String COMMAND_TYPE = "commandType";
+ public static final String COMMAND = "command";
+ }
// Gridftp Data Movement Table
public final class GridftpDataMovementConstants {
http://git-wip-us.apache.org/repos/asf/airavata/blob/d66d1698/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ParallelismPrefixCommandResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ParallelismPrefixCommandResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ParallelismPrefixCommandResource.java
new file mode 100644
index 0000000..3a1a038
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ParallelismPrefixCommandResource.java
@@ -0,0 +1,350 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.*;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ParallelismPrefixCommandResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(ParallelismPrefixCommandResource.class);
+ private String resourceJobManagerId;
+ private ResourceJobManagerResource resourceJobManagerResource;
+ private String commandType;
+ private String command;
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(PARALLELISM_PREFIX_COMMAND);
+ generator.setParameter(ParallelismCommandConstants.RESOURCE_JOB_MANAGER_ID, ids.get(ParallelismCommandConstants.RESOURCE_JOB_MANAGER_ID));
+ generator.setParameter(ParallelismCommandConstants.COMMAND_TYPE, ids.get(ParallelismCommandConstants.COMMAND_TYPE));
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(PARALLELISM_PREFIX_COMMAND);
+ generator.setParameter(ParallelismCommandConstants.RESOURCE_JOB_MANAGER_ID, ids.get(ParallelismCommandConstants.RESOURCE_JOB_MANAGER_ID));
+ generator.setParameter(ParallelismCommandConstants.COMMAND_TYPE, ids.get(ParallelismCommandConstants.COMMAND_TYPE));
+ Query q = generator.selectQuery(em);
+ ParallelismPrefixCommand parallelismPrefixCommand = (ParallelismPrefixCommand) q.getSingleResult();
+ ParallelismPrefixCommandResource prefixCommandResource = (ParallelismPrefixCommandResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.PARALLELISM_PREFIX_COMMAND, parallelismPrefixCommand);
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ return prefixCommandResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> parallelismCommandResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(PARALLELISM_PREFIX_COMMAND);
+ Query q;
+ if ((fieldName.equals(ParallelismCommandConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(ParallelismCommandConstants.COMMAND_TYPE)) || (fieldName.equals(ParallelismCommandConstants.COMMAND))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ ParallelismPrefixCommand prefixCommand = (ParallelismPrefixCommand) result;
+ ParallelismPrefixCommandResource parallelismPrefixCommandResource = (ParallelismPrefixCommandResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.PARALLELISM_PREFIX_COMMAND, prefixCommand);
+ parallelismCommandResources.add(parallelismPrefixCommandResource);
+ }
+ } else {
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ logger.error("Unsupported field name for Parallelism Command Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Parallelism Command Resource.");
+ }
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return parallelismCommandResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> parallelismCommandResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(PARALLELISM_PREFIX_COMMAND);
+ Query q;
+ if ((fieldName.equals(ParallelismCommandConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(ParallelismCommandConstants.COMMAND_TYPE)) || (fieldName.equals(ParallelismCommandConstants.COMMAND))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ ParallelismPrefixCommand parallelismPrefixCommand = (ParallelismPrefixCommand) result;
+ ParallelismPrefixCommandResource parallelismPrefixCommandResource = (ParallelismPrefixCommandResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.PARALLELISM_PREFIX_COMMAND, parallelismPrefixCommand);
+ parallelismCommandResourceIDs.add(parallelismPrefixCommandResource.getResourceJobManagerId());
+ }
+ } else {
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ logger.error("Unsupported field name for Parallelism Command Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Parallelism Command Resource.");
+ }
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return parallelismCommandResourceIDs;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ParallelismPrefixCommand existingParallelismCommand = em.find(ParallelismPrefixCommand.class, new ParallelismPrefixCommand_PK(resourceJobManagerId, commandType));
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+
+ ParallelismPrefixCommand prefixCommand;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingParallelismCommand == null) {
+ prefixCommand = new ParallelismPrefixCommand();
+ } else {
+ prefixCommand = existingParallelismCommand;
+ }
+ prefixCommand.setResourceJobManagerId(getResourceJobManagerId());
+ ResourceJobManager resourceJobManager = em.find(ResourceJobManager.class, getResourceJobManagerId());
+ prefixCommand.setResourceJobManager(resourceJobManager);
+ prefixCommand.setCommandType(getCommandType());
+ prefixCommand.setCommand(getCommand());
+ if (existingParallelismCommand == null) {
+ em.persist(prefixCommand);
+ } else {
+ em.merge(prefixCommand);
+ }
+ em.getTransaction().commit();
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ParallelismPrefixCommand parallelismPrefixCommand = em.find(ParallelismPrefixCommand.class, new ParallelismPrefixCommand_PK(ids.get(ParallelismCommandConstants.RESOURCE_JOB_MANAGER_ID), ids.get(ParallelismCommandConstants.COMMAND_TYPE)));
+ if (em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ return parallelismPrefixCommand != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getResourceJobManagerId() {
+ return resourceJobManagerId;
+ }
+
+ public ResourceJobManagerResource getResourceJobManagerResource() {
+ return resourceJobManagerResource;
+ }
+
+ public String getCommandType() {
+ return commandType;
+ }
+
+ public String getCommand() {
+ return command;
+ }
+
+ public void setResourceJobManagerId(String resourceJobManagerId) {
+ this.resourceJobManagerId=resourceJobManagerId;
+ }
+
+ public void setResourceJobManagerResource(ResourceJobManagerResource resourceJobManagerResource) {
+ this.resourceJobManagerResource=resourceJobManagerResource;
+ }
+
+ public void setCommandType(String commandType) {
+ this.commandType=commandType;
+ }
+
+ public void setCommand(String command) {
+ this.command=command;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d66d1698/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
index d5e7549..6a16914 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
@@ -349,6 +349,13 @@ public class AppCatalogJPAUtils {
logger.error("Object should be a Job Manager Command.", new IllegalArgumentException());
throw new IllegalArgumentException("Object should be a Job Manager Command.");
}
+ case PARALLELISM_PREFIX_COMMAND:
+ if (o instanceof ParallelismPrefixCommand) {
+ return createParallelismCommand((ParallelismPrefixCommand) o);
+ } else {
+ logger.error("Object should be a Parallelism Prefix Command.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Object should be a Parallelism Prefix Command.");
+ }
case LOCAL_SUBMISSION:
if (o instanceof LocalSubmission) {
return createLocalSubmission((LocalSubmission) o);
@@ -416,6 +423,17 @@ public class AppCatalogJPAUtils {
return jobManagerCommandResource;
}
+ private static AppCatalogResource createParallelismCommand(ParallelismPrefixCommand o) {
+ ParallelismPrefixCommandResource parallelismPrefixCommandResource = new ParallelismPrefixCommandResource();
+ if (o != null) {
+ parallelismPrefixCommandResource.setResourceJobManagerId(o.getResourceJobManagerId());
+ parallelismPrefixCommandResource.setResourceJobManagerResource((ResourceJobManagerResource) createResourceJobManager(o.getResourceJobManager()));
+ parallelismPrefixCommandResource.setCommandType(o.getCommandType());
+ parallelismPrefixCommandResource.setCommand(o.getCommand());
+ }
+ return parallelismPrefixCommandResource;
+ }
+
private static AppCatalogResource createResourceJobManager(ResourceJobManager o) {
ResourceJobManagerResource resourceJobManagerResource = new ResourceJobManagerResource();
if (o != null) {
http://git-wip-us.apache.org/repos/asf/airavata/blob/d66d1698/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java
index e30ea06..df66757 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java
@@ -59,6 +59,7 @@ public enum AppCatalogResourceType {
DATA_MOVEMENT_INTERFACE,
RESOURCE_JOB_MANAGER,
JOB_MANAGER_COMMAND,
+ PARALLELISM_PREFIX_COMMAND,
LOCAL_SUBMISSION,
LOCAL_DATA_MOVEMENT,
MODULE_LOAD_CMD,
http://git-wip-us.apache.org/repos/asf/airavata/blob/d66d1698/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java
index b788109..aa98a21 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java
@@ -38,6 +38,8 @@ import org.apache.airavata.model.application.io.DataType;
import org.apache.airavata.model.application.io.InputDataObjectType;
import org.apache.airavata.model.application.io.OutputDataObjectType;
import org.apache.airavata.model.data.movement.*;
+import org.apache.airavata.model.parallelism.ApplicationParallelismType;
+import org.apache.airavata.registry.core.app.catalog.model.ParallelismPrefixCommand;
import org.apache.airavata.registry.core.app.catalog.resources.*;
import org.apache.airavata.registry.cpi.AppCatalogException;
@@ -394,6 +396,16 @@ public class AppCatalogThriftConversion {
r.getJobManagerCommands().put(JobManagerCommand.valueOf(rr.getCommandType()), rr.getCommand());
}
}
+
+ r.setParallelismPrefix(new HashMap<ApplicationParallelismType, String>());
+ ParallelismPrefixCommandResource prefixCommandResource=new ParallelismPrefixCommandResource();
+ List<AppCatalogResource> resourceList = prefixCommandResource.get(AppCatAbstractResource.JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID, manager.getResourceJobManagerId());
+ if (resourceList != null && !resourceList.isEmpty()){
+ for (AppCatalogResource rrr : resourceList) {
+ ParallelismPrefixCommandResource rr=(ParallelismPrefixCommandResource)rrr;
+ r.getParallelismPrefix().put(ApplicationParallelismType.valueOf(rr.getCommandType()), rr.getCommand());
+ }
+ }
return r;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d66d1698/modules/registry/registry-core/src/main/resources/appcatalog-derby.sql
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/resources/appcatalog-derby.sql b/modules/registry/registry-core/src/main/resources/appcatalog-derby.sql
index 078cd73..09cb6b2 100644
--- a/modules/registry/registry-core/src/main/resources/appcatalog-derby.sql
+++ b/modules/registry/registry-core/src/main/resources/appcatalog-derby.sql
@@ -423,6 +423,15 @@ CREATE TABLE JOB_MANAGER_COMMAND
FOREIGN KEY (RESOURCE_JOB_MANAGER_ID) REFERENCES RESOURCE_JOB_MANAGER(RESOURCE_JOB_MANAGER_ID) ON DELETE CASCADE
);
+CREATE TABLE PARALLELISM_COMMAND
+(
+ RESOURCE_JOB_MANAGER_ID VARCHAR (255) NOT NULL,
+ COMMAND_TYPE VARCHAR (255) NOT NULL,
+ COMMAND VARCHAR (255),
+ PRIMARY KEY (RESOURCE_JOB_MANAGER_ID,COMMAND_TYPE),
+ FOREIGN KEY (RESOURCE_JOB_MANAGER_ID) REFERENCES RESOURCE_JOB_MANAGER(RESOURCE_JOB_MANAGER_ID) ON DELETE CASCADE
+);
+
CREATE TABLE LOCAL_SUBMISSION
(
RESOURCE_JOB_MANAGER_ID VARCHAR (255) NOT NULL,
http://git-wip-us.apache.org/repos/asf/airavata/blob/d66d1698/modules/registry/registry-core/src/main/resources/appcatalog-mysql.sql
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/resources/appcatalog-mysql.sql b/modules/registry/registry-core/src/main/resources/appcatalog-mysql.sql
index 25024f5..b091c16 100644
--- a/modules/registry/registry-core/src/main/resources/appcatalog-mysql.sql
+++ b/modules/registry/registry-core/src/main/resources/appcatalog-mysql.sql
@@ -421,6 +421,15 @@ CREATE TABLE JOB_MANAGER_COMMAND
FOREIGN KEY (RESOURCE_JOB_MANAGER_ID) REFERENCES RESOURCE_JOB_MANAGER(RESOURCE_JOB_MANAGER_ID) ON DELETE CASCADE
);
+CREATE TABLE PARALLELISM_COMMAND
+(
+ RESOURCE_JOB_MANAGER_ID VARCHAR (255) NOT NULL,
+ COMMAND_TYPE VARCHAR (255) NOT NULL,
+ COMMAND VARCHAR (255),
+ PRIMARY KEY (RESOURCE_JOB_MANAGER_ID,COMMAND_TYPE),
+ FOREIGN KEY (RESOURCE_JOB_MANAGER_ID) REFERENCES RESOURCE_JOB_MANAGER(RESOURCE_JOB_MANAGER_ID) ON DELETE CASCADE
+);
+
CREATE TABLE LOCAL_SUBMISSION
(
RESOURCE_JOB_MANAGER_ID VARCHAR (255) NOT NULL,