You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ch...@apache.org on 2012/10/22 22:24:08 UTC

svn commit: r1401064 - in /airavata/trunk/modules: gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/ registry/airavata-registry-service/src/main/java/org/apache/airavata/registry/services/ registry/registry-api/src/main/java/org/apache/...

Author: chathuri
Date: Mon Oct 22 20:24:08 2012
New Revision: 1401064

URL: http://svn.apache.org/viewvc?rev=1401064&view=rev
Log:
refactoring thread classes in services

Added:
    airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AbstractRegistryUpdaterThread.java
Modified:
    airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java
    airavata/trunk/modules/registry/airavata-registry-service/src/main/java/org/apache/airavata/registry/services/RegistryService.java
    airavata/trunk/modules/ws-messenger/messagebox/src/main/java/org/apache/airavata/wsmg/msgbox/MsgBoxServiceLifeCycle.java
    airavata/trunk/modules/ws-messenger/messagebroker/src/main/java/org/apache/airavata/wsmg/broker/BrokerServiceLifeCycle.java
    airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java
    airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/nodes/XBayaWorkflowTemplatesNode.java

Modified: airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java?rev=1401064&r1=1401063&r2=1401064&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java (original)
+++ airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java Mon Oct 22 20:24:08 2012
@@ -35,10 +35,7 @@ import java.util.Properties;
 import org.apache.airavata.common.exception.AiravataConfigurationException;
 import org.apache.airavata.common.utils.ServiceUtils;
 import org.apache.airavata.core.gfac.context.GFacConfiguration;
-import org.apache.airavata.registry.api.AiravataRegistry2;
-import org.apache.airavata.registry.api.AiravataRegistryFactory;
-import org.apache.airavata.registry.api.AiravataUser;
-import org.apache.airavata.registry.api.Gateway;
+import org.apache.airavata.registry.api.*;
 import org.apache.airavata.registry.api.util.RegistryUtils;
 import org.apache.airavata.services.gfac.axis2.dispatchers.GFacURIBasedDispatcher;
 import org.apache.airavata.services.gfac.axis2.handlers.AmazonSecurityHandler;
@@ -148,7 +145,7 @@ public class GFacService implements Serv
 					/*
 					 * Heart beat message to registry
 					 */
-					thread = new GFacThread(context);
+					thread = new GFacThread(registry, context);
 					thread.start();
     	        } catch (Exception e) {
     	            log.error(e.getMessage(), e);
@@ -178,36 +175,19 @@ public class GFacService implements Serv
         }
     }
 
