Author: lahiru
Date: Tue Jan  7 06:31:30 2014
New Revision: 1556123

URL: http://svn.apache.org/r1556123
Log:
more changes to orchestrator component.

Added:
    
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/OrchestratorConfiguration.java
    
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/PullBasedOrchestrator.java
    
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java
    airavata/sandbox/orchestrator/orchestrator-core/src/main/test/
    airavata/sandbox/orchestrator/orchestrator-core/src/main/test/java/
    airavata/sandbox/orchestrator/orchestrator-core/src/main/test/java/org/
    
airavata/sandbox/orchestrator/orchestrator-core/src/main/test/java/org/apache/
    
airavata/sandbox/orchestrator/orchestrator-core/src/main/test/java/org/apache/airavata/
    
airavata/sandbox/orchestrator/orchestrator-core/src/main/test/java/org/apache/airavata/orchestrator/
    
airavata/sandbox/orchestrator/orchestrator-core/src/main/test/java/org/apache/airavata/orchestrator/core/
    airavata/sandbox/orchestrator/orchestrator-core/src/main/test/resources/
Modified:
    airavata/sandbox/orchestrator/orchestrator-core/pom.xml
    
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/JobSubmitterWorker.java
    
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/Orchestrator.java
    
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/context/OrchestratorContext.java
    
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFACInstance.java
    
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/SimpleJobSubmitter.java
    
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorConstants.java
    
airavata/sandbox/orchestrator/orchestrator-core/src/main/resources/orchestrator.properties

Modified: airavata/sandbox/orchestrator/orchestrator-core/pom.xml
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/orchestrator/orchestrator-core/pom.xml?rev=1556123&r1=1556122&r2=1556123&view=diff
==============================================================================
--- airavata/sandbox/orchestrator/orchestrator-core/pom.xml (original)
+++ airavata/sandbox/orchestrator/orchestrator-core/pom.xml Tue Jan  7 06:31:30 
2014
@@ -14,7 +14,7 @@ the License. -->
     <parent>
        <groupId>org.apache.airavata</groupId>
        <artifactId>airavata</artifactId>
-        <version>0.11-SNAPSHOT</version>
+        <version>0.12-SNAPSHOT</version>
        <relativePath>../../../trunk/pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

Modified: 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/JobSubmitterWorker.java
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/JobSubmitterWorker.java?rev=1556123&r1=1556122&r2=1556123&view=diff
==============================================================================
--- 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/JobSubmitterWorker.java
 (original)
+++ 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/JobSubmitterWorker.java
 Tue Jan  7 06:31:30 2014
@@ -22,6 +22,7 @@ package org.apache.airavata.orchestrator
 
 import org.apache.airavata.orchestrator.core.context.OrchestratorContext;
 import org.apache.airavata.orchestrator.core.exception.OrchestratorException;
+import org.apache.airavata.orchestrator.core.gfac.GFACInstance;
 import org.apache.airavata.orchestrator.core.job.JobSubmitter;
 import org.apache.airavata.orchestrator.core.utils.OrchestratorConstants;
 import org.slf4j.Logger;
@@ -31,32 +32,24 @@ import java.io.IOException;
 import java.net.URL;
 import java.util.Properties;
 
