Riak 2.0 java client Usage

hotmail.kwyto kwyto at hotmail.com
Tue Jun 3 00:38:16 EDT 2014


I have tried using the java client for Riak 2.0 without success.  I have created 2 buckets types:  one has properties {allow_mult:true, datatype:map} and the other one {allow_mult:true, last_write_wins:true}.  Below are the two approaches I tried.  The first attempts to save a Map in map-device-usage, the second one tries to saves an object under default.  In both occasions I never get an error but nothing is stored in Riak.  After a few minutes of the application running I just stop the app.  
Both bucket-types are active.  Im using leveled as backend.  Im writing to a cluster of 1 node just for the sake of prototyping.  The client was built from branch develop.  
- Am I using the client correctly?  
- Obviously something is going wrong, so where are the errors, or any logs for that matter? 

Any help or insight would be much appreciated. 
RiakClient riakClient() {
    RiakClient client = null;
    try {
      RiakNode node = new RiakNode.Builder()
      RiakCluster cluster = new RiakCluster.Builder(node)
      client = new RiakClient(cluster);
    } catch (UnknownHostException e) {
      LOG.error("Riak node was not created", e);
    return client;


        String deviceKey = RiakUtils.buildDeviceKey(e.getSourceId(), e.getCreatedAt());
        String eventKey = RiakUtils.buildEventKey(e.getType(), e.getCreatedAt());

        Location deviceMap = new Location(bucketName)

        // im not sure if this is the way to do it //
        MapUpdate eventMap = new MapUpdate()
            .add("id", new RegisterUpdate(BinaryValue.create(eventKey).getValue()))
            .add("source", new RegisterUpdate(BinaryValue.create(e.getSource()).getValue()))
    .add("sourceId", new RegisterUpdate(BinaryValue.create(e.getSourceId().toString()).getValue()))
            .add("sourceTypeId", new RegisterUpdate(BinaryValue.create(e.getSourceTypeId().toString()).getValue()))
            .add("created_at", new RegisterUpdate(BinaryValue.create(e.getCreatedAt().toString()).getValue()))
            .add("recorded_at", new RegisterUpdate(BinaryValue.create(DateTime.now().toString()).getValue()))
            .add("data", new RegisterUpdate(BinaryValue.create(e.getData().toString()).getValue()));
        UpdateMap update = new UpdateMap.Builder(deviceMap, eventMap).build();



RiakObject event = null;
        try {
          event = new RiakObject().setContentType(Constants.CTYPE_JSON)
        } catch (JsonProcessingException jpe) {
          LOG.warn("Could not create RiakObject[content={}]", e, jpe);
 Location deviceMap = new Location(bucketName)

        // this is another way // 
        StoreValue storeValue = new StoreValue.Builder(event)

        try {
          StoreValue.Response resp = client.executeAsync(storeValue).get();
        } catch (InterruptedException e1) {

yoandy terradas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20140602/6cbc3087/attachment.html>

More information about the riak-users mailing list