com.basho.riak.client
Class RiakFactory

java.lang.Object
  extended by com.basho.riak.client.RiakFactory

public class RiakFactory
extends Object

A factory for getting an IRiakClient implementation wrapping the RawClient of your choice.

Use the newClient method, passing an implementation of Configuration. The factory will look up a RiakClientFactory implementation and pass your Configuration to it.

For example:

 Configuration conf = new PBClientConfig.Builder().withHost("my-riak-host.com").withPort(9000).build();
 IRiakClient client = RiakFactory.newClient(conf);
 

Also provides convenience methods for grabbing a default configuration pb or http client.

Author:
russell
See Also:
Configuration, ClusterConfig

Constructor Summary
RiakFactory()
           
 
Method Summary
static IRiakClient httpClient()
          Wraps a HTTPClientAdapter connecting to 127.0.0.1:8098/riak in a DefaultRiakClient
static IRiakClient httpClient(RiakClient delegate)
          Wraps the given RiakClient in a DefaultRiakClient
static IRiakClient httpClient(String url)
          Wraps a HTTPClientAdapter connecting to the given url in a DefaultRiakClient
static IRiakClient newClient(Configuration config)
          Uses the given config to generate an IRiakClient instance.
static IRiakClient pbcClient()
          Wraps a PBClientAdapter connected to 127.0.0.1:8087 in a DefaultRiakClient.
static IRiakClient pbcClient(RiakClient delegate)
          Wraps the given RiakClient client in a DefaultRiakClient.
static IRiakClient pbcClient(String host, int port)
          Wraps a PBClientAdapter connected to host and port in a DefaultRiakClient.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RiakFactory

public RiakFactory()
Method Detail

pbcClient

public static IRiakClient pbcClient()
                             throws RiakException
Wraps a PBClientAdapter connected to 127.0.0.1:8087 in a DefaultRiakClient.

Returns:
a default configuration PBC client
Throws:
RiakException

pbcClient

public static IRiakClient pbcClient(String host,
                                    int port)
                             throws RiakException
Wraps a PBClientAdapter connected to host and port in a DefaultRiakClient.

Returns:
a default configuration PBC client
Throws:
RiakException

pbcClient

public static IRiakClient pbcClient(RiakClient delegate)
Wraps the given RiakClient client in a DefaultRiakClient.

Parameters:
delegate - the pbc.RiakClient to wrap.
Returns:
a DefaultRiakClient that delegates to delegate

httpClient

public static IRiakClient httpClient()
                              throws RiakException
Wraps a HTTPClientAdapter connecting to 127.0.0.1:8098/riak in a DefaultRiakClient

Returns:
a default configuration DefaultRiakClient delegating to the HTTP client
Throws:
RiakException

httpClient

public static IRiakClient httpClient(String url)
                              throws RiakException
Wraps a HTTPClientAdapter connecting to the given url in a DefaultRiakClient

Parameters:
url - a String of the url for Riak's REST iterface
Returns:
a default configuration DefaultRiakClient delegating to the HTTP client
Throws:
RiakException

httpClient

public static IRiakClient httpClient(RiakClient delegate)
                              throws RiakException
Wraps the given RiakClient in a DefaultRiakClient

Parameters:
delegate - the http.RiakClient to wrap.
Returns:
a DefaultRiakClient that delegates to delegate
Throws:
RiakException

newClient

public static IRiakClient newClient(Configuration config)
                             throws RiakException
Uses the given config to generate an IRiakClient instance. See the available Configuration implementations for details.

Parameters:
config - a concrete implementation of Configuration
Returns:
an IRiakClient that delegates to a RawClient configured by config
Throws:
IOException
NoFactoryForConfigException - if the Configuration type is not recognized
IllegalArgumentException - if config is null
RiakException
See Also:
HTTPClientConfig, PBClientConfig, ClusterConfig


Copyright © 2012. All Rights Reserved.