Author: lahiru
Date: Thu Jan  9 16:29:29 2014
New Revision: 1556860

URL: http://svn.apache.org/r1556860
Log:
fixing https://issues.apache.org/jira/browse/AIRAVATA-982.

Added:
    
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/OrchestratorRegistry.java
Modified:
    
airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
    
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry2.java

Modified: 
airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
URL: 
http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java?rev=1556860&r1=1556859&r2=1556860&view=diff
==============================================================================
--- 
airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
 (original)
+++ 
airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
 Thu Jan  9 16:29:29 2014
@@ -33,7 +33,7 @@ import java.util.Map;
 import java.util.regex.Pattern;
 
 import org.apache.airavata.common.exception.AiravataConfigurationException;
-import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataJobState;
 import org.apache.airavata.common.utils.DBUtil;
 import org.apache.airavata.common.utils.Version;
 import org.apache.airavata.commons.gfac.type.ApplicationDescription;
@@ -2510,37 +2510,32 @@ public class AiravataJPARegistry extends
        @Override
        public boolean isCredentialExist(String gatewayId, String tokenId)
                        throws RegistryException {
+               credentialReader = new CredentialReaderImpl(getDBConnector());
                try {
-            credentialReader = new CredentialReaderImpl(getDBConnector());
-            SSHCredential credential = (SSHCredential) 
credentialReader.getCredential(gatewayId, tokenId);
+                       SSHCredential credential = (SSHCredential) 
credentialReader.getCredential(gatewayId, tokenId);
                if (credential!=null) {
                        return true;
                }
                } catch(CredentialStoreException e) {
                        return false;
-               } catch (ApplicationSettingsException e) {
-            throw new RegistryException("An error occurred while creating 
credential reader.");
-        }
-        return false;
+               }
+               return false;
        }
 
        @Override
        public String getCredentialPublicKey(String gatewayId, String tokenId)
                        throws RegistryException {
                
+               credentialReader = new CredentialReaderImpl(getDBConnector());
                try {
-            credentialReader = new CredentialReaderImpl(getDBConnector());
-
-            SSHCredential credential = (SSHCredential) 
credentialReader.getCredential(gatewayId, tokenId);
+                       SSHCredential credential = (SSHCredential) 
credentialReader.getCredential(gatewayId, tokenId);
                if (credential!=null) {
                        return new String(credential.getPublicKey());
                }
                } catch(CredentialStoreException e) {
                        return null;
-               } catch (ApplicationSettingsException e) {
-            throw new RegistryException("An error occurred while creating 
credential reader");
-        }
-        return null;
+               }
+               return null;
        }
 
        @Override
@@ -2552,10 +2547,9 @@ public class AiravataJPARegistry extends
        @Override
        public String createCredential(String gatewayId, String tokenId,
                        String username) throws RegistryException {
-
+       credentialWriter = new SSHCredentialWriter(getDBConnector());
+       credentialGenerator = new SSHCredentialGenerator();
        try {
-            credentialWriter = new SSHCredentialWriter(getDBConnector());
-            credentialGenerator = new SSHCredentialGenerator();
                SSHCredential credential = 
credentialGenerator.generateCredential(tokenId);
                if (credential!=null) {
                        credential.setGateway(gatewayId);
@@ -2566,10 +2560,8 @@ public class AiravataJPARegistry extends
                }
        } catch (CredentialStoreException e) {
                return null;
-       } catch (ApplicationSettingsException e) {
-            throw new RegistryException("An error occurred while creating ssh 
credential writer");
-        }
-        return null;
+       }
+               return null;
        }
 
        private static DBUtil getDBConnector() throws RegistryException{
@@ -2594,4 +2586,53 @@ public class AiravataJPARegistry extends
                throw new RegistryException("Error while accesing registrty 
settings ", e);
                }
     }
