Search in sources :

Example 1 with RiakNode

use of com.basho.riak.client.core.RiakNode 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 RiakNode

use of com.basho.riak.client.core.RiakNode in project jnosql-diana-driver by eclipse.

the class RiakKeyValueConfiguration method get.

@Override
public RiakBucketManagerFactory get(Settings settings) {
    requireNonNull(settings, "settings is required");
    List<RiakNode> nodes = new ArrayList<>();
    settings.keySet().stream().filter(k -> k.startsWith(SERVER_PREFIX)).sorted().map(settings::get).map(a -> new RiakNode.Builder().withRemoteAddress(a.toString()).build()).forEach(nodes::add);
    if (nodes.isEmpty()) {
        nodes.add(DEFAULT_NODE);
    }
    RiakCluster cluster = new RiakCluster.Builder(nodes).build();
    return new RiakBucketManagerFactory(cluster);
}
Also used : RiakNode(com.basho.riak.client.core.RiakNode) List(java.util.List) ConfigurationReader(org.jnosql.diana.driver.ConfigurationReader) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) RiakCluster(com.basho.riak.client.core.RiakCluster) KeyValueConfiguration(org.jnosql.diana.api.key.KeyValueConfiguration) Settings(org.jnosql.diana.api.Settings) Logger(java.util.logging.Logger) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) RiakCluster(com.basho.riak.client.core.RiakCluster) RiakNode(com.basho.riak.client.core.RiakNode)

Example 3 with RiakNode

use of com.basho.riak.client.core.RiakNode in project jnosql-diana-driver by eclipse.

the class RiakTestUtils method get.

public static BucketManagerFactory get() {
    RiakKeyValueConfiguration riakKeyValueConfiguration = new RiakKeyValueConfiguration();
    RiakNode node = new RiakNode.Builder().withRemoteAddress("localhost").build();
    riakKeyValueConfiguration.add(node);
    return riakKeyValueConfiguration.get();
}
Also used : RiakNode(com.basho.riak.client.core.RiakNode)

Aggregations

RiakNode (com.basho.riak.client.core.RiakNode)3 RiakClient (com.basho.riak.client.api.RiakClient)1 RiakCluster (com.basho.riak.client.core.RiakCluster)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 TimeoutException (java.util.concurrent.TimeoutException)1 Logger (java.util.logging.Logger)1 Settings (org.jnosql.diana.api.Settings)1 KeyValueConfiguration (org.jnosql.diana.api.key.KeyValueConfiguration)1 ConfigurationReader (org.jnosql.diana.driver.ConfigurationReader)1