-public class JobSubmitterWorker implements Runnable{
+public class JobSubmitterWorker implements Runnable {
     private final static Logger logger = 
LoggerFactory.getLogger(JobSubmitterWorker.class);
 
-    OrchestratorContext orchestratorContext;
+    private OrchestratorContext orchestratorContext;
 
-    JobSubmitter jobSubmitter;
+    private JobSubmitter jobSubmitter;
 
-    public JobSubmitterWorker(OrchestratorContext orchestratorContext) throws 
OrchestratorException{
+    // Set the default submit interval value
+    private int submitInterval = 1000;
 
-        this.orchestratorContext = orchestratorContext;
-
-        URL resource =
-                
JobSubmitterWorker.class.getClassLoader().getResource(OrchestratorConstants.ORCHESTRATOR_PROPERTIES);
 
-        if(resource == null){
-            throw new OrchestratorException("orchestrator.properties cannot 
found");
-        }
-        Properties orchestratorProps = new Properties();
+    public JobSubmitterWorker(OrchestratorContext orchestratorContext) throws 
OrchestratorException {
+        this.orchestratorContext = orchestratorContext;
         try {
-            orchestratorProps.load(resource.openStream());
-            String submitterClass = 
(String)orchestratorProps.get("job.submitter");
+            String submitterClass = 
this.orchestratorContext.getOrchestratorConfiguration().getSubmitterClass();
+            submitInterval = 
this.orchestratorContext.getOrchestratorConfiguration().getSubmitterInterval();
             Class<? extends JobSubmitter> aClass = 
Class.forName(submitterClass.trim()).asSubclass(JobSubmitter.class);
             jobSubmitter = aClass.newInstance();
-        } catch (IOException e) {
-            logger.error("Error reading orchestrator.properties");
-            throw new OrchestratorException(e);
         } catch (ClassNotFoundException e) {
             logger.error("Error while loading Job Submitter");
         } catch (InstantiationException e) {
@@ -70,7 +63,20 @@ public class JobSubmitterWorker implemen
     }
 
     public void run() {
-         /* implement logic to submit job batches time to time */
+        /* implement logic to submit job batches time to time */
+        while (true) {
+            try {
+                Thread.sleep(submitInterval);
+            } catch (InterruptedException e) {
+                logger.error("Error in JobSubmitter during sleeping process 
before submit jobs");
+                e.printStackTrace();
+            }
+            /* Here the worker pick bunch of jobs available to submit and 
submit that to a single
+              GFAC instance, we do not handle job by job submission to each 
gfac instance
+            */
+            GFACInstance gfacInstance = 
jobSubmitter.selectGFACInstance(orchestratorContext);
+            jobSubmitter.submitJob(gfacInstance);
+        }
     }
 
     public OrchestratorContext getOrchestratorContext() {

Modified: 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/Orchestrator.java
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/Orchestrator.java?rev=1556123&r1=1556122&r2=1556123&view=diff
==============================================================================
--- 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/Orchestrator.java
 (original)
+++ 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/Orchestrator.java
 Tue Jan  7 06:31:30 2014
@@ -20,25 +20,39 @@
 */
 package org.apache.airavata.orchestrator.core;
 
+import org.apache.airavata.orchestrator.core.exception.OrchestratorException;
+
 /*
-    This is the interface for orchestrator functionality exposed to the out 
side of the
-    module
- */
+   This is the interface for orchestrator functionality exposed to the out 
side of the
+   module
+*/
 public interface Orchestrator {
+
+    /** This method will initialize the Orchestrator, during restart this will
+     * get called and do init tasks
+     * @return
+     */
+    boolean initialize() throws OrchestratorException;
     /**
      *
      * @return
      */
-    String createExperiment(ExperimentRequest request);
+    String createExperiment(ExperimentRequest request)throws 
OrchestratorException;
 
     /**
      *
      * @return
      */
-    boolean acceptExperiment(JobRequest request);
+    boolean acceptExperiment(JobRequest request)throws OrchestratorException;
 
     /**
      *
      */
-    void startJobSubmitter();
+    void startJobSubmitter()throws OrchestratorException;
+
+    /*
+    This method will get called during graceful shutdown of Orchestrator
+    This can be used to handle the shutdown of orchestrator gracefully.
+     */
+    boolean shutdown()throws OrchestratorException;
 }

Added: 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/OrchestratorConfiguration.java
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/OrchestratorConfiguration.java?rev=1556123&view=auto
==============================================================================
--- 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/OrchestratorConfiguration.java
 (added)
+++ 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/OrchestratorConfiguration.java
 Tue Jan  7 06:31:30 2014
@@ -0,0 +1,65 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.orchestrator.core;
+
+public class OrchestratorConfiguration {
+
+    private String submitterClass;
+
+    private int submitterInterval = 1000;
+
+    private int threadPoolSize = 10;
+
+    private boolean startSubmitter = false;
+    /* setter methods */
+    public String getSubmitterClass() {
+        return submitterClass;
+    }
+
+    public int getSubmitterInterval() {
+        return submitterInterval;
+    }
+
+    public int getThreadPoolSize() {
+        return threadPoolSize;
+    }
+
+    /* setter methods */
+    public void setSubmitterClass(String submitterClass) {
+        this.submitterClass = submitterClass;
+    }
+
+    public void setSubmitterInterval(int submitterInterval) {
+        this.submitterInterval = submitterInterval;
+    }
+
+    public void setThreadPoolSize(int threadPoolSize) {
+        this.threadPoolSize = threadPoolSize;
+    }
+
+    public boolean isStartSubmitter() {
+        return startSubmitter;
+    }
+
+    public void setStartSubmitter(boolean startSubmitter) {
+        this.startSubmitter = startSubmitter;
+    }
+}

Added: 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/PullBasedOrchestrator.java
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/PullBasedOrchestrator.java?rev=1556123&view=auto
==============================================================================
--- 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/PullBasedOrchestrator.java
 (added)
+++ 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/PullBasedOrchestrator.java
 Tue Jan  7 06:31:30 2014
@@ -0,0 +1,116 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.orchestrator.core;
+
+import org.apache.airavata.common.exception.AiravataConfigurationException;
+import org.apache.airavata.orchestrator.core.context.OrchestratorContext;
+import org.apache.airavata.orchestrator.core.exception.OrchestratorException;
+import org.apache.airavata.orchestrator.core.gfac.GFACInstance;
+import org.apache.airavata.orchestrator.core.utils.OrchestratorConstants;
+import org.apache.airavata.orchestrator.core.utils.OrchestratorUtils;
+import org.apache.airavata.registry.api.*;
+import org.apache.airavata.registry.api.exception.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.*;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+public class PullBasedOrchestrator implements Orchestrator {
+    private final static Logger logger = 
LoggerFactory.getLogger(PullBasedOrchestrator.class);
+
+    OrchestratorContext orchestratorContext;
+
+    OrchestratorRegistry airavataRegistry;
+
+    Executor executor;
+
+    public boolean initialize() throws OrchestratorException {
+        try {
+            /* Initializing the OrchestratorConfiguration object */
+            OrchestratorConfiguration orchestratorConfiguration = 
OrchestratorUtils.loadOrchestratorConfiguration();
+
+            /* initializing the Orchestratorcontext object */
+            airavataRegistry = AiravataRegistryFactory.getRegistry(new 
Gateway("default"), new AiravataUser("admin"));
+            Map<String, Integer> gfacNodeList = 
airavataRegistry.getGFACNodeList();
+            if (gfacNodeList.size() == 0) {
+                String error = "No GFAC instances available in the system, 
Can't initialize Orchestrator";
+                logger.error(error);
+                throw new OrchestratorException(error);
+            }
+            Set<String> uriList = gfacNodeList.keySet();
+            Iterator<String> iterator = uriList.iterator();
+            List<GFACInstance> gfacInstanceList = new 
ArrayList<GFACInstance>();
+            while (iterator.hasNext()) {
+                String uri = iterator.next();
+                Integer integer = gfacNodeList.get(uri);
+                gfacInstanceList.add(new GFACInstance(uri, integer));
+            }
+
+            orchestratorContext = new OrchestratorContext(gfacInstanceList);
+            
orchestratorContext.setOrchestratorConfiguration(orchestratorConfiguration);
+
+            /* Starting submitter thread pool */
+
+            executor = 
Executors.newFixedThreadPool(orchestratorConfiguration.getThreadPoolSize());
+
+
+
+        } catch (RegistryException e) {
+            logger.error("Failed to initializing Orchestrator");
+            OrchestratorException orchestratorException = new 
OrchestratorException(e);
+            throw orchestratorException;
+        } catch (AiravataConfigurationException e) {
+            logger.error("Failed to initializing Orchestrator");
+            OrchestratorException orchestratorException = new 
OrchestratorException(e);
+            throw orchestratorException;
+        } catch (IOException e) {
+            logger.error("Failed to initializing Orchestrator - Error parsing 
orchestrator.properties");
+            OrchestratorException orchestratorException = new 
OrchestratorException(e);
+            throw orchestratorException;
+        }
+        return true;
+    }
+
+
+    public boolean shutdown() throws OrchestratorException {
+        return false;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+
+    public String createExperiment(ExperimentRequest request) throws 
OrchestratorException {
+        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+
+    public boolean acceptExperiment(JobRequest request) throws 
OrchestratorException {
+        return false;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+
+    public void startJobSubmitter() throws OrchestratorException {
+        for (int i = 0; i < 
orchestratorContext.getOrchestratorConfiguration().getThreadPoolSize(); i++) {
+                JobSubmitterWorker jobSubmitterWorker = new 
JobSubmitterWorker(orchestratorContext);
+                executor.execute(jobSubmitterWorker);
+        }
+    }
+}

Modified: 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/context/OrchestratorContext.java
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/context/OrchestratorContext.java?rev=1556123&r1=1556122&r2=1556123&view=diff
==============================================================================
--- 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/context/OrchestratorContext.java
 (original)
+++ 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/context/OrchestratorContext.java
 Tue Jan  7 06:31:30 2014
@@ -20,6 +20,7 @@
 */
 package org.apache.airavata.orchestrator.core.context;
 
+import org.apache.airavata.orchestrator.core.OrchestratorConfiguration;
 import org.apache.airavata.orchestrator.core.gfac.GFACInstance;
 
 import java.util.ArrayList;
@@ -28,6 +29,8 @@ import java.util.List;
 public class OrchestratorContext {
     private List<GFACInstance> gfacInstanceList;
 
+    private OrchestratorConfiguration orchestratorConfiguration;
+
     public OrchestratorContext(List<GFACInstance> gfacInstanceList) {
         this.gfacInstanceList = new ArrayList<GFACInstance>();
     }
@@ -39,4 +42,12 @@ public class OrchestratorContext {
     public void addGfacInstanceList(GFACInstance instance) {
         this.gfacInstanceList.add(instance);
     }
+
+    public OrchestratorConfiguration getOrchestratorConfiguration() {
+        return orchestratorConfiguration;
+    }
+
+    public void setOrchestratorConfiguration(OrchestratorConfiguration 
orchestratorConfiguration) {
+        this.orchestratorConfiguration = orchestratorConfiguration;
+    }
 }

Modified: 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFACInstance.java
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFACInstance.java?rev=1556123&r1=1556122&r2=1556123&view=diff
==============================================================================
--- 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFACInstance.java
 (original)
+++ 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/gfac/GFACInstance.java
 Tue Jan  7 06:31:30 2014
@@ -30,6 +30,11 @@ public class GFACInstance {
 
     private int currentLoad;
 
+    public GFACInstance(String gfacURL, int currentLoad) {
+        this.gfacURL = gfacURL;
+        this.currentLoad = currentLoad;
+    }
+
     public String getGfacURL() {
         return gfacURL;
     }

Modified: 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/SimpleJobSubmitter.java
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/SimpleJobSubmitter.java?rev=1556123&r1=1556122&r2=1556123&view=diff
==============================================================================
--- 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/SimpleJobSubmitter.java
 (original)
+++ 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/SimpleJobSubmitter.java
 Tue Jan  7 06:31:30 2014
@@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory;
 
 public class SimpleJobSubmitter implements JobSubmitter{
     private final static Logger logger = 
LoggerFactory.getLogger(SimpleJobSubmitter.class);
+
     public GFACInstance selectGFACInstance(OrchestratorContext context) {
         return null;
     }

Modified: 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorConstants.java
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorConstants.java?rev=1556123&r1=1556122&r2=1556123&view=diff
==============================================================================
--- 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorConstants.java
 (original)
+++ 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorConstants.java
 Tue Jan  7 06:31:30 2014
@@ -23,4 +23,9 @@ package org.apache.airavata.orchestrator
 public class OrchestratorConstants {
     private static final String SUBMITTER_PROPERTY = "job.submitter";
     public static final String ORCHESTRATOR_PROPERTIES = 
"orchestrator.properties";
+    public static final int hotUpdateInterval=1000;
+    public static final String JOB_SUBMITTER = "job.submitter";
+    public static final String SUBMIT_INTERVAL = "submitter.interval";
+    public static final String THREAD_POOL_SIZE = "threadpool.size";
+    public static final String START_SUBMITTER = "start.submitter";
 }

Added: 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java?rev=1556123&view=auto
==============================================================================
--- 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java
 (added)
+++ 
airavata/sandbox/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java
 Tue Jan  7 06:31:30 2014
@@ -0,0 +1,54 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.orchestrator.core.utils;
+
+import org.apache.airavata.orchestrator.core.JobSubmitterWorker;
+import org.apache.airavata.orchestrator.core.OrchestratorConfiguration;
+import org.apache.airavata.orchestrator.core.exception.OrchestratorException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Properties;
+
+public class OrchestratorUtils {
+    private final static Logger logger = 
LoggerFactory.getLogger(OrchestratorUtils.class);
+
+    public static OrchestratorConfiguration loadOrchestratorConfiguration() 
throws OrchestratorException, IOException {
+        URL resource =
+                
JobSubmitterWorker.class.getClassLoader().getResource(OrchestratorConstants.ORCHESTRATOR_PROPERTIES);
+        if (resource == null) {
+            String error = "orchestrator.properties cannot be found, Failed to 
initialize Orchestrator";
+            logger.error(error);
+            throw new OrchestratorException(error);
+        }
+        OrchestratorConfiguration orchestratorConfiguration = new 
OrchestratorConfiguration();
+        Properties orchestratorProps = new Properties();
+        orchestratorProps.load(resource.openStream());
+        orchestratorConfiguration.setSubmitterClass((String) 
orchestratorProps.get(OrchestratorConstants.JOB_SUBMITTER));
+        orchestratorConfiguration.setSubmitterInterval((Integer) 
orchestratorProps.get(OrchestratorConstants.SUBMIT_INTERVAL));
+        orchestratorConfiguration.setThreadPoolSize((Integer) 
orchestratorProps.get(OrchestratorConstants.THREAD_POOL_SIZE));
+        
orchestratorConfiguration.setStartSubmitter(Boolean.valueOf(orchestratorProps.getProperty(OrchestratorConstants.START_SUBMITTER)));
+        return orchestratorConfiguration;
+    }
+
+}

Modified: 
airavata/sandbox/orchestrator/orchestrator-core/src/main/resources/orchestrator.properties
URL: 
http://svn.apache.org/viewvc/airavata/sandbox/orchestrator/orchestrator-core/src/main/resources/orchestrator.properties?rev=1556123&r1=1556122&r2=1556123&view=diff
==============================================================================
--- 
airavata/sandbox/orchestrator/orchestrator-core/src/main/resources/orchestrator.properties
 (original)
+++ 
airavata/sandbox/orchestrator/orchestrator-core/src/main/resources/orchestrator.properties
 Tue Jan  7 06:31:30 2014
@@ -1 +1,4 @@
-job.submitter=org.apache.airavata.orchestrator.core.impl.SimpleJobSubmitter
\ No newline at end of file
+job.submitter=org.apache.airavata.orchestrator.core.impl.SimpleJobSubmitter
+submitter.interval=10000
+threadpool.size=10
+start.submitter=true
\ No newline at end of file


Reply via email to