You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sa...@apache.org on 2012/03/23 18:20:11 UTC

svn commit: r1304499 - in /incubator/airavata/trunk/modules: gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java

Author: samindaw
Date: Fri Mar 23 17:20:10 2012
New Revision: 1304499

URL: http://svn.apache.org/viewvc?rev=1304499&view=rev
Log:
adding thread initialisation for xbayaservice + adding delayed retry for gfac url registering service if url registration fails with a registry exception (can happen when the content repository is not yet available)

Modified:
    incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java

Modified: incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java?rev=1304499&r1=1304498&r2=1304499&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java (original)
+++ incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java Fri Mar 23 17:20:10 2012
@@ -65,6 +65,7 @@ public class GFacService implements Serv
 
     public static final int GFAC_URL_UPDATE_INTERVAL = 1000 * 60 * 60 * 3;
 
+    public static final int JCR_AVAIALABILITY_WAIT_INTERVAL = 1000 * 10;
     /*
      * Properties for JCR
      */
@@ -110,44 +111,58 @@ public class GFacService implements Serv
     	new Thread(){
     		@Override
     		public void run() {
-    			try {
-					Thread.sleep(10000);
-				} catch (InterruptedException e1) {
-					e1.printStackTrace();
-				}
     	        Properties properties = new Properties();
     	        String port = null;
     	        try {
     	            URL url = this.getClass().getClassLoader().getResource(REPOSITORY_PROPERTIES);
     	            properties.load(url.openStream());
     	            Map<String, String> map = new HashMap<String, String>((Map) properties);
-    	            AiravataRegistry registry = new AiravataJCRRegistry(new URI(map.get(ORG_APACHE_JACKRABBIT_REPOSITORY_URI)),map.get(JCR_CLASS),map.get(JCR_USER),map.get(JCR_PASS), map);
-    	            String localAddress = Utils.getIpAddress(context.getAxisConfiguration());
-    	            TransportInDescription transportInDescription = context.getAxisConfiguration().getTransportsIn()
-    	                    .get("http");
-    	            if (transportInDescription != null && transportInDescription.getParameter("port") != null) {
-    	                port = (String) transportInDescription.getParameter("port").getValue();
-    	            } else {
-    	                port = map.get("port");
-    	            }
-    	            localAddress = "http://" + localAddress + ":" + port;
-    	            localAddress = localAddress + "/" + context.getContextRoot() + "/" + context.getServicePath() + "/"
-    	                    + WSConstants.GFAC_SERVICE_NAME;
-    	            log.debug("GFAC_ADDRESS:" + localAddress);
-    	            context.setProperty(CONFIGURATION_CONTEXT_REGISTRY, registry);
-    	            context.setProperty(GFAC_URL, localAddress);
-    	            context.setProperty(TRUSTED_CERT_LOCATION,properties.getProperty(TRUSTED_CERT_LOCATION));
-    	            context.setProperty(MYPROXY_USER,properties.getProperty(MYPROXY_USER));
-    	            context.setProperty(MYPROXY_PASS,properties.getProperty(MYPROXY_PASS));
-    	            context.setProperty(MYPROXY_SERVER,properties.getProperty(MYPROXY_SERVER));
-    	            context.setProperty(MYPROXY_LIFE,properties.getProperty(MYPROXY_LIFE));
-    	            
-
-    	            /*
-    	             * Heart beat message to registry
-    	             */
-    	            thread = new GFacThread(context);
-    	            thread.start();
+	            	try {
+						Thread.sleep(JCR_AVAIALABILITY_WAIT_INTERVAL);
+					} catch (InterruptedException e1) {
+						e1.printStackTrace();
+					}
+					AiravataRegistry registry = new AiravataJCRRegistry(
+							new URI(
+									map.get(ORG_APACHE_JACKRABBIT_REPOSITORY_URI)),
+							map.get(JCR_CLASS), map.get(JCR_USER), map
+									.get(JCR_PASS), map);
+					String localAddress = Utils.getIpAddress(context
+							.getAxisConfiguration());
+					TransportInDescription transportInDescription = context
+							.getAxisConfiguration().getTransportsIn()
+							.get("http");
+					if (transportInDescription != null
+							&& transportInDescription.getParameter("port") != null) {
+						port = (String) transportInDescription
+								.getParameter("port").getValue();
+					} else {
+						port = map.get("port");
+					}
+					localAddress = "http://" + localAddress + ":" + port;
+					localAddress = localAddress + "/"
+							+ context.getContextRoot() + "/"
+							+ context.getServicePath() + "/"
+							+ WSConstants.GFAC_SERVICE_NAME;
+					log.debug("GFAC_ADDRESS:" + localAddress);
+					context.setProperty(CONFIGURATION_CONTEXT_REGISTRY,
+							registry);
+					context.setProperty(GFAC_URL, localAddress);
+					context.setProperty(TRUSTED_CERT_LOCATION,
+							properties.getProperty(TRUSTED_CERT_LOCATION));
+					context.setProperty(MYPROXY_USER,
+							properties.getProperty(MYPROXY_USER));
+					context.setProperty(MYPROXY_PASS,
+							properties.getProperty(MYPROXY_PASS));
+					context.setProperty(MYPROXY_SERVER,
+							properties.getProperty(MYPROXY_SERVER));
+					context.setProperty(MYPROXY_LIFE,
+							properties.getProperty(MYPROXY_LIFE));
+					/*
+					 * Heart beat message to registry
+					 */
+					thread = new GFacThread(context);
+					thread.start();
     	        } catch (Exception e) {
     	            log.error(e.getMessage(), e);
     	        }
@@ -181,16 +196,20 @@ public class GFacService implements Serv
         public void run() {
             try {
                 while (true) {
-                    AiravataRegistry registry = (AiravataRegistry) this.context.getProperty(CONFIGURATION_CONTEXT_REGISTRY);
-                    String localAddress = (String) this.context.getProperty(GFAC_URL);
-                    registry.saveGFacDescriptor(localAddress);
-                    log.info("Updated the GFac URL in to Repository");
-                    Thread.sleep(GFAC_URL_UPDATE_INTERVAL);
+                    try {
+						AiravataRegistry registry = (AiravataRegistry) this.context.getProperty(CONFIGURATION_CONTEXT_REGISTRY);
+						String localAddress = (String) this.context.getProperty(GFAC_URL);
+						registry.saveGFacDescriptor(localAddress);
+						log.info("Updated the GFac URL in to Repository");
+						Thread.sleep(GFAC_URL_UPDATE_INTERVAL);
+					} catch (RegistryException e) {
+						//in case of an registry exception best to retry sooner
+						log.error("Error saving GFac descriptor",e);
+						Thread.sleep(JCR_AVAIALABILITY_WAIT_INTERVAL);
+					}
                 }
             } catch (InterruptedException e) {
                 log.info("GFacURL update thread is interrupted");
-            } catch (RegistryException e) {
-				log.error("Error saving GFac descriptor",e);			
 			}
         }
     }

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java?rev=1304499&r1=1304498&r2=1304499&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java Fri Mar 23 17:20:10 2012
@@ -73,42 +73,54 @@ public class WorkflowInterpretorSkeleton
     public static  JCRComponentRegistry jcrComponentRegistry = null;
     public static int provenanceWriterThreadPoolSize = 1;
     public static final String PROVENANCE_WRITER_THREAD_POOL_SIZE = "provenanceWriterThreadPoolSize";
+    public static final int JCR_AVAIALABILITY_WAIT_INTERVAL = 1000 * 10;
 
-    public void startUp(ConfigurationContext configctx, AxisService service) {
-        URL url = this.getClass().getClassLoader().getResource("xbaya.properties");
-        Properties properties = new Properties();
-        try {
-            properties.load(url.openStream());
-            configctx.setProperty(MYPROXY_PASS, properties.get(MYPROXY_PASS));
-            configctx.setProperty(MYPROXY_USER, properties.get(MYPROXY_USER));
-
-            jcrUserName = (String)properties.get(JCR_USER);
-            jcrPassword = (String) properties.get(JCR_PASS);
-            jcrURL = (String) properties.get(JCR_URL);
-            provenanceWriterThreadPoolSize = Integer.parseInt((String)properties.get(PROVENANCE_WRITER_THREAD_POOL_SIZE));
-
-            if("true".equals(properties.get(PROVENANCE))){
-                provenance = true;
-                runner = new PredicatedTaskRunner(provenanceWriterThreadPoolSize);
-                try {
-                    jcrComponentRegistry = new JCRComponentRegistry(new URI(jcrURL),jcrUserName,jcrPassword);
-                } catch (RepositoryException e) {
-                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-                } catch (URISyntaxException e) {
-                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-                }
-            }else{
-                provenance = false;
-            }
-            if("true".equals(properties.get(RUN_IN_THREAD))){
-                runInThread = true;
-            }else{
-                runInThread = false;
-            }
+    public void startUp(final ConfigurationContext configctx, AxisService service) {
+    	new Thread(){
+    		@Override
+    		public void run() {
+    			try {
+					Thread.sleep(JCR_AVAIALABILITY_WAIT_INTERVAL);
+				} catch (InterruptedException e1) {
+					e1.printStackTrace();
+				}
+		        URL url = this.getClass().getClassLoader().getResource("xbaya.properties");
+		        Properties properties = new Properties();
+		        try {
+		            properties.load(url.openStream());
+		            configctx.setProperty(MYPROXY_PASS, properties.get(MYPROXY_PASS));
+		            configctx.setProperty(MYPROXY_USER, properties.get(MYPROXY_USER));
+		
+		            jcrUserName = (String)properties.get(JCR_USER);
+		            jcrPassword = (String) properties.get(JCR_PASS);
+		            jcrURL = (String) properties.get(JCR_URL);
+		            provenanceWriterThreadPoolSize = Integer.parseInt((String)properties.get(PROVENANCE_WRITER_THREAD_POOL_SIZE));
+		
+		            if("true".equals(properties.get(PROVENANCE))){
+		                provenance = true;
+		                runner = new PredicatedTaskRunner(provenanceWriterThreadPoolSize);
+		                try {
+		                    jcrComponentRegistry = new JCRComponentRegistry(new URI(jcrURL),jcrUserName,jcrPassword);
+		                } catch (RepositoryException e) {
+		                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+		                } catch (URISyntaxException e) {
+		                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+		                }
+		            }else{
+		                provenance = false;
+		            }
+		            if("true".equals(properties.get(RUN_IN_THREAD))){
+		                runInThread = true;
+		            }else{
+		                runInThread = false;
+		            }
+		
+		        } catch (IOException e) {
+		            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+		        }
+    		}
+    	}.start();
 
-        } catch (IOException e) {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-        }
     }
 	/**
 	 * Auto generated method signature