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 2018/01/17 09:41:06 UTC

[camel] branch master updated (1b23a30 -> e52425e)

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

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


    from 1b23a30  Upgrade OS Maven Plugin to version 1.5.0.Final
     new 494e9d8  Polished
     new e52425e  CAMEL-12061: camel-ftp now forces a hard disconnect in case of rollback such as error during scanning files etc, to force a fresh client/login on next poll to mitigate any transient issues in the ftp client.

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:
 .../camel/component/file/remote/FtpOperations.java |  5 ++++
 .../component/file/remote/RemoteFileConsumer.java  | 32 ++++++++++++++++------
 .../file/remote/RemoteFileOperations.java          |  7 +++++
 .../RemoteFilePollingConsumerPollStrategy.java     |  6 ++--
 .../component/file/remote/SftpOperations.java      | 17 +++++++++++-
 .../apache/camel/component/scp/ScpOperations.java  | 16 +++++++++--
 6 files changed, 69 insertions(+), 14 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
['"commits@camel.apache.org" <co...@camel.apache.org>'].

[camel] 02/02: CAMEL-12061: camel-ftp now forces a hard disconnect in case of rollback such as error during scanning files etc, to force a fresh client/login on next poll to mitigate any transient issues in the ftp client.

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

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

commit e52425e6b9f70a7f59e5a2b6025330470049f0f0
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jan 17 10:40:46 2018 +0100

    CAMEL-12061: camel-ftp now forces a hard disconnect in case of rollback such as error during scanning files etc, to force a fresh client/login on next poll to mitigate any transient issues in the ftp client.
---
 .../camel/component/file/remote/FtpOperations.java      |  5 +++++
 .../camel/component/file/remote/RemoteFileConsumer.java | 16 ++++++++++++++++
 .../component/file/remote/RemoteFileOperations.java     |  7 +++++++
 .../remote/RemoteFilePollingConsumerPollStrategy.java   |  6 +++---
 .../camel/component/file/remote/SftpOperations.java     | 17 ++++++++++++++++-
 .../org/apache/camel/component/scp/ScpOperations.java   | 16 ++++++++++++++--
 6 files changed, 61 insertions(+), 6 deletions(-)

diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
index 36a7c5d..fba2389 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
@@ -249,6 +249,11 @@ public class FtpOperations implements RemoteFileOperations<FTPFile> {
         }
     }
 
+    @Override
+    public void forceDisconnect() throws GenericFileOperationFailedException {
+        doDisconnect();
+    }
+
     protected void doDisconnect() throws GenericFileOperationFailedException {
         // logout before disconnecting
         clientActivityListener.onDisconnecting(endpoint.getConfiguration().remoteServerInformation());
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
index 483e4aa..a676732 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
@@ -166,6 +166,22 @@ public abstract class RemoteFileConsumer<T> extends GenericFileConsumer<T> {
         }
     }
 