-    class GFacThread extends Thread {
+    class GFacThread extends AbstractRegistryUpdaterThread {
         private ConfigurationContext context = null;
 
-        GFacThread(ConfigurationContext context) {
+        GFacThread(AiravataRegistry2 registry, ConfigurationContext context) {
+            super(registry);
             this.context = context;
         }
 
-         public void run() {
-            try{
-                while (true) {
-                    try {
-                        AiravataRegistry2 registry = ((GFacConfiguration)context.getProperty(GFAC_CONFIGURATION)).getRegistry();
-                        URI localAddress = new URI((String)this.context.getProperty(GFAC_URL));
-                        registry.addGFacURI(localAddress);
-                        log.info("Updated Workflow Interpreter service URL in to Repository");
-                        Thread.sleep(GFAC_URL_UPDATE_INTERVAL);
-                    } catch (InterruptedException e) {
-                        break;
-                    }
-                }
-            }catch (Exception e){
-                try {
-                    Thread.sleep(JCR_AVAIALABILITY_WAIT_INTERVAL);
-                } catch (InterruptedException e1) {
-                    e1.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-                    return;
-                }
-                log.error(e.getMessage());
-                log.error("Workflow Interpreter Service URL update thread is interrupted");
-            }
+        @Override
+        protected void updateRegistry(AiravataRegistry2 registry) throws Exception {
+            URI localAddress = new URI((String) this.context.getProperty(GFAC_URL));
+            registry.addGFacURI(localAddress);
+            log.info("Updated Workflow Interpreter service URL in to Repository");
         }
     }
 }

Modified: airavata/trunk/modules/registry/airavata-registry-service/src/main/java/org/apache/airavata/registry/services/RegistryService.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-registry-service/src/main/java/org/apache/airavata/registry/services/RegistryService.java?rev=1401064&r1=1401063&r2=1401064&view=diff
==============================================================================
--- airavata/trunk/modules/registry/airavata-registry-service/src/main/java/org/apache/airavata/registry/services/RegistryService.java (original)
+++ airavata/trunk/modules/registry/airavata-registry-service/src/main/java/org/apache/airavata/registry/services/RegistryService.java Mon Oct 22 20:24:08 2012
@@ -61,9 +61,9 @@ public class RegistryService implements 
     private void startDerbyInServerMode() {
         try {
             System.setProperty(DERBY_SERVER_MODE_SYS_PROPERTY, "true");
-            server = new NetworkServerControl(InetAddress.getByName(Utils.getHost()),
+            server = new NetworkServerControl(InetAddress.getByName("0.0.0.0"),
                     Utils.getPort(),
-                    Utils.getJDBCUser(), Utils.getJDBCUser());
+                    Utils.getJDBCUser(), Utils.getJDBCPassword());
             java.io.PrintWriter consoleWriter = new java.io.PrintWriter(System.out, true);
             server.start(consoleWriter);
         } catch (IOException e) {

Added: airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AbstractRegistryUpdaterThread.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AbstractRegistryUpdaterThread.java?rev=1401064&view=auto
==============================================================================
--- airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AbstractRegistryUpdaterThread.java (added)
+++ airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AbstractRegistryUpdaterThread.java Mon Oct 22 20:24:08 2012
@@ -0,0 +1,63 @@
+/*
+ *
+ * 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.axis2.context.ConfigurationContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URI;
+
+public abstract class AbstractRegistryUpdaterThread extends Thread {
+
+    private AiravataRegistry2 airavataRegistry2;
+    public static final int URL_UPDATE_INTERVAL = 1000 * 60 * 60 * 3;
+    public static final int JCR_AVAIALABILITY_WAIT_INTERVAL = 1000 * 10;
+
+    private static final Logger log = LoggerFactory.getLogger(AbstractRegistryUpdaterThread.class);
+
+    public AbstractRegistryUpdaterThread(AiravataRegistry2 registry) {
+        airavataRegistry2 = registry;
+    }
+
+    public void run() {
+        while (true) {
+            try {
+                updateRegistry(airavataRegistry2);
+                Thread.sleep(URL_UPDATE_INTERVAL);
+            } catch (InterruptedException e) {
+                break;
+            } catch (Exception e) {
+                try {
+                    Thread.sleep(JCR_AVAIALABILITY_WAIT_INTERVAL);
+                } catch (InterruptedException e1) {
+                    e1.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                    return;
+                }
+                log.error(e.getMessage());
+                log.error("Workflow Interpreter Service URL update thread is interrupted");
+            }
+        }
+    }
+
+    protected abstract void updateRegistry(AiravataRegistry2 registry) throws Exception;
+}

Modified: airavata/trunk/modules/ws-messenger/messagebox/src/main/java/org/apache/airavata/wsmg/msgbox/MsgBoxServiceLifeCycle.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/ws-messenger/messagebox/src/main/java/org/apache/airavata/wsmg/msgbox/MsgBoxServiceLifeCycle.java?rev=1401064&r1=1401063&r2=1401064&view=diff
==============================================================================
--- airavata/trunk/modules/ws-messenger/messagebox/src/main/java/org/apache/airavata/wsmg/msgbox/MsgBoxServiceLifeCycle.java (original)
+++ airavata/trunk/modules/ws-messenger/messagebox/src/main/java/org/apache/airavata/wsmg/msgbox/MsgBoxServiceLifeCycle.java Mon Oct 22 20:24:08 2012
@@ -29,6 +29,7 @@ import java.util.Map;
 import java.util.Properties;
 
 import org.apache.airavata.common.utils.ServiceUtils;
+import org.apache.airavata.registry.api.AbstractRegistryUpdaterThread;
 import org.apache.airavata.registry.api.AiravataRegistry2;
 import org.apache.airavata.registry.api.util.RegistryUtils;
 import org.apache.airavata.wsmg.commons.config.ConfigurationManager;
@@ -113,7 +114,7 @@ public class MsgBoxServiceLifeCycle impl
 					/*
 					 * Heart beat message to registry
 					 */
-					thread = new MsgBoxURLRegisterThread(context);
+					thread = new MsgBoxURLRegisterThread(registry, context);
 					thread.start();
     	        } catch (Exception e) {
     	            logger.error(e.getMessage(), e);
@@ -164,37 +165,19 @@ public class MsgBoxServiceLifeCycle impl
         return interval;
     }
     
-    class MsgBoxURLRegisterThread extends Thread {
+    class MsgBoxURLRegisterThread extends AbstractRegistryUpdaterThread {
         private ConfigurationContext context = null;
 
-        MsgBoxURLRegisterThread(ConfigurationContext context) {
+        MsgBoxURLRegisterThread(AiravataRegistry2 registry, ConfigurationContext context) {
+            super(registry);
             this.context = context;
         }
 
-
-        public void run() {
-            try{
-                while (true) {
-                    try {
-                        AiravataRegistry2 registry = (AiravataRegistry2) context.getProperty(JCR_REGISTRY);
-                        URI localAddress = (URI) this.context.getProperty(SERVICE_URL);
-                        registry.setMessageBoxURI(localAddress);
-                        logger.info("Updated Workflow Interpreter service URL in to Repository");
-                        Thread.sleep(GFAC_URL_UPDATE_INTERVAL);
-                    } catch (InterruptedException e) {
-                        break;
-                    }
-                }
-            }catch (Exception e){
-                try {
-                    Thread.sleep(JCR_AVAIALABILITY_WAIT_INTERVAL);
-                } catch (InterruptedException e1) {
-                    e1.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-                    return;
-                }
-                logger.error(e.getMessage());
-                logger.error("Workflow Interpreter Service URL update thread is interrupted");
-            }
+        @Override
+        protected void updateRegistry(AiravataRegistry2 registry) throws Exception {
+            URI localAddress = (URI) this.context.getProperty(SERVICE_URL);
+            registry.setMessageBoxURI(localAddress);
+            logger.info("Updated Workflow Interpreter service URL in to Repository");
         }
     }
 

Modified: airavata/trunk/modules/ws-messenger/messagebroker/src/main/java/org/apache/airavata/wsmg/broker/BrokerServiceLifeCycle.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/ws-messenger/messagebroker/src/main/java/org/apache/airavata/wsmg/broker/BrokerServiceLifeCycle.java?rev=1401064&r1=1401063&r2=1401064&view=diff
==============================================================================
--- airavata/trunk/modules/ws-messenger/messagebroker/src/main/java/org/apache/airavata/wsmg/broker/BrokerServiceLifeCycle.java (original)
+++ airavata/trunk/modules/ws-messenger/messagebroker/src/main/java/org/apache/airavata/wsmg/broker/BrokerServiceLifeCycle.java Mon Oct 22 20:24:08 2012
@@ -30,6 +30,7 @@ import java.util.Map;
 import java.util.Properties;
 
 import org.apache.airavata.common.utils.ServiceUtils;
+import org.apache.airavata.registry.api.AbstractRegistryUpdaterThread;
 import org.apache.airavata.registry.api.AiravataRegistry2;
 import org.apache.airavata.registry.api.util.RegistryUtils;
 import org.apache.airavata.wsmg.broker.handler.PublishedMessageHandler;
@@ -159,7 +160,7 @@ public class BrokerServiceLifeCycle impl
                             /*
                                     * Heart beat message to registry
                                     */
-                            thread = new MsgBrokerURLRegisterThread(context);
+                            thread = new MsgBrokerURLRegisterThread(registry, context);
                             thread.start();
                         } catch (Exception e) {
                             log.error(e.getMessage(), e);
@@ -298,36 +299,20 @@ public class BrokerServiceLifeCycle impl
         log.info(initedmethod + " sending method inited");
     }
 
-    class MsgBrokerURLRegisterThread extends Thread {
+    class MsgBrokerURLRegisterThread extends AbstractRegistryUpdaterThread {
+
         private ConfigurationContext context = null;
 
-        MsgBrokerURLRegisterThread(ConfigurationContext context) {
+        public MsgBrokerURLRegisterThread(AiravataRegistry2 registry, ConfigurationContext context) {
+            super(registry);
             this.context = context;
         }
 
-        public void run() {
-            try {
-                while (true) {
-                    try {
-                        AiravataRegistry2 registry = (AiravataRegistry2) context.getProperty(JCR_REGISTRY);
-                        URI localAddress = (URI) this.context.getProperty(SERVICE_URL);
-                        registry.setEventingURI(localAddress);
-                        log.info("Updated Workflow Interpreter service URL in to Repository");
-                        Thread.sleep(GFAC_URL_UPDATE_INTERVAL);
-                    } catch (InterruptedException e) {
-                        break;
-                    }
-                }
-            } catch (Exception e) {
-                try {
-                    Thread.sleep(JCR_AVAIALABILITY_WAIT_INTERVAL);
-                } catch (InterruptedException e1) {
-                    e1.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-                    return;
-                }
-                log.error(e.getMessage());
-                log.error("Workflow Interpreter Service URL update thread is interrupted");
-            }
+
+        protected void updateRegistry(AiravataRegistry2 registry) {
+            URI localAddress = (URI) this.context.getProperty(SERVICE_URL);
+            registry.setEventingURI(localAddress);
+            log.info("Updated Workflow Interpreter service URL in to Repository");
         }
 
     }

Modified: airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java?rev=1401064&r1=1401063&r2=1401064&view=diff
==============================================================================
--- airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java (original)
+++ airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java Mon Oct 22 20:24:08 2012
@@ -40,6 +40,7 @@ import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
+import org.apache.airavata.registry.api.AbstractRegistryUpdaterThread;
 import org.apache.airavata.registry.api.exception.RegistryException;
 import org.apache.airavata.common.utils.ServiceUtils;
 import org.apache.airavata.common.workflow.execution.context.WorkflowContextHeaderBuilder;
@@ -200,7 +201,7 @@ public class WorkflowInterpretorSkeleton
  					/*
 					 * Heart beat message to registry
 					 */
-					thread = new WIServiceThread(configctx);
+					thread = new WIServiceThread(getRegistry(), configctx);
 					thread.start();
 		        } catch (IOException e) {
 		            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
@@ -430,35 +431,20 @@ public class WorkflowInterpretorSkeleton
     }
     public static final int URL_UPDATE_INTERVAL = 1000 * 60 * 60 * 3;
 
-    class WIServiceThread extends Thread {
+    class WIServiceThread extends AbstractRegistryUpdaterThread {
         private ConfigurationContext context = null;
 
-        WIServiceThread(ConfigurationContext context) {
+        WIServiceThread(AiravataRegistry2 registry, ConfigurationContext context) {
+            super(registry);
             this.context = context;
         }
 
-        public void run() {
-            try{
-                while (true) {
-                    try {
-                        AiravataRegistry2 registry = (AiravataRegistry2) context.getProperty(JCR_REG);
-                        URI localAddress = (URI) this.context.getProperty(SERVICE_URL);
-                        registry.addWorkflowInterpreterURI(localAddress);
-                        log.info("Updated Workflow Interpreter service URL in to Repository");
-                        Thread.sleep(URL_UPDATE_INTERVAL);
-                    } catch (InterruptedException e) {
-                        break;
-                    }
-                }
-            }catch (Exception e){
-                try {
-                    Thread.sleep(JCR_AVAIALABILITY_WAIT_INTERVAL);
-                } catch (InterruptedException e1) {
-                    e1.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-                    return;
-                }
-                log.error("Workflow Interpreter Service URL update thread is interrupted");
-            }
+        @Override
+        protected void updateRegistry(AiravataRegistry2 registry) throws Exception {
+            URI localAddress = (URI) this.context.getProperty(SERVICE_URL);
+            registry.addWorkflowInterpreterURI(localAddress);
+            log.info("Updated Workflow Interpreter service URL in to Repository");
+
         }
     }
 }

Modified: airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/nodes/XBayaWorkflowTemplatesNode.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/nodes/XBayaWorkflowTemplatesNode.java?rev=1401064&r1=1401063&r2=1401064&view=diff
==============================================================================
--- airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/nodes/XBayaWorkflowTemplatesNode.java (original)
+++ airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/nodes/XBayaWorkflowTemplatesNode.java Mon Oct 22 20:24:08 2012
@@ -67,7 +67,7 @@ public class XBayaWorkflowTemplatesNode 
 
     @Override
     public List<String> getSupportedActions() {
-        return Arrays.asList(AddAction.ID, RefreshAction.ID);
+        return Arrays.asList(RefreshAction.ID);
     }
 
     public boolean triggerAction(JTree tree, String action) throws Exception {