+
+    public Map<String, Integer> getGFACNodeList() throws RegistryException {
+        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+
+    /**
+     *These are the methods inherited from Orchestrator Registry
+     */
+
+
+    public List<URI> getLiveGFacURIs() throws RegistryException {
+        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+
+    public boolean storeExperiment(String userName, String experimentID) 
throws RegistryException {
+        return false;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+
+    public boolean changeStatus(String experimentID, AiravataJobState.State 
state) throws RegistryException {
+        return false;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+
+    public AiravataJobState getState(String experimentID) throws 
RegistryException {
+        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+
+    public List<String> getAllJobsWithState(AiravataJobState state) throws 
RuntimeException {
+        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+
+    public List<String> getAllAcceptedJobs() throws RegistryException {
+        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+
+    public String fetchAcceptedJob(String experimentID) throws 
RegistryException {
+        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+
+    public List<String> getAllHangedJobs() throws RegistryException {
+        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+
+    public int getHangedJobCount() throws RegistryException {
+        return 0;  //To change body of implemented methods use File | Settings 
| File Templates.
+    }
+
+    public boolean resetHangedJob(String experimentID) throws 
RegistryException {
+        return false;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
 }

Modified: 
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry2.java
URL: 
http://svn.apache.org/viewvc/airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry2.java?rev=1556860&r1=1556859&r2=1556860&view=diff
==============================================================================
--- 
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry2.java
 (original)
+++ 
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry2.java
 Thu Jan  9 16:29:29 2014
@@ -27,7 +27,7 @@ import java.net.URI;
 import java.util.Observable;
 
 
-public abstract class AiravataRegistry2 extends Observable implements 
DescriptorRegistry, ProjectsRegistry, PublishedWorkflowRegistry, 
UserWorkflowRegistry, ConfigurationRegistry, ProvenanceRegistry, UserRegistry, 
CredentialRegistry{
+public abstract class AiravataRegistry2 extends Observable implements 
DescriptorRegistry, ProjectsRegistry, PublishedWorkflowRegistry, 
UserWorkflowRegistry, ConfigurationRegistry, 
ProvenanceRegistry,OrchestratorRegistry, UserRegistry, CredentialRegistry{
        private Gateway gateway;
        private AiravataUser user;
        

Added: 
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/OrchestratorRegistry.java
URL: 
http://svn.apache.org/viewvc/airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/OrchestratorRegistry.java?rev=1556860&view=auto
==============================================================================
--- 
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/OrchestratorRegistry.java
 (added)
+++ 
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/OrchestratorRegistry.java
 Thu Jan  9 16:29:29 2014
@@ -0,0 +1,117 @@
+/*
+ *
+ * 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.api;
+
+import org.apache.airavata.common.utils.AiravataJobState;
+import org.apache.airavata.registry.api.exception.RegistryException;
+
+import java.util.List;
+import java.util.Map;
+
+public interface OrchestratorRegistry extends AiravataSubRegistry {
+
+
+    /**
+     * this return information about GFAC instances running in the system.
+     * @return
+     * @throws RegistryException
+     */
+    Map<String, Integer> getGFACNodeList() throws RegistryException;
+
+
+    /**
+     * This method will add an entry to job management table in database
+     * With the default initial status of ACCEPTED
+     * @param userName
+     * @param experimentID
+     * @return
+     * @throws RegistryException
+     */
+    boolean storeExperiment(String userName,String experimentID)throws 
RegistryException;
+
+    /**
+     * This can be used to change the status to any valid status
+     * @param experimentID
+     * @param state
+     * @return
+     * @throws RegistryException
+     */
+    boolean changeStatus(String experimentID,AiravataJobState.State 
state)throws RegistryException;
+
+
+    /**
+     * This method can be used to seek the status of a given experiment
+     * @param experimentID
+     * @return
+     * @throws RegistryException
+     */
+    AiravataJobState getState(String experimentID)throws RegistryException;
+
+    /**
+     * This returns all the jobs with the given state
+     * @param state give any state user wants to retrieve all the experiment 
IDs
+     * @return
+     * @throws RuntimeException
+     */
+    List<String> getAllJobsWithState(AiravataJobState state) throws 
RuntimeException;
+
+    /**
+     * This will return list of experimentID of jobs which are in
+     * ACCEPTED state
+     * @return
+     * @throws RegistryException
+     */
+    List<String> getAllAcceptedJobs()throws RegistryException;
+
+    /**
+     * This will pick one job from jobs in ACCEPTED state and change its 
status to
+     * FETCHED
+     * @return experimentID
+     * @throws RegistryException
+     */
+    String fetchAcceptedJob(String experimentID)throws RegistryException;
+
+    /**
+     * This will return all the hanged jobs, the logic to determine
+     * whether job is hanged or not is depend on the implementation
+     * @return
+     * @throws RegistryException
+     */
+    List<String> getAllHangedJobs()throws RegistryException;
+
+    /**
+     * return the number of jobs hanged, it not normal that jobs are hanged
+     * all the time, so users can use this method before try to retrieve
+     * list of hanged jobs
+     * @return  number of hanged jobs
+     * @throws RegistryException
+     */
+    int getHangedJobCount()throws RegistryException;
+
+    /**
+     * reset hanged jobs based on previous state
+     * @param experimentID
+     * @return true if operation is successful
+     * @throws RegistryException
+     */
+    boolean resetHangedJob(String experimentID)throws RegistryException;
+
+}


Reply via email to