-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added empty-stream struct replication
- Loading branch information
Showing
26 changed files
with
338 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 0 additions & 72 deletions
72
connectors/riot-file/src/main/java/com/redis/riot/file/AmazonS3Args.java
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
connectors/riot-file/src/main/java/com/redis/riot/file/AmazonS3ProtocolResolver.java
This file was deleted.
Oops, something went wrong.
87 changes: 87 additions & 0 deletions
87
connectors/riot-file/src/main/java/com/redis/riot/file/AwsArgs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.redis.riot.file; | ||
|
||
import java.net.URI; | ||
|
||
import org.springframework.core.io.Resource; | ||
import org.springframework.util.Assert; | ||
import org.springframework.util.StringUtils; | ||
|
||
import io.awspring.cloud.s3.InMemoryBufferingS3OutputStreamProvider; | ||
import io.awspring.cloud.s3.Location; | ||
import io.awspring.cloud.s3.PropertiesS3ObjectContentTypeResolver; | ||
import io.awspring.cloud.s3.S3Resource; | ||
import picocli.CommandLine.ArgGroup; | ||
import picocli.CommandLine.Option; | ||
import software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider; | ||
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; | ||
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider; | ||
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; | ||
import software.amazon.awssdk.regions.Region; | ||
import software.amazon.awssdk.services.s3.S3Client; | ||
import software.amazon.awssdk.services.s3.S3ClientBuilder; | ||
|
||
public class AwsArgs { | ||
|
||
@ArgGroup(exclusive = false) | ||
private AwsCredentialsArgs credentialsArgs; | ||
|
||
@Option(names = "--s3-region", description = "Region to use for the AWS client (e.g. us-west-1).", paramLabel = "<name>") | ||
private Region region; | ||
|
||
@Option(names = "--s3-endpoint", description = "Service endpoint with which the AWS client should communicate (e.g. https://sns.us-west-1.amazonaws.com).", paramLabel = "<url>") | ||
private URI endpoint; | ||
|
||
public static boolean isSimpleStorageResource(String location) { | ||
Assert.notNull(location, "Location must not be null"); | ||
return location.toLowerCase().startsWith(Location.S3_PROTOCOL_PREFIX); | ||
} | ||
|
||
public Resource resource(String location) { | ||
S3ClientBuilder clientBuilder = S3Client.builder(); | ||
if (region != null) { | ||
clientBuilder.region(region); | ||
} | ||
if (endpoint != null) { | ||
clientBuilder.endpointOverride(endpoint); | ||
} | ||
clientBuilder.credentialsProvider(credentialsProvider()); | ||
S3Client client = clientBuilder.build(); | ||
InMemoryBufferingS3OutputStreamProvider outputStreamProvider = new InMemoryBufferingS3OutputStreamProvider( | ||
client, new PropertiesS3ObjectContentTypeResolver()); | ||
return S3Resource.create(location, client, outputStreamProvider); | ||
} | ||
|
||
private AwsCredentialsProvider credentialsProvider() { | ||
if (credentialsArgs != null && StringUtils.hasText(credentialsArgs.getAccessKey()) | ||
&& StringUtils.hasText(credentialsArgs.getSecretKey())) { | ||
AwsBasicCredentials credentials = AwsBasicCredentials.create(credentialsArgs.getAccessKey(), | ||
credentialsArgs.getSecretKey()); | ||
return StaticCredentialsProvider.create(credentials); | ||
} | ||
return AnonymousCredentialsProvider.create(); | ||
} | ||
|
||
public AwsCredentialsArgs getCredentialsArgs() { | ||
return credentialsArgs; | ||
} | ||
|
||
public void setCredentialsArgs(AwsCredentialsArgs args) { | ||
this.credentialsArgs = args; | ||
} | ||
|
||
public Region getRegion() { | ||
return region; | ||
} | ||
|
||
public void setRegion(Region region) { | ||
this.region = region; | ||
} | ||
|
||
public URI getEndpoint() { | ||
return endpoint; | ||
} | ||
|
||
public void setEndpoint(URI endpoint) { | ||
this.endpoint = endpoint; | ||
} | ||
} |
11 changes: 1 addition & 10 deletions
11
...is/riot/file/AmazonS3CredentialsArgs.java → ...m/redis/riot/file/AwsCredentialsArgs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.