net.spy.memcached.vbucket
Class ConfigurationProviderHTTP

java.lang.Object
  extended by net.spy.memcached.compat.SpyObject
      extended by net.spy.memcached.vbucket.ConfigurationProviderHTTP
All Implemented Interfaces:
ConfigurationProvider

public class ConfigurationProviderHTTP
extends SpyObject
implements ConfigurationProvider


Field Summary
static String CLIENT_SPEC_VER
          The specification version which this client meets.
 
Constructor Summary
ConfigurationProviderHTTP(List<URI> baseList)
          Constructs a configuration provider with disabled authentication for the REST service
ConfigurationProviderHTTP(List<URI> baseList, String restUsr, String restPwd)
          Constructs a configuration provider with a given credentials for the REST service
 
Method Summary
protected static String buildAuthHeader(String username, String password)
          Oddly, lots of things that do HTTP seem to not know how to do this and Authenticator caches for the process.
 String getAnonymousAuthBucket()
          Retrieves a default bucket name i.e.
 Bucket getBucketConfiguration(String bucketname)
          Connects to the REST service and retrieves the bucket configuration from the first pool available
 Config getLatestConfig(String bucketname)
           
 List<InetSocketAddress> getServerList(String bucketname)
           
 void shutdown()
          Shutdowns a monitor connections to the REST service
 void subscribe(String bucketName, Reconfigurable rec)
          Subscribes for configuration updates
 void unsubscribe(String vbucketName, Reconfigurable rec)
          Unsubscribe from updates on a given bucket and given reconfigurable
 
Methods inherited from class net.spy.memcached.compat.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLIENT_SPEC_VER

public static final String CLIENT_SPEC_VER
The specification version which this client meets. This will be included in requests to the server.

See Also:
Constant Field Values
Constructor Detail

ConfigurationProviderHTTP

public ConfigurationProviderHTTP(List<URI> baseList)
                          throws IOException
Constructs a configuration provider with disabled authentication for the REST service

Parameters:
baseList - list of urls to treat as base
Throws:
IOException

ConfigurationProviderHTTP

public ConfigurationProviderHTTP(List<URI> baseList,
                                 String restUsr,
                                 String restPwd)
                          throws IOException
Constructs a configuration provider with a given credentials for the REST service

Parameters:
baseList - list of urls to treat as base
restUsr - username
restPwd - password
Throws:
IOException
Method Detail

getBucketConfiguration

public Bucket getBucketConfiguration(String bucketname)
                              throws ConfigurationException
Connects to the REST service and retrieves the bucket configuration from the first pool available

Specified by:
getBucketConfiguration in interface ConfigurationProvider
Parameters:
bucketname - bucketname
Returns:
vbucket configuration
Throws:
ConfigurationException

getServerList

public List<InetSocketAddress> getServerList(String bucketname)
                                      throws ConfigurationException
Throws:
ConfigurationException

subscribe

public void subscribe(String bucketName,
                      Reconfigurable rec)
               throws ConfigurationException
Subscribes for configuration updates

Specified by:
subscribe in interface ConfigurationProvider
Parameters:
bucketName - bucket name to receive configuration for
rec - reconfigurable that will receive updates
Throws:
ConfigurationException

unsubscribe

public void unsubscribe(String vbucketName,
                        Reconfigurable rec)
Unsubscribe from updates on a given bucket and given reconfigurable

Specified by:
unsubscribe in interface ConfigurationProvider
Parameters:
vbucketName - bucket name
rec - reconfigurable

getLatestConfig

public Config getLatestConfig(String bucketname)
                       throws ConfigurationException
Throws:
ConfigurationException

getAnonymousAuthBucket

public String getAnonymousAuthBucket()
Description copied from interface: ConfigurationProvider
Retrieves a default bucket name i.e. 'default'

Specified by:
getAnonymousAuthBucket in interface ConfigurationProvider
Returns:

shutdown

public void shutdown()
Shutdowns a monitor connections to the REST service

Specified by:
shutdown in interface ConfigurationProvider

buildAuthHeader

protected static String buildAuthHeader(String username,
                                        String password)
                                 throws UnsupportedEncodingException
Oddly, lots of things that do HTTP seem to not know how to do this and Authenticator caches for the process. Since we only need Basic at the moment simply, add the header.

Returns:
a value for an HTTP Basic Auth Header
Throws:
UnsupportedEncodingException