embulk-output-sftp 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 240c94805c37b60dab3cbd3fa4f56e7f4425ccd5
4
- data.tar.gz: e7c12ffd35503919c9cbe6ae5d94e0eb57e5dd29
3
+ metadata.gz: def79366c531079d576567b48397391ad61bf65f
4
+ data.tar.gz: 3a5e5e2fae4a711450ab485fba681fe39da7ddce
5
5
  SHA512:
6
- metadata.gz: 9daa772b09637ce0054f1ec9637fdc8f6ea7f7d989968bbaee32616c80fc7e2d711598b6d27b02a7931ace5012e87b2b373cc4d9caeac2a00345a600925854ac
7
- data.tar.gz: 9c4d21f588162ff7c9b3cf97acf8f83fae4ba373b1160aef490b9b6f8316984d18d9a9b831b101c276e41a25fa39b607a015cfe7786d9f73cb7ad363cea32d19
6
+ metadata.gz: f3985d0d51133dbe93a5a29c1a3b9c7757b2b9a0b8724a2cbd88b46bff6d4e91a6e1dc6eab86727397a772451c9f65146907da4da2239424e22028f4a5810eb6
7
+ data.tar.gz: 3894f07dbd4d056dd75bc0f9f4b95e000421ff1da5cc9733d1b6c563fffd355146b5d7f918ee454b7c7f4226de9dd8ce283313c5ea0f826477634c94caedbb68
@@ -1,7 +1,6 @@
1
1
  dist: trusty
2
2
  language: java
3
3
  jdk:
4
- - openjdk8
5
4
  - oraclejdk8
6
5
  script:
7
6
  - ./gradlew test
@@ -1,3 +1,6 @@
1
+ 0.2.2 (2019-07-26)
2
+ - Do not retry when "Connection refused" is returned and throw ConfigException
3
+ - https://github.com/embulk/embulk-output-sftp/pull/56
1
4
  0.2.1 (2018-10-23)
2
5
  - Improved logic that detects exception is retryable or not
3
6
  - https://github.com/embulk/embulk-output-sftp/pull/52
@@ -17,9 +17,9 @@ configurations {
17
17
  }
18
18
 
19
19
  group = "org.embulk.output.sftp"
20
- version = "0.2.1"
21
- sourceCompatibility = 1.7
22
- targetCompatibility = 1.7
20
+ version = "0.2.2"
21
+ sourceCompatibility = 1.8
22
+ targetCompatibility = 1.8
23
23
 
