Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Duration unit to use sec, msec, usec, and min suffix in params #31

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,65 @@

* **min_task_size** (experimental): minimum bytesize of a task. If this is larger than 0, one task includes multiple input files up until it becomes the bytesize in total. This is useful if too many number of tasks impacts performance of output or executor plugins badly. (integer, optional)

- **client_config**: configure S3 client config (optional)

- **protocol**: (enum, `HTTP` or `HTTPS`. default: `"HTTPS"`)

- **max_connections**: (int, default: `50`)

- **user_agent** (string, optional)

- **local_address**: name of a hostname (string, optional)

- **proxy_host**: name of a hostname (string, optional)

- **proxy_port**: (int, optional)

- **proxy_username**: (string, optional)

- **proxy_password**: (string, optional)

- **proxy_domain**: (string, optional)

- **proxy_workstation**: (string, optional)

- **max_error_retry**: (int, default: `3`)

- **socket_timeout**: (duration, default: `8min`)

- **connection_timeout**: (duration, default: `50sec`)

- **request_timeout**: (duration, default: no timeout)

- **use_reaper**: (boolean, optional)

- **use_gzip**: (boolean, optional)

- **signer_override**: (string, optional)

- **preemptive_basic_proxy_auth**: (boolean, optional)

- **connection_ttl**: (duration, optional)

- **connection_max_idle**: (duration, default: `60sec`)

- **use_tcp_keep_alive**: (boolean, optional)

- **response_metadata_cache_size**: (bytesize, optional)

- **use_expect_continue**: (boolean, optional)

- **secure_random**: (optional)

- **algorithm**: (string, required)

- **provider**: (string, optional)

- **socket_send_buffer_size_hint**: (bytesize, optional)

- **socket_receive_buffer_size_hint**: (bytesize, optional)


## Example

```yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package org.embulk.input.s3;

import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.InputStream;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.base.Optional;
import com.google.common.base.Throwables;
import org.slf4j.Logger;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.ListObjectsRequest;
Expand All @@ -23,7 +19,6 @@
import com.amazonaws.services.s3.model.S3Object;
import com.amazonaws.ClientConfiguration;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.Protocol;
import org.embulk.config.Config;
import org.embulk.config.ConfigInject;
import org.embulk.config.ConfigDefault;
Expand Down Expand Up @@ -65,7 +60,9 @@ public interface PluginTask
@ConfigDefault("null")
public Optional<String> getAccessKeyId();

// TODO timeout, ssl, etc
@Config("client_config")
@ConfigDefault("{}")
public AwsClientConfigurationTask getClientConfig();

public FileList getFiles();
public void setFiles(FileList files);
Expand Down Expand Up @@ -129,14 +126,7 @@ protected AWSCredentialsProvider getCredentialsProvider(PluginTask task)

protected ClientConfiguration getClientConfiguration(PluginTask task)
{
ClientConfiguration clientConfig = new ClientConfiguration();

//clientConfig.setProtocol(Protocol.HTTP);
clientConfig.setMaxConnections(50); // SDK default: 50
clientConfig.setMaxErrorRetry(3); // SDK default: 3
clientConfig.setSocketTimeout(8*60*1000); // SDK default: 50*1000

return clientConfig;
return AwsClientConfigurations.getClientConfiguration(task.getClientConfig());
}

private FileList listFiles(PluginTask task)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
package org.embulk.input.s3;

import com.google.common.base.Optional;
import com.amazonaws.Protocol;
import org.embulk.config.Config;
import org.embulk.config.ConfigDefault;
import org.embulk.config.Task;
import org.embulk.spi.unit.ByteSize;

public interface AwsClientConfigurationTask
extends Task
{
// NOTE: Can use `client_execution_timeout` from v1.10.65
// @Config("client_execution_timeout")
// @ConfigDefault("null")
// Optional<Integer> getClientExecutionTimeout();

@Config("connection_max_idle")
@ConfigDefault("null")
Optional<Duration> getConnectionMaxIdle();

@Config("connection_timeout")
@ConfigDefault("null") // SDK default: 50sec
Optional<Duration> getConnectionTimeout();

@Config("connection_ttl")
@ConfigDefault("null")
Optional<Duration> getConnectionTTL();

// NOTE: DnsResolver is a interface
// @Config("dns_resolver")
// @ConfigDefault("null")
// Optional<DnsResolver> getDnsResolver();

@Config("local_address")
@ConfigDefault("null")
Optional<String> getLocalAddress();

@Config("max_connections")
@ConfigDefault("50")
Optional<Integer> getMaxConnections();

@Config("max_error_retry")
@ConfigDefault("3")
Optional<Integer> getMaxErrorRetry();

@Config("preemptive_basic_proxy_auth")
@ConfigDefault("null")
Optional<Boolean> getPreemptiveBasicProxyAuth();

@Config("protocol")
@ConfigDefault("null") // SDK default: HTTPS
Optional<Protocol> getProtocol();

@Config("proxy_domain")
@ConfigDefault("null")
Optional<String> getProxyDomain();

@Config("proxy_host")
@ConfigDefault("null")
Optional<String> getProxyHost();

@Config("proxy_password")
@ConfigDefault("null")
Optional<String> getProxyPassword();

@Config("proxy_port")
@ConfigDefault("null")
Optional<Integer> getProxyPort();

@Config("proxy_username")
@ConfigDefault("null")
Optional<String> getProxyUsername();

@Config("proxy_workstation")
@ConfigDefault("null")
Optional<String> getProxyWorkstation();

@Config("request_timeout")
@ConfigDefault("null")
Optional<Duration> getRequestTimeout();

@Config("response_metadata_cache_size")
@ConfigDefault("null")
Optional<ByteSize> getResponseMetadataCacheSize();

// NOTE: RetryPolicy is a interface
// @Config("retry_policy")
// @ConfigDefault("null")
// Optional<RetryPolicy> getRetryPolicy();

@Config("secure_random")
@ConfigDefault("null")
Optional<SecureRandomTask> getSecureRandom();

public interface SecureRandomTask
extends org.embulk.config.Task
{
@Config("algorithm")
String getAlgorithm();

@Config("provider")
@ConfigDefault("null")
Optional<String> getProvider();
}

@Config("signer_override")
@ConfigDefault("null")
Optional<String> getSignerOverride();

@Config("socket_timeout")
@ConfigDefault("\"8min\"")
Optional<Duration> getSocketTimeout();

@Config("use_expect_continue")
@ConfigDefault("null")
Optional<Boolean> getUseExpectContinue();

@Config("use_gzip")
@ConfigDefault("null")
Optional<Boolean> getUseGzip();

@Config("user_agent")
@ConfigDefault("null")
Optional<String> getUserAgent();

@Config("use_reaper")
@ConfigDefault("null")
Optional<Boolean> getUseReaper();

@Config("use_tcp_keep_alive")
@ConfigDefault("null")
Optional<Boolean> getUseTcpKeepAlive();

// NOTE: Can use `use_throttle_retries` from v1.10.65
// @Config("use_throttle_retries")
// @ConfigDefault("null")
// Optional<Boolean> getUseThrottleRetries();

@Config("socket_send_buffer_size_hint") // used by setSocketBufferSizeHints
@ConfigDefault("null")
Optional<ByteSize> getSocketSendBufferSizeHint();

@Config("socket_receive_buffer_size_hint") // used by setSocketBufferSizeHints
@ConfigDefault("null")
Optional<ByteSize> getSocketReceiveBufferSizeHint();
}
Loading