servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lh...@apache.org
Subject svn commit: r798044 - in /servicemix/components/bindings/servicemix-vfs/trunk/src/main: java/org/apache/servicemix/vfs/VFSPollingEndpoint.java resources/META-INF/spring/servicemix-vfs.xml
Date Mon, 27 Jul 2009 07:01:48 GMT
Author: lhein
Date: Mon Jul 27 07:01:47 2009
New Revision: 798044

URL: http://svn.apache.org/viewvc?rev=798044&view=rev
Log:
- applied patch for SMXCOMP-603 provided by Bill Simms
- put in a logic for releasing the lock of the file if an error happens on processing the
file (otherwise this file will be locked forever)

Modified:
    servicemix/components/bindings/servicemix-vfs/trunk/src/main/java/org/apache/servicemix/vfs/VFSPollingEndpoint.java
    servicemix/components/bindings/servicemix-vfs/trunk/src/main/resources/META-INF/spring/servicemix-vfs.xml

Modified: servicemix/components/bindings/servicemix-vfs/trunk/src/main/java/org/apache/servicemix/vfs/VFSPollingEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-vfs/trunk/src/main/java/org/apache/servicemix/vfs/VFSPollingEndpoint.java?rev=798044&r1=798043&r2=798044&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-vfs/trunk/src/main/java/org/apache/servicemix/vfs/VFSPollingEndpoint.java
(original)
+++ servicemix/components/bindings/servicemix-vfs/trunk/src/main/java/org/apache/servicemix/vfs/VFSPollingEndpoint.java
Mon Jul 27 07:01:47 2009
@@ -6,7 +6,6 @@
  * (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,
@@ -46,6 +45,7 @@
 import org.apache.servicemix.common.locks.impl.SimpleLockManager;
 import org.apache.servicemix.components.util.DefaultFileMarshaler;
 import org.apache.servicemix.components.util.FileMarshaler;
+import org.apache.servicemix.executors.ExecutorAwareRunnable;
 
 /**
  * A polling endpoint that looks for a file or files in a virtual file system 
@@ -73,7 +73,7 @@
     private FileSystemManager fileSystemManager;
     private LockManager lockManager;
     private ConcurrentMap<String, InputStream> openExchanges = new ConcurrentHashMap<String,
InputStream>();
-    
+    private boolean concurrentExchange = true;
     /**
      * default constructor
      */
@@ -158,7 +158,7 @@
                 throw new JBIException(
                                        "Property org.apache.servicemix.vfs was removed from
the exchange -- unable to delete/archive the file");
             }
-
+            
             logger.debug("Releasing " + aFile.getName().getPathDecoded());
         
             // first try to close the stream
@@ -290,7 +290,7 @@
             }
             
             // execute processing in another thread
-            getExecutor().execute(new Runnable() {
+            getExecutor().execute(new ExecutorAwareRunnable() {
                 public void run() {
                     String uri = aFile.getName().getURI().toString();
                     Lock lock = lockManager.getLock(uri);
@@ -303,6 +303,9 @@
                         }
                     }
                 }
+                public boolean shouldRunSynchronously(){
+                	return !isConcurrentExchange();
+                }
             });
         }
     }
@@ -322,7 +325,9 @@
                 processFile(aFile);
             }
         } catch (Exception e) {
-            logger.error("Failed to process file: " + aFile.getName().getURI() + ". Reason:
" + e, e);
+        	workingSet.remove(aFile);
+        	unlockAsyncFile(aFile);
+        	logger.error("Failed to process file: " + aFile.getName().getURI() + ". Reason:
" + e, e);
         }
     }
 
@@ -356,7 +361,12 @@
         exchange.getInMessage().setProperty(VFSComponent.VFS_PROPERTY, file);
         this.openExchanges.put(exchange.getExchangeId(), stream);
 
-        send(exchange);
+        if(isConcurrentExchange()){
+        	send(exchange);
+        }else{
+        	sendSync(exchange);
+        	process(exchange);
+        }
     }
     
     /**
@@ -516,5 +526,19 @@
     public void setRecursive(boolean recursive) {
         this.recursive = recursive;
     }
+    
+	/**
+	 * @return the concurrentExchange
+	 */
+	public boolean isConcurrentExchange() {
+		return concurrentExchange;
+	}
+
+	/**
+	 * @param concurrentExchange the concurrentExchange to set
+	 */
+	public void setConcurrentExchange(boolean concurrentExchange) {
+		this.concurrentExchange = concurrentExchange;
+	}
 
 }

Modified: servicemix/components/bindings/servicemix-vfs/trunk/src/main/resources/META-INF/spring/servicemix-vfs.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-vfs/trunk/src/main/resources/META-INF/spring/servicemix-vfs.xml?rev=798044&r1=798043&r2=798044&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-vfs/trunk/src/main/resources/META-INF/spring/servicemix-vfs.xml
(original)
+++ servicemix/components/bindings/servicemix-vfs/trunk/src/main/resources/META-INF/spring/servicemix-vfs.xml
Mon Jul 27 07:01:47 2009
@@ -45,6 +45,7 @@
                 <property name="corePoolSize" value="${threadPoolCorePoolSize}"/>
                 <property name="maximumPoolSize" value="${threadPoolMaximumPoolSize}"/>
                 <property name="queueSize" value="${threadPoolQueueSize}"/>
+                <property name="bypassIfSynchronous" value="${threadPoolAllowBypass}"/>
             </bean>
         </property>
     </bean>
@@ -70,6 +71,7 @@
         <prop key="threadPoolCorePoolSize">8</prop>
         <prop key="threadPoolMaximumPoolSize">32</prop>
         <prop key="threadPoolQueueSize">256</prop>
+        <prop key="threadPoolAllowBypass">true</prop>
     </osgix:cm-properties>
 
     <ctx:property-placeholder properties-ref="cmProps" />



Mime
View raw message