public final class RestClientBindings extends Object
The swift rest client takes a Properties instance containing the string values it uses to bind to a swift endpoint.
This class extracts the values for a specific filesystem endpoint and then builds an appropriate Properties file.
Modifier and Type | Field and Description |
---|---|
static String |
E_INVALID_NAME |
Constructor and Description |
---|
RestClientBindings() |
Modifier and Type | Method and Description |
---|---|
static Properties |
bind(URI fsURI,
org.apache.hadoop.conf.Configuration conf)
Build a properties instance bound to the configuration file -using
the filesystem URI as the source of the information.
|
static String |
buildSwiftInstancePrefix(String service)
Public for testing : build the full prefix for use in resolving
configuration items
|
static void |
copy(org.apache.hadoop.conf.Configuration conf,
String confKey,
Properties props,
String propsKey,
boolean required)
Copy a (trimmed) property from the configuration file to the properties file.
|
static String |
extractContainerName(String hostname)
Get the container name from the hostname -the single element before the
first "." in the hostname
|
static String |
extractContainerName(URI uri) |
static String |
extractServiceName(String hostname)
Get the service name from a longer hostname string
|
static String |
extractServiceName(URI uri) |
public static final String E_INVALID_NAME
public static String buildSwiftInstancePrefix(String service)
service
- service to usepublic static String extractContainerName(String hostname) throws SwiftConfigurationException
hostname
- hostname to splitSwiftConfigurationException
public static String extractContainerName(URI uri) throws SwiftConfigurationException
SwiftConfigurationException
public static String extractServiceName(String hostname) throws SwiftConfigurationException
hostname
- hostnameSwiftConfigurationException
- if the hostname was invalidpublic static String extractServiceName(URI uri) throws SwiftConfigurationException
SwiftConfigurationException
public static Properties bind(URI fsURI, org.apache.hadoop.conf.Configuration conf) throws SwiftConfigurationException
fsURI
- filesystem URIconf
- configurationSwiftConfigurationException
- if the configuration is invalidpublic static void copy(org.apache.hadoop.conf.Configuration conf, String confKey, Properties props, String propsKey, boolean required) throws SwiftConfigurationException
If marked as required and not found in the configuration, an exception is raised. If not required -and missing- then the property will not be set. In this case, if the property is already in the Properties instance, it will remain untouched.
conf
- source configurationconfKey
- key in the configuration fileprops
- destination property setpropsKey
- key in the property setrequired
- is the property requiredSwiftConfigurationException
- if the property is required but was
not found in the configuration instance.Copyright © 2017 Apache Software Foundation. All Rights Reserved.