You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/10/03 08:06:37 UTC

[camel] branch camel-2.24.x updated (8565063 -> 62a49ac)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch camel-2.24.x
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 8565063  CAMEL-13796: Allow to configure idle and connection timeout on camel-salesforce http client and increaase default a bit
     new 6a6298e  [CAMEL-14000] Use LRUCache instead of Map when caching Services (Producers/Consumers) (#3218)
     new 62a49ac  CAMEL-14030: camel-ftp - streamDownload=true and move options dont work. Thanks to Peter Nowak for reporting and the suggested fix.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../strategy/GenericFileRenameProcessStrategy.java |  9 ++++-
 .../org/apache/camel/impl/DefaultServicePool.java  |  8 ++--
 ...treamingTest.java => FtpStreamingMoveTest.java} | 45 +++++++++++++---------
 3 files changed, 39 insertions(+), 23 deletions(-)
 copy components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/{FtpSimpleConsumeStreamingTest.java => FtpStreamingMoveTest.java} (65%)


[camel] 01/02: [CAMEL-14000] Use LRUCache instead of Map when caching Services (Producers/Consumers) (#3218)

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.24.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 6a6298e33ff2772c7e96d903fc2dbcaa648fb25a
Author: John Poth <po...@gmail.com>
AuthorDate: Thu Oct 3 04:40:58 2019 +0200

    [CAMEL-14000] Use LRUCache instead of Map when caching Services (Producers/Consumers) (#3218)
---
 .../src/main/java/org/apache/camel/impl/DefaultServicePool.java   | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultServicePool.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultServicePool.java
index fdb928e..9d85eea 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultServicePool.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultServicePool.java
@@ -18,13 +18,13 @@ package org.apache.camel.impl;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Map;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
 
 import org.apache.camel.spi.ServicePool;
 import org.apache.camel.support.ServiceSupport;
+import org.apache.camel.util.LRUCacheFactory;
 import org.apache.camel.util.ServiceHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -37,14 +37,16 @@ import org.slf4j.LoggerFactory;
 @Deprecated
 public abstract class DefaultServicePool<Key, Service> extends ServiceSupport implements ServicePool<Key, Service> {
     protected final Logger log = LoggerFactory.getLogger(getClass());
-    protected final ConcurrentMap<Key, BlockingQueue<Service>> pool = new ConcurrentHashMap<>();
+    protected final Map<Key, BlockingQueue<Service>> pool;
     protected int capacity = 100;
 
     protected DefaultServicePool() {
+        this.pool = LRUCacheFactory.newLRUCache(capacity);
     }
 
     public DefaultServicePool(int capacity) {
         this.capacity = capacity;
+        this.pool = LRUCacheFactory.newLRUCache(capacity);
     }
 
     public int getCapacity() {


[camel] 02/02: CAMEL-14030: camel-ftp - streamDownload=true and move options dont work. Thanks to Peter Nowak for reporting and the suggested fix.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.24.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 62a49acec85e56f78f8179776eafd0204f035c2d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Oct 3 09:55:21 2019 +0200

    CAMEL-14030: camel-ftp - streamDownload=true and move options dont work. Thanks to Peter Nowak for reporting and the suggested fix.
---
 .../strategy/GenericFileRenameProcessStrategy.java |  9 ++-
 .../file/remote/FtpStreamingMoveTest.java          | 77 ++++++++++++++++++++++
 2 files changed, 84 insertions(+), 2 deletions(-)

diff --git a/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameProcessStrategy.java b/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameProcessStrategy.java
index ada2a9c..024bf45 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameProcessStrategy.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameProcessStrategy.java
@@ -93,6 +93,8 @@ public class GenericFileRenameProcessStrategy<T> extends GenericFileProcessStrat
     @Override
     public void commit(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, Exchange exchange, GenericFile<T> file) throws Exception {
         try {
+            operations.releaseRetrievedFileResources(exchange);
+            
             if (commitRenamer != null) {
                 // create a copy and bind the file to the exchange to be used by the renamer to evaluate the file name
                 Exchange copy = ExchangeHelper.createCopy(exchange, true);
@@ -111,8 +113,11 @@ public class GenericFileRenameProcessStrategy<T> extends GenericFileProcessStrat
                 renameFile(operations, file, newName);
             }
         } finally {
-            // must invoke super
-            super.commit(operations, endpoint, exchange, file);
+            deleteLocalWorkFile(exchange);
+            // must release lock last
+            if (exclusiveReadLockStrategy != null) {
+                exclusiveReadLockStrategy.releaseExclusiveReadLockOnCommit(operations, file, exchange);
+            }
         }
     }
 
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpStreamingMoveTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpStreamingMoveTest.java
new file mode 100644
index 0000000..45f4bb2
--- /dev/null
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpStreamingMoveTest.java
@@ -0,0 +1,77 @@
+/**
+ * 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.camel.component.file.remote;
+
+import java.io.File;
+import java.io.InputStream;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.file.GenericFile;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Before;
+import org.junit.Test;
+
+public class FtpStreamingMoveTest extends FtpServerTestSupport {
+
+    private String getFtpUrl() {
+        return "ftp://admin@localhost:" + getPort() + "/mymove?password=admin&delay=1000&streamDownload=true&move=done";
+    }
+
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        deleteDirectory("target/mymove");
+    }
+
+    @Test
+    public void testStreamDownloadMove() throws Exception {
+        if (!canTest()) {
+            return;
+        }
+
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello World");
+
+        sendFile(getFtpUrl(), "Hello World", "hello.txt");
+
+        context.getRouteController().startRoute("foo");
+
+        assertMockEndpointsSatisfied();
+
+        GenericFile<?> remoteFile = (GenericFile<?>) mock.getExchanges().get(0).getIn().getBody();
+        assertTrue(remoteFile.getBody() instanceof InputStream);
+
+        // give time for consumer to rename file
+        Thread.sleep(1000);
+
+        File file = new File(FTP_ROOT_DIR + "/mymove/done/hello.txt");
+        assertTrue("File should have been renamed", file.exists());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(getFtpUrl())
+                    .routeId("foo").noAutoStartup()
+                    .to("mock:result");
+            }
+        };
+    }
+}