Class S3NioSpiConfiguration
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<java.lang.String,java.lang.Object>
-
- software.amazon.nio.spi.s3.config.S3NioSpiConfiguration
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.util.Map<java.lang.String,java.lang.Object>
public class S3NioSpiConfiguration extends java.util.HashMap<java.lang.String,java.lang.Object>Object to hold configuration of the S3 NIO SPI- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAWS_ACCESS_KEY_PROPERTYstatic java.lang.StringAWS_REGION_PROPERTYstatic java.lang.StringAWS_SECRET_ACCESS_KEY_PROPERTYstatic java.lang.StringS3_SPI_CREDENTIALS_PROPERTYThe default value of the credentials propertystatic java.lang.StringS3_SPI_ENDPOINT_DEFAULTThe default value of the endpoint propertystatic java.lang.StringS3_SPI_ENDPOINT_PROPERTYThe name of the endpoint propertystatic java.lang.StringS3_SPI_ENDPOINT_PROTOCOL_DEFAULTThe default value of the endpoint protocol propertystatic java.lang.StringS3_SPI_ENDPOINT_PROTOCOL_PROPERTYThe name of the endpoint protocol propertystatic booleanS3_SPI_FORCE_PATH_STYLE_DEFAULTThe default value of the force path style propertystatic java.lang.StringS3_SPI_FORCE_PATH_STYLE_PROPERTYThe name of the force path style propertystatic intS3_SPI_READ_MAX_FRAGMENT_NUMBER_DEFAULTThe default value of the maximum fragment size propertystatic java.lang.StringS3_SPI_READ_MAX_FRAGMENT_NUMBER_PROPERTYThe name of the maximum fragment number propertystatic intS3_SPI_READ_MAX_FRAGMENT_SIZE_DEFAULTThe default value of the maximum fragment size propertystatic java.lang.StringS3_SPI_READ_MAX_FRAGMENT_SIZE_PROPERTYThe name of the maximum fragment size propertystatic java.lang.LongS3_SPI_TIMEOUT_HIGH_DEFAULTThe default value of high timeout propertystatic java.lang.StringS3_SPI_TIMEOUT_HIGH_PROPERTYHigh timeout (in minutes) for Async APIsstatic java.lang.LongS3_SPI_TIMEOUT_LOW_DEFAULTThe default value of low timeout propertystatic java.lang.StringS3_SPI_TIMEOUT_LOW_PROPERTYLow timeout (in minutes) for Async APIsstatic java.lang.LongS3_SPI_TIMEOUT_MEDIUM_DEFAULTThe default value of medium timeout propertystatic java.lang.StringS3_SPI_TIMEOUT_MEDIUM_PROPERTYMedium timeout (in minutes) for Async APIs
-
Constructor Summary
Constructors Modifier Constructor Description S3NioSpiConfiguration()Create a new, empty configurationS3NioSpiConfiguration(java.util.Map<java.lang.String,?> overrides)Create a new, empty configurationprotectedS3NioSpiConfiguration(java.util.Properties overrides)Create a new configuration with overrides
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringconvertPropertyNameToEnvVar(java.lang.String propertyName)Generates an environment variable name from a property name.java.net.URIendpointUri()java.lang.StringgetBucketName()Get the configured bucket name if configuredsoftware.amazon.awssdk.auth.credentials.AwsCredentialsgetCredentials()Get the configured credentials.java.lang.StringgetEndpoint()Get the value of the endpoint.java.lang.StringgetEndpointProtocol()Get the value of the endpoint protocolbooleangetForcePathStyle()intgetMaxFragmentNumber()Get the value of the Maximum Fragment NumberintgetMaxFragmentSize()Get the value of the Maximum Fragment Sizejava.lang.StringgetRegion()Get the configured region if anyjava.lang.LonggetTimeoutHigh()Get the value of the Timeout Highjava.lang.LonggetTimeoutLow()Get the value of the Timeout Lowjava.lang.LonggetTimeoutMedium()Get the value of the Timeout MediumS3NioSpiConfigurationwithBucketName(java.lang.String bucketName)Fluently sets the value of bucketNameS3NioSpiConfigurationwithCredentials(java.lang.String accessKey, java.lang.String secretAccessKey)Fluently sets the value of accessKey and secretAccessKeyS3NioSpiConfigurationwithCredentials(software.amazon.awssdk.auth.credentials.AwsCredentials credentials)Fluently sets the value of accessKey and secretAccessKey given aAwsCredentialsobject.S3NioSpiConfigurationwithEndpoint(java.lang.String endpoint)Fluently sets the value of the endpointS3NioSpiConfigurationwithEndpointProtocol(java.lang.String protocol)Fluently sets the value of the endpoint's protocolS3NioSpiConfigurationwithForcePathStyle(java.lang.Boolean forcePathStyle)Fluently sets the value offorcePathStyleand addsS3_SPI_FORCE_PATH_STYLE_PROPERTYto the map unless the given value is null.S3NioSpiConfigurationwithMaxFragmentNumber(int maxFragmentNumber)Fluently sets the value of maximum fragment numberS3NioSpiConfigurationwithMaxFragmentSize(int maxFragmentSize)Fluently sets the value of maximum fragment sizeS3NioSpiConfigurationwithRegion(java.lang.String region)Fluently sets the value of the regionS3NioSpiConfigurationwithTimeoutHigh(java.lang.Long timeoutHigh)Fluently sets the value oftimeoutHighand addsS3_SPI_TIMEOUT_HIGH_PROPERTYto the map unless the given value is null.S3NioSpiConfigurationwithTimeoutLow(java.lang.Long timeoutLow)Fluently sets the value oftimeoutLowand addsS3_SPI_TIMEOUT_LOW_PROPERTYto the map unless the given value is null.S3NioSpiConfigurationwithTimeoutMedium(java.lang.Long timeoutMedium)Fluently sets the value oftimeoutMediumand addsS3_SPI_TIMEOUT_MEDIUM_PROPERTYto the map unless the given value is null.-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
-
-
-
Field Detail
-
AWS_REGION_PROPERTY
public static final java.lang.String AWS_REGION_PROPERTY
- See Also:
- Constant Field Values
-
AWS_ACCESS_KEY_PROPERTY
public static final java.lang.String AWS_ACCESS_KEY_PROPERTY
- See Also:
- Constant Field Values
-
AWS_SECRET_ACCESS_KEY_PROPERTY
public static final java.lang.String AWS_SECRET_ACCESS_KEY_PROPERTY
- See Also:
- Constant Field Values
-
S3_SPI_READ_MAX_FRAGMENT_SIZE_PROPERTY
public static final java.lang.String S3_SPI_READ_MAX_FRAGMENT_SIZE_PROPERTY
The name of the maximum fragment size property- See Also:
- Constant Field Values
-
S3_SPI_READ_MAX_FRAGMENT_SIZE_DEFAULT
public static final int S3_SPI_READ_MAX_FRAGMENT_SIZE_DEFAULT
The default value of the maximum fragment size property- See Also:
- Constant Field Values
-
S3_SPI_READ_MAX_FRAGMENT_NUMBER_PROPERTY
public static final java.lang.String S3_SPI_READ_MAX_FRAGMENT_NUMBER_PROPERTY
The name of the maximum fragment number property- See Also:
- Constant Field Values
-
S3_SPI_READ_MAX_FRAGMENT_NUMBER_DEFAULT
public static final int S3_SPI_READ_MAX_FRAGMENT_NUMBER_DEFAULT
The default value of the maximum fragment size property- See Also:
- Constant Field Values
-
S3_SPI_ENDPOINT_PROPERTY
public static final java.lang.String S3_SPI_ENDPOINT_PROPERTY
The name of the endpoint property- See Also:
- Constant Field Values
-
S3_SPI_ENDPOINT_DEFAULT
public static final java.lang.String S3_SPI_ENDPOINT_DEFAULT
The default value of the endpoint property- See Also:
- Constant Field Values
-
S3_SPI_ENDPOINT_PROTOCOL_PROPERTY
public static final java.lang.String S3_SPI_ENDPOINT_PROTOCOL_PROPERTY
The name of the endpoint protocol property- See Also:
- Constant Field Values
-
S3_SPI_ENDPOINT_PROTOCOL_DEFAULT
public static final java.lang.String S3_SPI_ENDPOINT_PROTOCOL_DEFAULT
The default value of the endpoint protocol property- See Also:
- Constant Field Values
-
S3_SPI_FORCE_PATH_STYLE_PROPERTY
public static final java.lang.String S3_SPI_FORCE_PATH_STYLE_PROPERTY
The name of the force path style property- See Also:
- Constant Field Values
-
S3_SPI_FORCE_PATH_STYLE_DEFAULT
public static final boolean S3_SPI_FORCE_PATH_STYLE_DEFAULT
The default value of the force path style property- See Also:
- Constant Field Values
-
S3_SPI_TIMEOUT_LOW_PROPERTY
public static final java.lang.String S3_SPI_TIMEOUT_LOW_PROPERTY
Low timeout (in minutes) for Async APIs- See Also:
- Constant Field Values
-
S3_SPI_TIMEOUT_LOW_DEFAULT
public static final java.lang.Long S3_SPI_TIMEOUT_LOW_DEFAULT
The default value of low timeout property
-
S3_SPI_TIMEOUT_MEDIUM_PROPERTY
public static final java.lang.String S3_SPI_TIMEOUT_MEDIUM_PROPERTY
Medium timeout (in minutes) for Async APIs- See Also:
- Constant Field Values
-
S3_SPI_TIMEOUT_MEDIUM_DEFAULT
public static final java.lang.Long S3_SPI_TIMEOUT_MEDIUM_DEFAULT
The default value of medium timeout property
-
S3_SPI_TIMEOUT_HIGH_PROPERTY
public static final java.lang.String S3_SPI_TIMEOUT_HIGH_PROPERTY
High timeout (in minutes) for Async APIs- See Also:
- Constant Field Values
-
S3_SPI_TIMEOUT_HIGH_DEFAULT
public static final java.lang.Long S3_SPI_TIMEOUT_HIGH_DEFAULT
The default value of high timeout property
-
S3_SPI_CREDENTIALS_PROPERTY
public static final java.lang.String S3_SPI_CREDENTIALS_PROPERTY
The default value of the credentials property- See Also:
- Constant Field Values
-
-
Constructor Detail
-
S3NioSpiConfiguration
public S3NioSpiConfiguration()
Create a new, empty configuration
-
S3NioSpiConfiguration
public S3NioSpiConfiguration(java.util.Map<java.lang.String,?> overrides)
Create a new, empty configuration- Parameters:
overrides- configuration to override default values
-
S3NioSpiConfiguration
protected S3NioSpiConfiguration(java.util.Properties overrides)
Create a new configuration with overrides- Parameters:
overrides- the overrides
-
-
Method Detail
-
withMaxFragmentNumber
public S3NioSpiConfiguration withMaxFragmentNumber(int maxFragmentNumber)
Fluently sets the value of maximum fragment number- Parameters:
maxFragmentNumber- the maximum fragment number- Returns:
- this instance
-
withMaxFragmentSize
public S3NioSpiConfiguration withMaxFragmentSize(int maxFragmentSize)
Fluently sets the value of maximum fragment size- Parameters:
maxFragmentSize- the maximum fragment size- Returns:
- this instance
-
withEndpoint
public S3NioSpiConfiguration withEndpoint(java.lang.String endpoint)
Fluently sets the value of the endpoint- Parameters:
endpoint- the endpoint- Returns:
- this instance
-
withEndpointProtocol
public S3NioSpiConfiguration withEndpointProtocol(java.lang.String protocol)
Fluently sets the value of the endpoint's protocol- Parameters:
protocol- the endpoint's protcol- Returns:
- this instance
-
withRegion
public S3NioSpiConfiguration withRegion(java.lang.String region)
Fluently sets the value of the region- Parameters:
region- the region; if null or blank the property is removed- Returns:
- this instance
-
withBucketName
public S3NioSpiConfiguration withBucketName(java.lang.String bucketName)
Fluently sets the value of bucketName- Parameters:
bucketName- the bucket name- Returns:
- this instance
- Throws:
java.lang.IllegalArgumentException- if bucketName is not compliant with https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html
-
withCredentials
public S3NioSpiConfiguration withCredentials(java.lang.String accessKey, java.lang.String secretAccessKey)
Fluently sets the value of accessKey and secretAccessKey- Parameters:
accessKey- the accesskey; if null, credentials are removedsecretAccessKey- the secretAccesskey; if accessKey is not null, it can not be null- Returns:
- this instance
-
withCredentials
public S3NioSpiConfiguration withCredentials(software.amazon.awssdk.auth.credentials.AwsCredentials credentials)
Fluently sets the value of accessKey and secretAccessKey given aAwsCredentialsobject.- Parameters:
credentials- the credentials; if null, credentials are removed- Returns:
- this instance
-
withForcePathStyle
public S3NioSpiConfiguration withForcePathStyle(java.lang.Boolean forcePathStyle)
Fluently sets the value offorcePathStyleand addsS3_SPI_FORCE_PATH_STYLE_PROPERTYto the map unless the given value is null. If null,S3_SPI_FORCE_PATH_STYLE_PROPERTYis removed from the map.- Parameters:
forcePathStyle- the new value; can be null- Returns:
- this instance
-
withTimeoutLow
public S3NioSpiConfiguration withTimeoutLow(java.lang.Long timeoutLow)
Fluently sets the value oftimeoutLowand addsS3_SPI_TIMEOUT_LOW_PROPERTYto the map unless the given value is null. If null,S3_SPI_TIMEOUT_LOW_PROPERTYtakes default value of 1.- Parameters:
timeoutLow- the new value; can be null- Returns:
- this instance
-
withTimeoutMedium
public S3NioSpiConfiguration withTimeoutMedium(java.lang.Long timeoutMedium)
Fluently sets the value oftimeoutMediumand addsS3_SPI_TIMEOUT_MEDIUM_PROPERTYto the map unless the given value is null. If null,S3_SPI_TIMEOUT_MEDIUM_PROPERTYtakes default value of 3.- Parameters:
timeoutMedium- the new value; can be null- Returns:
- this instance
-
withTimeoutHigh
public S3NioSpiConfiguration withTimeoutHigh(java.lang.Long timeoutHigh)
Fluently sets the value oftimeoutHighand addsS3_SPI_TIMEOUT_HIGH_PROPERTYto the map unless the given value is null. If null,S3_SPI_TIMEOUT_HIGH_PROPERTYholds default value of 5.- Parameters:
timeoutHigh- the new value; can be null- Returns:
- this instance
-
getMaxFragmentSize
public int getMaxFragmentSize()
Get the value of the Maximum Fragment Size- Returns:
- the configured value or the default if not overridden
-
getMaxFragmentNumber
public int getMaxFragmentNumber()
Get the value of the Maximum Fragment Number- Returns:
- the configured value or the default if not overridden
-
getEndpoint
public java.lang.String getEndpoint()
Get the value of the endpoint. Not that no endvar/sysprop is taken as default.- Returns:
- the configured value or the default ("") if not overridden
-
getEndpointProtocol
public java.lang.String getEndpointProtocol()
Get the value of the endpoint protocol- Returns:
- the configured value or the default if not overridden
-
getCredentials
public software.amazon.awssdk.auth.credentials.AwsCredentials getCredentials()
Get the configured credentials. Note that credentials can be provided in two ways:1.
withCredentials(String accessKey, String secretAcccessKey)2.withCredentials(AwsCredentials credentials)The latter takes the priority, so if both are used,
getCredentials()returns the most complete object, which is the value of the propertyS3_SPI_CREDENTIALS_PROPERTY- Returns:
- the configured value or null if not provided
-
getRegion
public java.lang.String getRegion()
Get the configured region if any- Returns:
- the configured value or null if not provided
-
getBucketName
public java.lang.String getBucketName()
Get the configured bucket name if configured- Returns:
- the configured value or null if not provided
-
getForcePathStyle
public boolean getForcePathStyle()
-
getTimeoutLow
public java.lang.Long getTimeoutLow()
Get the value of the Timeout Low- Returns:
- the configured value or the default if not overridden
-
getTimeoutMedium
public java.lang.Long getTimeoutMedium()
Get the value of the Timeout Medium- Returns:
- the configured value or the default if not overridden
-
getTimeoutHigh
public java.lang.Long getTimeoutHigh()
Get the value of the Timeout High- Returns:
- the configured value or the default if not overridden
-
convertPropertyNameToEnvVar
protected java.lang.String convertPropertyNameToEnvVar(java.lang.String propertyName)
Generates an environment variable name from a property name. E.g 'some.property' becomes 'SOME_PROPERTY'- Parameters:
propertyName- the name to convert- Returns:
- the converted name
-
endpointUri
public java.net.URI endpointUri()
-
-