airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [13/16] airavata git commit: check unclosed entity managers
Date Sat, 05 Sep 2015 07:06:01 GMT
check unclosed entity managers


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/4e57f5b9
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/4e57f5b9
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/4e57f5b9

Branch: refs/heads/master
Commit: 4e57f5b9e0304aa5c4091380999e2ea2c5837f44
Parents: 840ae1a
Author: Chathuri Wimalasena <chathuri@apache.org>
Authored: Fri Sep 4 15:54:00 2015 -0400
Committer: Supun Nakandala <scnakandala@apache.org>
Committed: Sat Sep 5 12:24:24 2015 +0530

----------------------------------------------------------------------
 .../catalog/resources/ExperimentResource.java   |  2 -
 .../catalog/resources/GatewayResource.java      |  2 -
 .../catalog/resources/JobResource.java          |  2 -
 .../catalog/resources/JobStatusResource.java    |  6 +--
 .../catalog/resources/ProcessErrorResource.java |  6 +--
 .../catalog/resources/ProcessInputResource.java |  4 +-
 .../resources/ProcessOutputResource.java        |  4 +-
 .../catalog/resources/ProcessResource.java      |  2 -
 .../ProcessResourceScheduleResource.java        |  6 +--
 .../resources/ProcessStatusResource.java        |  6 +--
 .../catalog/resources/ProjectResource.java      |  2 +
 .../catalog/resources/TaskResource.java         |  2 -
 .../src/main/resources/expcatalog-derby.sql     |  2 +-
 .../src/main/resources/expcatalog-mysql.sql     |  2 +-
 .../src/test/resources/expcatalog-derby.sql     | 40 +++++++++++++++-----
 15 files changed, 51 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/4e57f5b9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
index ab1def4..f60ff0a 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
@@ -413,8 +413,6 @@ public class ExperimentResource extends AbstractExpCatResource {
                     }
                     break;
                 default:
-                    em.getTransaction().commit();
-                    em.close();
                     logger.error("Unsupported resource type for experiment resource.", new
UnsupportedOperationException());
                     throw new UnsupportedOperationException();
             }

http://git-wip-us.apache.org/repos/asf/airavata/blob/4e57f5b9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/GatewayResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/GatewayResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/GatewayResource.java
index 3c1c93e..15ead2d 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/GatewayResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/GatewayResource.java
@@ -296,8 +296,6 @@ public class GatewayResource extends AbstractExpCatResource {
                     }
                     break;
                 default:
-                    em.getTransaction().commit();
-                    em.close();
                     logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
                     throw new IllegalArgumentException("Unsupported resource type for gateway
resource.");
             }

http://git-wip-us.apache.org/repos/asf/airavata/blob/4e57f5b9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java
index a8e6d11..d4c1a99 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java
@@ -250,8 +250,6 @@ public class JobResource extends AbstractExpCatResource {
                     }
                     break;
                 default:
-                    em.getTransaction().commit();
-                    em.close();
                     logger.error("Unsupported resource type for job resource.", new UnsupportedOperationException());
                     throw new UnsupportedOperationException();
             }