+    protected void forceDisconnect() {
+        // eager indicate we are no longer logged in
+        loggedIn = false;
+
+        // disconnect
+        try {
+            if (log.isDebugEnabled()) {
+                log.debug("Force disconnecting from: {}", remoteServer());
+            }
+            getOperations().forceDisconnect();
+        } catch (GenericFileOperationFailedException e) {
+            // ignore just log a warning
+            log.warn("Error occurred while disconnecting from " + remoteServer() + " due: " + e.getMessage() + ". This exception will be ignored.");
+        }
+    }
+
     protected void recoverableConnectIfNecessary() throws Exception {
         try {
             connectIfNecessary();
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileOperations.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileOperations.java
index 55573cb..7136682 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileOperations.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileOperations.java
@@ -49,6 +49,13 @@ public interface RemoteFileOperations<T> extends GenericFileOperations<T> {
     void disconnect() throws GenericFileOperationFailedException;
 
     /**
+     * Forces a hard disconnect from the remote server and cause the client to be re-created on next poll.
+     *
+     * @throws GenericFileOperationFailedException can be thrown
+     */
+    void forceDisconnect() throws GenericFileOperationFailedException;
+
+    /**
      * Sends a noop command to the remote server
      *
      * @return <tt>true</tt> if the noop was a success, <tt>false</tt> otherwise
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFilePollingConsumerPollStrategy.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFilePollingConsumerPollStrategy.java
index fea8be2..85d40cd 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFilePollingConsumerPollStrategy.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFilePollingConsumerPollStrategy.java
@@ -35,12 +35,12 @@ public class RemoteFilePollingConsumerPollStrategy extends DefaultPollingConsume
             // only try to recover if we are allowed to run
             if (rfc.isRunAllowed()) {
                 // disconnect from the server to force it to re login at next poll to recover
-                log.warn("Trying to recover by disconnecting from remote server forcing a re-connect at next poll: " + rfc.remoteServer());
+                log.warn("Trying to recover by force disconnecting from remote server and re-connecting at next poll: {}", rfc.remoteServer());
                 try {
-                    rfc.disconnect();
+                    rfc.forceDisconnect();
                 } catch (Throwable t) {
                     // ignore the exception
-                    log.debug("Error occurred during disconnect from: " + rfc.remoteServer() + ". This exception will be ignored.", t);
+                    log.debug("Error occurred during force disconnecting from: " + rfc.remoteServer() + ". This exception will be ignored.", t);
                 }
             }
         }
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
index a06ad5c..e6178a9 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
@@ -420,9 +420,24 @@ public class SftpOperations implements RemoteFileOperations<SftpRemoteFile> {
         }
     }
 
+    public synchronized void forceDisconnect() throws GenericFileOperationFailedException {
+        try {
+            if (session != null) {
+                session.disconnect();
+            }
+            if (channel != null) {
+                channel.disconnect();
+            }
+        } finally {
+            // ensure these
+            session = null;
+            channel = null;
+        }
+    }
+
     private void reconnectIfNecessary() {
         if (!isConnected()) {
-            connect((RemoteFileConfiguration) endpoint.getConfiguration());
+            connect(endpoint.getConfiguration());
         }
     }
 
diff --git a/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpOperations.java b/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpOperations.java
index 3854f4a..6fdfe0d 100644
--- a/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpOperations.java
+++ b/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpOperations.java
@@ -193,10 +193,22 @@ public class ScpOperations implements RemoteFileOperations<ScpFile> {
 
     @Override
     public void disconnect() throws GenericFileOperationFailedException {
-        if (isConnected()) {
+        try {
+            if (isConnected()) {
+                session.disconnect();
+            }
+        } finally {
+            session = null;
+        }
+    }
+
+    @Override
+    public void forceDisconnect() throws GenericFileOperationFailedException {
+        try {
             session.disconnect();
+        } finally {
+            session = null;
         }
-        session = null;
     }
 
     @Override

-- 
To stop receiving notification emails like this one, please contact
"commits@camel.apache.org" <co...@camel.apache.org>.

[camel] 01/02: Polished

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

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

commit 494e9d8027db61c2894cb78f798f34ea8b053752
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jan 17 10:12:30 2018 +0100

    Polished
---
 .../camel/component/file/remote/RemoteFileConsumer.java  | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
index d8653e3..483e4aa 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
@@ -228,12 +228,12 @@ public abstract class RemoteFileConsumer<T> extends GenericFileConsumer<T> {
     }
 
     /**
-     * Executes doPollDirectory and on exception checks if it can be ignored by calling ignoreCannotRetrieveFile .
+     * Executes doPollDirectory and on exception checks if it can be ignored by calling ignoreCannotRetrieveFile.
      *
-     * @param absolutePath The path of the directory to poll
-     * @param dirName The name of the directory to poll
-     * @param fileList current list of files gathered
-     * @param depth the current depth of the directory
+     * @param absolutePath  the path of the directory to poll
+     * @param dirName       the name of the directory to poll
+     * @param fileList      current list of files gathered
+     * @param depth         the current depth of the directory
      * @return whether or not to continue polling, <tt>false</tt> means the maxMessagesPerPoll limit has been hit
      * @throws GenericFileOperationFailedException if the exception during doPollDirectory can not be ignored
      */
@@ -243,13 +243,13 @@ public abstract class RemoteFileConsumer<T> extends GenericFileConsumer<T> {
             //Try to poll the directory
             return doPollDirectory(absolutePath, dirName, fileList, depth);
         } catch (Exception e) {
-            log.debug("Caught exception " + e.getMessage());
+            log.debug("Caught exception {}", e.getMessage());
             if (ignoreCannotRetrieveFile(absolutePath, null, e)) {
-                log.trace("Ignoring file error " + e.getMessage() + " for " + absolutePath);
+                log.trace("Ignoring file error {} for {}", e.getMessage(), absolutePath);
                 //indicate no files in this directory to poll, continue with fileList
                 return true;
             } else {
-                log.trace("Not ignoring file error " + e.getMessage() + " for " + absolutePath);
+                log.trace("Not ignoring file error {} for {}", e.getMessage(), absolutePath);
                 if (e instanceof GenericFileOperationFailedException) {
                     throw (GenericFileOperationFailedException) e;
                 } else {

-- 
To stop receiving notification emails like this one, please contact
"commits@camel.apache.org" <co...@camel.apache.org>.