Search in sources :

Example 1 with RiakClient

use of com.basho.riak.client.api.RiakClient in project YCSB by brianfrankcooper.

the class RiakKVClient method init.

public void init() throws DBException {
    loadProperties();
    RiakNode.Builder builder = new RiakNode.Builder().withRemotePort(port);
    List<RiakNode> nodes = RiakNode.Builder.buildNodes(builder, Arrays.asList(hosts));
    riakCluster = new RiakCluster.Builder(nodes).build();
    try {
        riakCluster.start();
        riakClient = new RiakClient(riakCluster);
    } catch (Exception e) {
        System.err.println("Unable to properly start up the cluster. Reason: " + e.toString());
        throw new DBException(e);
    }
    // If strong consistency is in use, we need to change the bucket-type where the 2i indexes will be stored.
    if (strongConsistency && !strongConsistentScansBucketType.isEmpty()) {
        // The 2i indexes have to be stored in the appositely created strongConsistentScansBucketType: this however has
        // to be done only if the user actually created it! So, if the latter doesn't exist, then the scan transactions
        // will not be performed at all.
        bucketType2i = strongConsistentScansBucketType;
        performStrongConsistentScans = true;
    } else {
        // If instead eventual consistency is in use, then the 2i indexes have to be stored in the bucket-type
        // indicated with the bucketType variable.
        bucketType2i = bucketType;
        performStrongConsistentScans = false;
    }
    if (debug) {
        System.err.println("DEBUG ENABLED. Configuration parameters:");
        System.err.println("-----------------------------------------");
        System.err.println("Hosts: " + Arrays.toString(hosts));
        System.err.println("Port: " + port);
        System.err.println("Bucket Type: " + bucketType);
        System.err.println("R Val: " + rvalue.toString());
        System.err.println("W Val: " + wvalue.toString());
        System.err.println("Read Retry Count: " + readRetryCount);
        System.err.println("Wait Time Before Retry: " + waitTimeBeforeRetry + " ms");
        System.err.println("Transaction Time Limit: " + transactionTimeLimit + " s");
        System.err.println("Consistency model: " + (strongConsistency ? "Strong" : "Eventual"));
        if (strongConsistency) {
            System.err.println("Strong Consistent Scan Transactions " + (performStrongConsistentScans ? "" : "NOT ") + "allowed.");
        }
    }
}
Also used : RiakClient(com.basho.riak.client.api.RiakClient) RiakNode(com.basho.riak.client.core.RiakNode) TimeoutException(java.util.concurrent.TimeoutException) IOException(java.io.IOException)

Example 2 with RiakClient

use of com.basho.riak.client.api.RiakClient in project jnosql-diana-driver by eclipse.

the class RiakBucketManagerFactory method getBucketManager.

@Override
public RiakBucketManager getBucketManager(String bucketName) throws UnsupportedOperationException {
    cluster.start();
    RiakClient riakClient = new RiakClient(cluster);
    Namespace quotesBucket = new Namespace(bucketName);
    return new RiakBucketManager(riakClient, quotesBucket);
}
Also used : RiakClient(com.basho.riak.client.api.RiakClient) Namespace(com.basho.riak.client.core.query.Namespace)

Aggregations

RiakClient (com.basho.riak.client.api.RiakClient)2 RiakNode (com.basho.riak.client.core.RiakNode)1 Namespace (com.basho.riak.client.core.query.Namespace)1 IOException (java.io.IOException)1 TimeoutException (java.util.concurrent.TimeoutException)1