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

suvasude pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-gobblin.git


The following commit(s) were added to refs/heads/master by this push:
     new 5d61531  [GOBBLIN-833] Make SFTP connection timeout-table
5d61531 is described below

commit 5d61531aa80944a104efc22752e1622c9c0a549f
Author: autumnust <[email protected]>
AuthorDate: Thu Jul 25 19:18:40 2019 -0700

    [GOBBLIN-833] Make SFTP connection timeout-table
    
    Closes #2692 from autumnust/connectionTimeoutSFTP
---
 .../gobblin/source/extractor/extract/sftp/SftpFsHelper.java       | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git 
a/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/extract/sftp/SftpFsHelper.java
 
b/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/extract/sftp/SftpFsHelper.java
index bb3c4da..a60999b 100644
--- 
a/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/extract/sftp/SftpFsHelper.java
+++ 
b/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/extract/sftp/SftpFsHelper.java
@@ -64,6 +64,9 @@ public class SftpFsHelper implements 
TimestampAwareFileBasedHelper {
   private Session session;
   private State state;
 
+  private static final String SFTP_CONNECTION_TIMEOUT_KEY = "sftpConn.timeout";
+  private static final int DEFAULT_SFTP_CONNECTION_TIMEOUT = 3000;
+
   public SftpFsHelper(State state) {
 
     this.state = state;
@@ -99,7 +102,10 @@ public class SftpFsHelper implements 
TimestampAwareFileBasedHelper {
 
     try {
       ChannelSftp channelSftp = (ChannelSftp) this.session.openChannel("sftp");
-      channelSftp.connect();
+
+      // In millsec
+      int connTimeout = state.getPropAsInt(SFTP_CONNECTION_TIMEOUT_KEY, 
DEFAULT_SFTP_CONNECTION_TIMEOUT);
+      channelSftp.connect(connTimeout);
       return channelSftp;
     } catch (JSchException e) {
       throw new SftpException(0, "Cannot open a channel to SFTP server", e);

Reply via email to