Skip to content

Commit

Permalink
Merge branch 'release/1.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jarnaiz committed May 28, 2016
2 parents 6ecd2b5 + a88bd78 commit 05fe4eb
Show file tree
Hide file tree
Showing 51 changed files with 6,682 additions and 6,347 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ before_script:
- chmod a+x ./print_surefire_reports.sh
script: mvn clean install
after_success:
- mvn jacoco:report coveralls:jacoco
- mvn jacoco:report coveralls:report
after_failure: ./print_surefire_reports.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This project provides a first API implementation, little optimized, but "complet
<dependency>
<groupId>com.upplication</groupId>
<artifactId>s3fs</artifactId>
<version>1.2.3</version>
<version>1.3.0</version>
</dependency>
```

Expand Down
103 changes: 56 additions & 47 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.upplication</groupId>
<artifactId>s3fs</artifactId>
<packaging>jar</packaging>
<version>1.2.3</version>
<version>1.3.0</version>
<name>s3fs</name>
<description>S3 filesystem provider for Java 7</description>
<url>https://github.com/Upplication/Amazon-S3-FileSystem-NIO2</url>
Expand Down Expand Up @@ -216,69 +216,78 @@
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven.surfire.plugin.version}</version>
<configuration>
<includes>
<include>**/*IT.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<phase>verify</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>travis</id>
<activation>
<property>
<name>env.TRAVIS</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>${jacoco.agent.arg}</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.7.1</version>
<configuration>
<includes>
<include>**/*IT.java</include>
</includes>
<argLine>${jacoco.agent.arg}</argLine>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<phase>verify</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>2.2.0</version>
<version>4.1.0</version>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.4.201312101107</version>
<version>0.7.6.201602180812</version>

<executions>
<!-- Prepare execution with Surefire -->
<execution>
<id>prepare-agent</id>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>jacoco.agent.arg</propertyName>
<append>true</append>
</configuration>
</execution>
<!-- Generate report after tests are run -->
<execution>
<id>post-unit-test</id>
<phase>integration-test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>


</build>
</profile>
<profile>
<id>release-sign-artifacts</id>

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/upplication/s3fs/AmazonS3ClientFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import com.amazonaws.services.s3.AmazonS3Client;

public class AmazonS3ClientFactory extends AmazonS3Factory {
@Override
protected AmazonS3Client createAmazonS3(AWSCredentialsProvider credentialsProvider, ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricsCollector) {
return new AmazonS3Client(credentialsProvider, clientConfiguration, requestMetricsCollector);
}
@Override
protected AmazonS3Client createAmazonS3(AWSCredentialsProvider credentialsProvider, ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricsCollector) {
return new AmazonS3Client(credentialsProvider, clientConfiguration, requestMetricsCollector);
}
}
169 changes: 85 additions & 84 deletions src/main/java/com/upplication/s3fs/AmazonS3Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,100 +20,101 @@
*/
public abstract class AmazonS3Factory {

public static final String ACCESS_KEY = "s3fs_access_key";
public static final String SECRET_KEY = "s3fs_secret_key";
public static final String REQUEST_METRIC_COLLECTOR_CLASS = "s3fs_request_metric_collector_class";
public static final String CONNECTION_TIMEOUT = "s3fs_connection_timeout";
public static final String MAX_CONNECTIONS = "s3fs_max_connections";
public static final String MAX_ERROR_RETRY = "s3fs_max_retry_error";
public static final String PROTOCOL = "s3fs_protocol";
public static final String PROXY_DOMAIN = "s3fs_proxy_domain";
public static final String PROXY_HOST = "s3fs_proxy_host";
public static final String PROXY_PASSWORD = "s3fs_proxy_password";
public static final String PROXY_PORT = "s3fs_proxy_port";
public static final String PROXY_USERNAME = "s3fs_proxy_username";
public static final String PROXY_WORKSTATION = "s3fs_proxy_workstation";
public static final String SOCKET_SEND_BUFFER_SIZE_HINT = "s3fs_socket_send_buffer_size_hint";
public static final String SOCKET_RECEIVE_BUFFER_SIZE_HINT = "s3fs_socket_receive_buffer_size_hint";
public static final String SOCKET_TIMEOUT = "s3fs_socket_timeout";
public static final String USER_AGENT = "s3fs_user_agent";
public static final String ACCESS_KEY = "s3fs_access_key";
public static final String SECRET_KEY = "s3fs_secret_key";
public static final String REQUEST_METRIC_COLLECTOR_CLASS = "s3fs_request_metric_collector_class";
public static final String CONNECTION_TIMEOUT = "s3fs_connection_timeout";
public static final String MAX_CONNECTIONS = "s3fs_max_connections";
public static final String MAX_ERROR_RETRY = "s3fs_max_retry_error";
public static final String PROTOCOL = "s3fs_protocol";
public static final String PROXY_DOMAIN = "s3fs_proxy_domain";
public static final String PROXY_HOST = "s3fs_proxy_host";
public static final String PROXY_PASSWORD = "s3fs_proxy_password";
public static final String PROXY_PORT = "s3fs_proxy_port";
public static final String PROXY_USERNAME = "s3fs_proxy_username";
public static final String PROXY_WORKSTATION = "s3fs_proxy_workstation";
public static final String SOCKET_SEND_BUFFER_SIZE_HINT = "s3fs_socket_send_buffer_size_hint";
public static final String SOCKET_RECEIVE_BUFFER_SIZE_HINT = "s3fs_socket_receive_buffer_size_hint";
public static final String SOCKET_TIMEOUT = "s3fs_socket_timeout";
public static final String USER_AGENT = "s3fs_user_agent";

protected Logger logger = LoggerFactory.getLogger(getClass());
protected Logger logger = LoggerFactory.getLogger(getClass());

/**
* should return a new AmazonS3
* @param credentialsProvider AWSCredentialsProvider mandatory
* @param clientConfiguration ClientConfiguration mandatory
*
* @param credentialsProvider AWSCredentialsProvider mandatory
* @param clientConfiguration ClientConfiguration mandatory
* @param requestMetricsCollector RequestMetricCollector mandatory
* @return {@link com.amazonaws.services.s3.AmazonS3}
*/
protected abstract AmazonS3 createAmazonS3(AWSCredentialsProvider credentialsProvider, ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricsCollector);
protected abstract AmazonS3 createAmazonS3(AWSCredentialsProvider credentialsProvider, ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricsCollector);

public AmazonS3 getAmazonS3(URI uri, Properties props) {
AmazonS3 client = createAmazonS3(getCredentialsProvider(props), getClientConfiguration(props), getRequestMetricsCollector(props));
if (uri.getHost() != null)
client.setEndpoint(uri.getHost());
return client;
}
public AmazonS3 getAmazonS3(URI uri, Properties props) {
AmazonS3 client = createAmazonS3(getCredentialsProvider(props), getClientConfiguration(props), getRequestMetricsCollector(props));
if (uri.getHost() != null)
client.setEndpoint(uri.getHost());
return client;
}

protected AWSCredentialsProvider getCredentialsProvider(Properties props) {
AWSCredentialsProvider credentialsProvider;
if (props.getProperty(ACCESS_KEY) == null && props.getProperty(SECRET_KEY) == null)
credentialsProvider = new DefaultAWSCredentialsProviderChain();
else
credentialsProvider = new StaticCredentialsProvider(getAWSCredentials(props));
return credentialsProvider;
}
protected AWSCredentialsProvider getCredentialsProvider(Properties props) {
AWSCredentialsProvider credentialsProvider;
if (props.getProperty(ACCESS_KEY) == null && props.getProperty(SECRET_KEY) == null)
credentialsProvider = new DefaultAWSCredentialsProviderChain();
else
credentialsProvider = new StaticCredentialsProvider(getAWSCredentials(props));
return credentialsProvider;
}

protected RequestMetricCollector getRequestMetricsCollector(Properties props) {
RequestMetricCollector requestMetricCollector = null;
if (props.containsKey(REQUEST_METRIC_COLLECTOR_CLASS)) {
try {
requestMetricCollector = (RequestMetricCollector) Class.forName(props.getProperty(REQUEST_METRIC_COLLECTOR_CLASS)).newInstance();
} catch (Throwable t) {
throw new IllegalArgumentException("Can't instantiate REQUEST_METRIC_COLLECTOR_CLASS " + props.getProperty(REQUEST_METRIC_COLLECTOR_CLASS), t);
}
}
return requestMetricCollector;
}
protected RequestMetricCollector getRequestMetricsCollector(Properties props) {
RequestMetricCollector requestMetricCollector = null;
if (props.containsKey(REQUEST_METRIC_COLLECTOR_CLASS)) {
try {
requestMetricCollector = (RequestMetricCollector) Class.forName(props.getProperty(REQUEST_METRIC_COLLECTOR_CLASS)).newInstance();
} catch (Throwable t) {
throw new IllegalArgumentException("Can't instantiate REQUEST_METRIC_COLLECTOR_CLASS " + props.getProperty(REQUEST_METRIC_COLLECTOR_CLASS), t);
}
}
return requestMetricCollector;
}

protected ClientConfiguration getClientConfiguration(Properties props) {
ClientConfiguration clientConfiguration = new ClientConfiguration();
if (props.getProperty(CONNECTION_TIMEOUT) != null)
clientConfiguration.setConnectionTimeout(Integer.parseInt(props.getProperty(CONNECTION_TIMEOUT)));
if (props.getProperty(MAX_CONNECTIONS) != null)
clientConfiguration.setMaxConnections(Integer.parseInt(props.getProperty(MAX_CONNECTIONS)));
if (props.getProperty(MAX_ERROR_RETRY) != null)
clientConfiguration.setMaxErrorRetry(Integer.parseInt(props.getProperty(MAX_ERROR_RETRY)));
if (props.getProperty(PROTOCOL) != null)
clientConfiguration.setProtocol(Protocol.valueOf(props.getProperty(PROTOCOL)));
if (props.getProperty(PROXY_DOMAIN) != null)
clientConfiguration.setProxyDomain(props.getProperty(PROXY_DOMAIN));
if (props.getProperty(PROXY_HOST) != null)
clientConfiguration.setProxyHost(props.getProperty(PROXY_HOST));
if (props.getProperty(PROXY_PASSWORD) != null)
clientConfiguration.setProxyPassword(props.getProperty(PROXY_PASSWORD));
if (props.getProperty(PROXY_PORT) != null)
clientConfiguration.setProxyPort(Integer.parseInt(props.getProperty(PROXY_PORT)));
if (props.getProperty(PROXY_USERNAME) != null)
clientConfiguration.setProxyUsername(props.getProperty(PROXY_USERNAME));
if (props.getProperty(PROXY_WORKSTATION) != null)
clientConfiguration.setProxyWorkstation(props.getProperty(PROXY_WORKSTATION));
int socketSendBufferSizeHint = 0;
if (props.getProperty(SOCKET_SEND_BUFFER_SIZE_HINT) != null)
socketSendBufferSizeHint = Integer.parseInt(props.getProperty(SOCKET_SEND_BUFFER_SIZE_HINT));
int socketReceiveBufferSizeHint = 0;
if (props.getProperty(SOCKET_RECEIVE_BUFFER_SIZE_HINT) != null)
socketReceiveBufferSizeHint = Integer.parseInt(props.getProperty(SOCKET_RECEIVE_BUFFER_SIZE_HINT));
clientConfiguration.setSocketBufferSizeHints(socketSendBufferSizeHint, socketReceiveBufferSizeHint);
if (props.getProperty(SOCKET_TIMEOUT) != null)
clientConfiguration.setSocketTimeout(Integer.parseInt(props.getProperty(SOCKET_TIMEOUT)));
if (props.getProperty(USER_AGENT) != null)
clientConfiguration.setUserAgent(props.getProperty(USER_AGENT));
return clientConfiguration;
}
protected ClientConfiguration getClientConfiguration(Properties props) {
ClientConfiguration clientConfiguration = new ClientConfiguration();
if (props.getProperty(CONNECTION_TIMEOUT) != null)
clientConfiguration.setConnectionTimeout(Integer.parseInt(props.getProperty(CONNECTION_TIMEOUT)));
if (props.getProperty(MAX_CONNECTIONS) != null)
clientConfiguration.setMaxConnections(Integer.parseInt(props.getProperty(MAX_CONNECTIONS)));
if (props.getProperty(MAX_ERROR_RETRY) != null)
clientConfiguration.setMaxErrorRetry(Integer.parseInt(props.getProperty(MAX_ERROR_RETRY)));
if (props.getProperty(PROTOCOL) != null)
clientConfiguration.setProtocol(Protocol.valueOf(props.getProperty(PROTOCOL)));
if (props.getProperty(PROXY_DOMAIN) != null)
clientConfiguration.setProxyDomain(props.getProperty(PROXY_DOMAIN));
if (props.getProperty(PROXY_HOST) != null)
clientConfiguration.setProxyHost(props.getProperty(PROXY_HOST));
if (props.getProperty(PROXY_PASSWORD) != null)
clientConfiguration.setProxyPassword(props.getProperty(PROXY_PASSWORD));
if (props.getProperty(PROXY_PORT) != null)
clientConfiguration.setProxyPort(Integer.parseInt(props.getProperty(PROXY_PORT)));
if (props.getProperty(PROXY_USERNAME) != null)
clientConfiguration.setProxyUsername(props.getProperty(PROXY_USERNAME));
if (props.getProperty(PROXY_WORKSTATION) != null)
clientConfiguration.setProxyWorkstation(props.getProperty(PROXY_WORKSTATION));
int socketSendBufferSizeHint = 0;
if (props.getProperty(SOCKET_SEND_BUFFER_SIZE_HINT) != null)
socketSendBufferSizeHint = Integer.parseInt(props.getProperty(SOCKET_SEND_BUFFER_SIZE_HINT));
int socketReceiveBufferSizeHint = 0;
if (props.getProperty(SOCKET_RECEIVE_BUFFER_SIZE_HINT) != null)
socketReceiveBufferSizeHint = Integer.parseInt(props.getProperty(SOCKET_RECEIVE_BUFFER_SIZE_HINT));
clientConfiguration.setSocketBufferSizeHints(socketSendBufferSizeHint, socketReceiveBufferSizeHint);
if (props.getProperty(SOCKET_TIMEOUT) != null)
clientConfiguration.setSocketTimeout(Integer.parseInt(props.getProperty(SOCKET_TIMEOUT)));
if (props.getProperty(USER_AGENT) != null)
clientConfiguration.setUserAgent(props.getProperty(USER_AGENT));
return clientConfiguration;
}

protected BasicAWSCredentials getAWSCredentials(Properties props) {
return new BasicAWSCredentials(props.getProperty(ACCESS_KEY), props.getProperty(SECRET_KEY));
}
protected BasicAWSCredentials getAWSCredentials(Properties props) {
return new BasicAWSCredentials(props.getProperty(ACCESS_KEY), props.getProperty(SECRET_KEY));
}
}
Loading

0 comments on commit 05fe4eb

Please sign in to comment.