24
24
  dependencies {
25
25
  compile "org.embulk:embulk-core:0.9.7"
@@ -27,7 +27,7 @@ dependencies {
27
27
  // compile "YOUR_JAR_DEPENDENCY_GROUP:YOUR_JAR_DEPENDENCY_MODULE:YOUR_JAR_DEPENDENCY_VERSION"
28
28
  compile "org.apache.commons:commons-vfs2:2.2"
29
29
  compile "commons-io:commons-io:2.6"
30
- compile "com.jcraft:jsch:0.1.54"
30
+ compile "com.jcraft:jsch:0.1.55"
31
31
  testCompile "junit:junit:4.+"
32
32
  testCompile "org.embulk:embulk-core:0.9.7:tests"
33
33
  testCompile "org.embulk:embulk-standards:0.9.7"
@@ -2,7 +2,6 @@ package org.embulk.output.sftp;
2
2
 
3
3
  import com.fasterxml.jackson.annotation.JsonCreator;
4
4
  import com.fasterxml.jackson.annotation.JsonValue;
5
- import com.google.common.base.Optional;
6
5
  import org.apache.commons.vfs2.FileSystemOptions;
7
6
  import org.apache.commons.vfs2.provider.sftp.SftpFileSystemConfigBuilder;
8
7
  import org.embulk.config.Config;
@@ -11,33 +10,34 @@ import org.embulk.config.ConfigException;
11
10
  import org.embulk.config.Task;
12
11
 
13
12
  import java.util.Locale;
13
+ import java.util.Optional;
14
14
 
15
15
  interface ProxyTask
16
16
  extends Task
17
17
  {
18
18
  @Config("type")
19
- public ProxyType getType();
19
+ ProxyType getType();
20
20
 
21
21
  @Config("host")
22
- public Optional<String> getHost();
22
+ Optional<String> getHost();
23
23
 
24
24
  @Config("user")
25
25
  @ConfigDefault("null")
26
- public Optional<String> getUser();
26
+ Optional<String> getUser();
27
27
 
28
28
  @Config("password")
29
29
  @ConfigDefault("null")
30
- public Optional<String> getPassword();
30
+ Optional<String> getPassword();
31
31
 
32
32
  @Config("port")
33
33
  @ConfigDefault("22")
34
- public int getPort();
34
+ int getPort();
35
35
 
36
36
  @Config("command")
37
37
  @ConfigDefault("null")
38
- public Optional<String> getCommand();
38
+ Optional<String> getCommand();
39
39
 
40
- public enum ProxyType
40
+ enum ProxyType
41
41
  {
42
42
  HTTP,
43
43
  SOCKS,
@@ -1,6 +1,5 @@
1
1
  package org.embulk.output.sftp;
2
2
 
3
- import com.google.common.base.Optional;
4
3
  import org.embulk.config.Config;
5
4
  import org.embulk.config.ConfigDefault;
6
5
  import org.embulk.config.ConfigDiff;
@@ -18,6 +17,7 @@ import javax.validation.constraints.Min;
18
17
 
19
18
  import java.util.List;
20
19
  import java.util.Map;
20
+ import java.util.Optional;
21
21
 
22
22
  public class SftpFileOutputPlugin
23
23
  implements FileOutputPlugin
@@ -26,68 +26,68 @@ public class SftpFileOutputPlugin
26
26
  extends Task
27
27
  {
28
28
  @Config("host")
29
- public String getHost();
29
+ String getHost();
30
30
 
31
31
  @Config("port")
32
32
  @ConfigDefault("22")
33
- public int getPort();
33
+ int getPort();
34
34
 
35
35
  @Config("user")
36
- public String getUser();
36
+ String getUser();
37
37
 
38
38
  @Config("password")
39
39
  @ConfigDefault("null")
40
- public Optional<String> getPassword();
40
+ Optional<String> getPassword();
41
41
 
42
42
  @Config("secret_key_file")
43
43
  @ConfigDefault("null")
44
- public Optional<LocalFile> getSecretKeyFilePath();
45
- public void setSecretKeyFilePath(Optional<LocalFile> secretKeyFilePath);
44
+ Optional<LocalFile> getSecretKeyFilePath();
45
+ void setSecretKeyFilePath(Optional<LocalFile> secretKeyFilePath);
46
46
 
47
47
  @Config("secret_key_passphrase")
48
48
  @ConfigDefault("\"\"")
49
- public String getSecretKeyPassphrase();
49
+ String getSecretKeyPassphrase();
50
50
 
51
51
  @Config("user_directory_is_root")
52
52
  @ConfigDefault("true")
53
- public boolean getUserDirIsRoot();
53
+ boolean getUserDirIsRoot();
54
54
 
55
55
  @Config("timeout")
56
56
  @ConfigDefault("600") // 10 minutes
57
- public int getSftpConnectionTimeout();
57
+ int getSftpConnectionTimeout();
58
58
 
59
59
  @Config("max_connection_retry")
60
60
  @ConfigDefault("5") // 5 times retry to connect sftp server if failed.
61
- public int getMaxConnectionRetry();
61
+ int getMaxConnectionRetry();
62
62
 
63
63
  @Config("path_prefix")
64
- public String getPathPrefix();
64
+ String getPathPrefix();
65
65
 
66
66
  @Config("file_ext")
67
- public String getFileNameExtension();
67
+ String getFileNameExtension();
68
68
 
69
69
  @Config("sequence_format")
70
70
  @ConfigDefault("\"%03d.%02d.\"")
71
- public String getSequenceFormat();
71
+ String getSequenceFormat();
72
72
 
73
73
  @Config("proxy")
74
74
  @ConfigDefault("null")
75
- public Optional<ProxyTask> getProxy();
75
+ Optional<ProxyTask> getProxy();
76
76
 
77
77
  @Config("rename_file_after_upload")
78
78
  @ConfigDefault("false")
79
- public boolean getRenameFileAfterUpload();
79
+ boolean getRenameFileAfterUpload();
80
80
 
81
81
  // if `false`, plugin will use remote file as buffer
82
82
  @Config("local_buffering")
83
83
  @ConfigDefault("true")
84
- public boolean getLocalBuffering();
84
+ boolean getLocalBuffering();
85
85
 
86
86
  @Min(50L * 1024 * 1024) // 50MiB
87
87
  @Max(10L * 1024 * 1024 * 1024) // 10GiB
88
88
  @Config("temp_file_threshold")
89
89
  @ConfigDefault("5368709120") // 5GiB
90
- public long getTempFileThreshold();
90
+ long getTempFileThreshold();
91
91
  }
92
92
 
93
93
  @Override
@@ -1,7 +1,6 @@
1
1
  package org.embulk.output.sftp;
2
2
 
3
3
  import com.google.common.annotations.VisibleForTesting;
4
- import com.google.common.base.Function;
5
4
  import com.google.common.base.Throwables;
6
5
  import org.apache.commons.vfs2.FileObject;
7
6
  import org.apache.commons.vfs2.FileSystemException;
@@ -20,7 +19,6 @@ import org.embulk.spi.util.RetryExecutor.Retryable;
20
19
  import org.slf4j.Logger;
21
20
 
22
21
  import java.io.BufferedOutputStream;
23
- import java.io.Closeable;
24
22
  import java.io.File;
25
23
  import java.io.FileInputStream;
26
24
  import java.io.IOException;
@@ -29,6 +27,7 @@ import java.io.OutputStream;
29
27
  import java.net.URI;
30
28
  import java.net.URISyntaxException;
31
29
  import java.util.concurrent.TimeUnit;
30
+ import java.util.function.Function;
32
31
  import java.util.regex.Pattern;
33
32
 
34
33
  import static org.embulk.output.sftp.SftpFileOutputPlugin.PluginTask;
@@ -96,7 +95,7 @@ public class SftpUtils
96
95
  builder.setStrictHostKeyChecking(fsOptions, "no");
97
96
  if (task.getSecretKeyFilePath().isPresent()) {
98
97
  IdentityInfo identityInfo = new IdentityInfo(
99
- new File((task.getSecretKeyFilePath().transform(localFileToPathString()).get())),
98
+ new File((task.getSecretKeyFilePath().map(localFileToPathString()).get())),
100
99
  task.getSecretKeyPassphrase().getBytes()
101
100
  );
102
101
  builder.setIdentityInfo(fsOptions, identityInfo);
@@ -1,6 +1,7 @@
1
1
  package org.embulk.output.sftp.utils;
2
2
 
3
3
  import com.jcraft.jsch.JSchException;
4
+ import org.embulk.config.ConfigException;
4
5
  import org.embulk.spi.Exec;
5
6
  import org.embulk.spi.util.RetryExecutor;
6
7
  import org.slf4j.Logger;
@@ -19,7 +20,7 @@ public abstract class DefaultRetry<T> implements RetryExecutor.Retryable<T>
19
20
  @Override
20
21
  public boolean isRetryableException(Exception exception)
21
22
  {
22
- return !hasRootCauseAuthFail(exception);
23
+ return !hasRootCauseUserProblem(exception);
23
24
  }
24
25
 
25
26
  @Override
@@ -38,6 +39,9 @@ public abstract class DefaultRetry<T> implements RetryExecutor.Retryable<T>
38
39
  @Override
39
40
  public void onGiveup(Exception firstException, Exception lastException)
40
41
  {
42
+ if (hasRootCauseUserProblem(lastException)) {
43
+ throw new ConfigException(lastException);
44
+ }
41
45
  }
42
46
 
43
47
  private static boolean isAuthFail(Throwable e)
@@ -45,9 +49,14 @@ public abstract class DefaultRetry<T> implements RetryExecutor.Retryable<T>
45
49
  return e instanceof JSchException && (e.getMessage().contains("Auth fail") || e.getMessage().contains("USERAUTH fail"));
46
50
  }
47
51
 
48
- private static boolean hasRootCauseAuthFail(Throwable e)
52
+ private static boolean isConnectionProblem(Throwable e)
53
+ {
54
+ return e instanceof JSchException && (e.getMessage().contains("Connection refused"));
55
+ }
56
+
57
+ private static boolean hasRootCauseUserProblem(Throwable e)
49
58
  {
50
- while (e != null && !isAuthFail(e)) {
59
+ while (e != null && !isAuthFail(e) && !isConnectionProblem(e)) {
51
60
  e = e.getCause();
52
61
  }
53
62
  return e != null;
@@ -1,7 +1,6 @@
1
1
  package org.embulk.output.sftp;
2
2
 
3
3
  import com.google.common.base.Charsets;
4
- import com.google.common.base.Optional;
5
4
  import com.google.common.collect.Lists;
6
5
  import com.google.common.io.Resources;
7
6
  import com.jcraft.jsch.JSchException;
@@ -62,6 +61,7 @@ import java.security.PublicKey;
62
61
  import java.util.Arrays;
63
62
  import java.util.Collections;
64
63
  import java.util.List;
64
+ import java.util.Optional;
65
65
  import java.util.Random;
66
66
  import java.util.concurrent.TimeoutException;
67
67
 
@@ -331,8 +331,8 @@ public class TestSftpFileOutputPlugin
331
331
  assertEquals(HOST, task.getHost());
332
332
  assertEquals(22, task.getPort());
333
333
  assertEquals(USERNAME, task.getUser());
334
- assertEquals(Optional.absent(), task.getPassword());
335
- assertEquals(Optional.absent(), task.getSecretKeyFilePath());
334
+ assertEquals(Optional.empty(), task.getPassword());
335
+ assertEquals(Optional.empty(), task.getSecretKeyFilePath());
336
336
  assertEquals("", task.getSecretKeyPassphrase());
337
337
  assertEquals(true, task.getUserDirIsRoot());
338
338
  assertEquals(600, task.getSftpConnectionTimeout());
@@ -340,7 +340,7 @@ public class TestSftpFileOutputPlugin
340
340
  assertEquals(pathPrefix, task.getPathPrefix());
341
341
  assertEquals("txt", task.getFileNameExtension());
342
342
  assertEquals("%03d.%02d.", task.getSequenceFormat());
343
- assertEquals(Optional.absent(), task.getProxy());
343
+ assertEquals(Optional.empty(), task.getProxy());
344
344
  }
345
345
 
346
346
  @Test
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-sftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Civitaspo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-10-23 00:00:00.000000000 Z
12
+ date: 2019-07-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement
@@ -83,9 +83,9 @@ files:
83
83
  - src/test/resources/id_rsa.pub
84
84
  - classpath/commons-logging-1.2.jar
85
85
  - classpath/commons-vfs2-2.2.jar
86
- - classpath/embulk-output-sftp-0.2.1.jar
86
+ - classpath/embulk-output-sftp-0.2.2.jar
87
87
  - classpath/commons-io-2.6.jar
88
- - classpath/jsch-0.1.54.jar
88
+ - classpath/jsch-0.1.55.jar
89
89
  homepage: https://github.com/embulk/embulk-output-sftp
90
90
  licenses:
91
91
  - MIT