container = props.getProperty(SWIFT_CONTAINER_PROPERTY);
String isPubProp = props.getProperty(SWIFT_PUBLIC_PROPERTY, "false");
usePublicURL = "true".equals(isPubProp);
if (apiKey == null && password == null) {
throw new SwiftConfigurationException(
"Configuration for " + filesystemURI +" must contain either "
+ SWIFT_PASSWORD_PROPERTY + " or "
+ SWIFT_APIKEY_PROPERTY);
}
//create the (reusable) authentication request
if (password != null) {
authRequest = new PasswordAuthenticationRequest(tenant,
new PasswordCredentials(
username,
password));
} else {
authRequest = new ApiKeyAuthenticationRequest(tenant,
new ApiKeyCredentials(
username, apiKey));
keystoneAuthRequest = new KeyStoneAuthRequest(tenant,
new KeystoneApiKeyCredentials(username, apiKey));
}
locationAware = "true".equals(
props.getProperty(SWIFT_LOCATION_AWARE_PROPERTY, "false"));
//now read in properties that are shared across all connections
//connection and retries
try {
retryCount = conf.getInt(SWIFT_RETRY_COUNT, DEFAULT_RETRY_COUNT);
connectTimeout = conf.getInt(SWIFT_CONNECTION_TIMEOUT,
DEFAULT_CONNECT_TIMEOUT);
socketTimeout = conf.getInt(SWIFT_SOCKET_TIMEOUT,
DEFAULT_SOCKET_TIMEOUT);
throttleDelay = conf.getInt(SWIFT_THROTTLE_DELAY,
DEFAULT_THROTTLE_DELAY);
//proxy options
proxyHost = conf.get(SWIFT_PROXY_HOST_PROPERTY);
proxyPort = conf.getInt(SWIFT_PROXY_PORT_PROPERTY, 8080);
blocksizeKB = conf.getInt(SWIFT_BLOCKSIZE,
DEFAULT_SWIFT_BLOCKSIZE);
if (blocksizeKB <= 0) {
throw new SwiftConfigurationException("Invalid blocksize set in "
+ SWIFT_BLOCKSIZE
+ ": " + blocksizeKB);
}
partSizeKB = conf.getInt(SWIFT_PARTITION_SIZE,
DEFAULT_SWIFT_PARTITION_SIZE);
if (partSizeKB <=0) {
throw new SwiftConfigurationException("Invalid partition size set in "
+ SWIFT_PARTITION_SIZE
+ ": " + partSizeKB);
}
bufferSizeKB = conf.getInt(SWIFT_REQUEST_SIZE,
DEFAULT_SWIFT_REQUEST_SIZE);
if (bufferSizeKB <=0) {
throw new SwiftConfigurationException("Invalid buffer size set in "
+ SWIFT_REQUEST_SIZE
+ ": " + bufferSizeKB);
}
} catch (NumberFormatException e) {
//convert exceptions raised parsing ints and longs into
// SwiftConfigurationException instances
throw new SwiftConfigurationException(e.toString(), e);
}
//everything you need for diagnostics. The password is omitted.
serviceDescription = String.format(
"Service={%s} container={%s} uri={%s}"
+ " tenant={%s} user={%s} region={%s}"
+ " publicURL={%b}"
+ " location aware={%b}"
+ " partition size={%d KB}, buffer size={%d KB}"
+ " block size={%d KB}"
+ " connect timeout={%d}, retry count={%d}"
+ " socket timeout={%d}"
+ " throttle delay={%d}"
,
serviceProvider,
container,
stringAuthUri,
tenant,
username,
region != null ? region : "(none)",
usePublicURL,
locationAware,
partSizeKB,
bufferSizeKB,
blocksizeKB,
connectTimeout,
retryCount,
socketTimeout,
throttleDelay
);
if (LOG.isDebugEnabled()) {
LOG.debug(serviceDescription);
}
try {
this.authUri = new URI(stringAuthUri);
} catch (URISyntaxException e) {
throw new SwiftConfigurationException("The " + SWIFT_AUTH_PROPERTY
+ " property was incorrect: "
+ stringAuthUri, e);
}
}