http://git-wip-us.apache.org/repos/asf/airavata/blob/4e57f5b9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java
index b41a071..ded56b4 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java
@@ -118,12 +118,12 @@ public class JobStatusResource extends AbstractExpCatResource {
     public void save() throws RegistryException{
         EntityManager em = null;
         try {
-            em = ExpCatResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            JobStatus jobStatus;
             if(jobId == null || statusId == null || processId == null){
                 throw new RegistryException("Does not have the job id or status id or task
id");
             }
+            em = ExpCatResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            JobStatus jobStatus;
             JobStatusPK jobStatusPK = new JobStatusPK();
             jobStatusPK.setJobId(jobId);
             jobStatusPK.setStatusId(statusId);

http://git-wip-us.apache.org/repos/asf/airavata/blob/4e57f5b9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessErrorResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessErrorResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessErrorResource.java
index 7f84a74..05915b4 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessErrorResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessErrorResource.java
@@ -127,12 +127,12 @@ public class ProcessErrorResource extends AbstractExpCatResource {
     public void save() throws RegistryException{
         EntityManager em = null;
         try {
-            em = ExpCatResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            ProcessError processError;
             if(processId == null || errorId == null){
                 throw new RegistryException("Does not have the process id or error id");
             }
+            em = ExpCatResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            ProcessError processError;
             ProcessErrorPK processErrorPK = new ProcessErrorPK();
             processErrorPK.setProcessId(processId);
             processErrorPK.setErrorId(errorId);

http://git-wip-us.apache.org/repos/asf/airavata/blob/4e57f5b9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessInputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessInputResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessInputResource.java
index d2437a0..823ec2b 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessInputResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessInputResource.java
@@ -171,11 +171,11 @@ public class ProcessInputResource extends AbstractExpCatResource {
     public void save() throws RegistryException{
         EntityManager em = null;
         try {
-            em = ExpCatResourceUtils.getEntityManager();
-            em.getTransaction().begin();
             if(processId == null){
                 throw new RegistryException("Does not have the process id");
             }
+            em = ExpCatResourceUtils.getEntityManager();
+            em.getTransaction().begin();
             ProcessInput processInput;
             ProcessInputPK processInputPk = new ProcessInputPK();
             processInputPk.setProcessId(processId);

http://git-wip-us.apache.org/repos/asf/airavata/blob/4e57f5b9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessOutputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessOutputResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessOutputResource.java
index bee0ef7..8e930ac 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessOutputResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessOutputResource.java
@@ -153,11 +153,11 @@ public class ProcessOutputResource extends AbstractExpCatResource {
     public void save() throws RegistryException{
         EntityManager em = null;
         try {
-            em = ExpCatResourceUtils.getEntityManager();
-            em.getTransaction().begin();
             if(processId == null){
                 throw new RegistryException("Does not have the process id");
             }
+            em = ExpCatResourceUtils.getEntityManager();
+            em.getTransaction().begin();
             ProcessOutput processOutput;
             ProcessOutputPK processOutputPK = new ProcessOutputPK();
             processOutputPK.setProcessId(processId);

http://git-wip-us.apache.org/repos/asf/airavata/blob/4e57f5b9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResource.java
index 51a91ce..9adb7dc 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResource.java
@@ -447,8 +447,6 @@ public class ProcessResource extends AbstractExpCatResource {
 		            }
 		            break;
                 default:
-                    em.getTransaction().commit();
-                    em.close();
                     logger.error("Unsupported resource type for task resource.", new UnsupportedOperationException());
                     throw new UnsupportedOperationException();
             }

http://git-wip-us.apache.org/repos/asf/airavata/blob/4e57f5b9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResourceScheduleResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResourceScheduleResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResourceScheduleResource.java
index 4975ae9..c510305 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResourceScheduleResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResourceScheduleResource.java
@@ -134,12 +134,12 @@ public class ProcessResourceScheduleResource extends AbstractExpCatResource
{
     public void save() throws RegistryException{
         EntityManager em = null;
         try {
-            em = ExpCatResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            ProcessResourceSchedule processResourceSchedule;
             if(processId == null){
                 throw new RegistryException("Does not have the process id");
             }
+            em = ExpCatResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            ProcessResourceSchedule processResourceSchedule;
             processResourceSchedule = em.find(ProcessResourceSchedule.class, processId);
             if(processResourceSchedule == null){
                 processResourceSchedule = new ProcessResourceSchedule();

http://git-wip-us.apache.org/repos/asf/airavata/blob/4e57f5b9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java
index de8c81b..53eba4f 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java
@@ -109,12 +109,12 @@ public class ProcessStatusResource extends AbstractExpCatResource {
     public void save() throws RegistryException{
         EntityManager em = null;
         try {
-            em = ExpCatResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            ProcessStatus processStatus;
             if(processId == null || statusId == null){
                 throw new RegistryException("Does not have the process id or status id");
             }
+            em = ExpCatResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            ProcessStatus processStatus;
             ProcessStatusPK processStatusPK = new ProcessStatusPK();
             processStatusPK.setStatusId(statusId);
             processStatusPK.setProcessId(processId);

http://git-wip-us.apache.org/repos/asf/airavata/blob/4e57f5b9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectResource.java
index f77c2b9..eabd8b0 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectResource.java
@@ -101,6 +101,8 @@ public class ProjectResource extends AbstractExpCatResource {
                 Query q = generator.deleteQuery(em);
                 q.executeUpdate();
             } else {
+                em.getTransaction().commit();
+                em.close();
                 logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
                 throw new IllegalArgumentException("Unsupported resource type for project
resource.");
             }

http://git-wip-us.apache.org/repos/asf/airavata/blob/4e57f5b9/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java
index 962f0d0..ad3de43 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java
@@ -250,8 +250,6 @@ public class TaskResource extends AbstractExpCatResource {
                     }
                     break;
                 default:
-                    em.getTransaction().commit();
-                    em.close();
                     logger.error("Unsupported resource type for task resource.", new UnsupportedOperationException());
                     throw new UnsupportedOperationException();
             }

http://git-wip-us.apache.org/repos/asf/airavata/blob/4e57f5b9/modules/registry/registry-core/src/main/resources/expcatalog-derby.sql
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/resources/expcatalog-derby.sql b/modules/registry/registry-core/src/main/resources/expcatalog-derby.sql
index c395099..5dd1777 100644
--- a/modules/registry/registry-core/src/main/resources/expcatalog-derby.sql
+++ b/modules/registry/registry-core/src/main/resources/expcatalog-derby.sql
@@ -308,7 +308,7 @@ CREATE TABLE JOB (
   WORKING_DIR varchar(255),
   STDOUT CLOB,
   STDERR CLOB,
-  EXIT_CODE INTEGER(11),
+  EXIT_CODE INT,
   PRIMARY KEY (JOB_ID, PROCESS_ID),
   FOREIGN KEY (PROCESS_ID) REFERENCES PROCESS(PROCESS_ID) ON DELETE CASCADE
 );

http://git-wip-us.apache.org/repos/asf/airavata/blob/4e57f5b9/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql b/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql
index 12b61ec..b3d05b7 100644
--- a/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql
+++ b/modules/registry/registry-core/src/main/resources/expcatalog-mysql.sql
@@ -310,7 +310,7 @@ CREATE TABLE JOB (
   WORKING_DIR varchar(255),
   STDOUT LONGTEXT,
   STDERR LONGTEXT,
-  EXIT_CODE INTEGER(11),
+  EXIT_CODE INT(11),
   PRIMARY KEY (JOB_ID, PROCESS_ID),
   FOREIGN KEY (PROCESS_ID) REFERENCES PROCESS(PROCESS_ID) ON DELETE CASCADE
 );

http://git-wip-us.apache.org/repos/asf/airavata/blob/4e57f5b9/modules/registry/registry-core/src/test/resources/expcatalog-derby.sql
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/resources/expcatalog-derby.sql b/modules/registry/registry-core/src/test/resources/expcatalog-derby.sql
index ac8c913..31aa701 100644
--- a/modules/registry/registry-core/src/test/resources/expcatalog-derby.sql
+++ b/modules/registry/registry-core/src/test/resources/expcatalog-derby.sql
@@ -294,30 +294,33 @@ CREATE TABLE TASK_ERROR (
   TRANSIENT_OR_PERSISTENT SMALLINT,
   ROOT_CAUSE_ERROR_ID_LIST CLOB,
   PRIMARY KEY (ERROR_ID, TASK_ID),
-  FOREIGN KEY (TASK_ID) REFERENCES TASK(TASK_ID) ON DELETE CASCADE
-);
+  FOREIGN KEY (TASK_ID) REFERENCES TASK(TASK_ID) ON DELETE CASCADE);
 
 CREATE TABLE JOB (
   JOB_ID varchar(255),
   TASK_ID varchar(255),
-  JOB_DESCRIPTION varchar(255),
+  PROCESS_ID varchar(255),
+  JOB_DESCRIPTION CLOB,
   CREATION_TIME  timestamp DEFAULT '0000-00-00 00:00:00',
   COMPUTE_RESOURCE_CONSUMED varchar(255),
   JOB_NAME varchar(255),
   WORKING_DIR varchar(255),
-  PRIMARY KEY (JOB_ID, TASK_ID),
-  FOREIGN KEY (TASK_ID) REFERENCES TASK(TASK_ID) ON DELETE CASCADE
+  STDOUT CLOB,
+  STDERR CLOB,
+  EXIT_CODE INT,
+  PRIMARY KEY (JOB_ID, PROCESS_ID),
+  FOREIGN KEY (PROCESS_ID) REFERENCES PROCESS(PROCESS_ID) ON DELETE CASCADE
 );
 
 CREATE TABLE JOB_STATUS (
   STATUS_ID varchar(255),
   JOB_ID varchar(255),
-  TASK_ID varchar(255),
+  PROCESS_ID varchar(255),
   STATE varchar(255),
   TIME_OF_STATE_CHANGE  timestamp DEFAULT '0000-00-00 00:00:00',
   REASON CLOB,
-  PRIMARY KEY (STATUS_ID, JOB_ID, TASK_ID),
-  FOREIGN KEY (JOB_ID, TASK_ID) REFERENCES JOB(JOB_ID, TASK_ID) ON DELETE CASCADE
+  PRIMARY KEY (STATUS_ID, JOB_ID, PROCESS_ID),
+  FOREIGN KEY (JOB_ID, PROCESS_ID) REFERENCES JOB(JOB_ID, PROCESS_ID) ON DELETE CASCADE
 );
 
 CREATE TABLE CONFIGURATION
@@ -329,4 +332,23 @@ CREATE TABLE CONFIGURATION
         PRIMARY KEY(CONFIG_KEY, CONFIG_VAL, CATEGORY_ID)
 );
 
-INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VAL, EXPIRE_DATE, CATEGORY_ID) VALUES('registry.version',
'0.15', CURRENT_TIMESTAMP ,'SYSTEM');
\ No newline at end of file
+INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VAL, EXPIRE_DATE, CATEGORY_ID) VALUES('registry.version',
'0.16', CURRENT_TIMESTAMP ,'SYSTEM');
+
+CREATE TABLE COMMUNITY_USER
+(
+        GATEWAY_ID VARCHAR(256) NOT NULL,
+        COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,
+        TOKEN_ID VARCHAR(256) NOT NULL,
+        COMMUNITY_USER_EMAIL VARCHAR(256) NOT NULL,
+        PRIMARY KEY (GATEWAY_ID, COMMUNITY_USER_NAME, TOKEN_ID)
+);
+
+CREATE TABLE CREDENTIALS
+(
+        GATEWAY_ID VARCHAR(256) NOT NULL,
+        TOKEN_ID VARCHAR(256) NOT NULL,
+        CREDENTIAL BLOB NOT NULL,
+        PORTAL_USER_ID VARCHAR(256) NOT NULL,
+        TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+        PRIMARY KEY (GATEWAY_ID, TOKEN_ID)
+);
\ No newline at end of file


Mime
View raw message