Package eu.mosaic_cloud.platform.interop.common.kv

Examples of eu.mosaic_cloud.platform.interop.common.kv.KeyValueMessage


  {
    final String k1 = RiakDriverTest.keyPrefix + "_key_famous";
    final IOperationCompletionHandler<KeyValueMessage> handler = new TestLoggingHandler<KeyValueMessage> ("get");
    final IResult<KeyValueMessage> r1 = this.wrapper.invokeGetOperation (RiakDriverTest.keyPrefix, k1, new EncodingMetadata ("text/plain", "identity"), handler);
    try {
      final KeyValueMessage mssg = r1.getResult ();
      Assert.assertEquals ("famous", this.encoder.decode (mssg.getData (), new EncodingMetadata ("text/plain", "identity")));
    } catch (final InterruptedException e) {
      this.exceptions.traceIgnoredException (e);
      Assert.fail ();
    } catch (final ExecutionException e) {
      this.exceptions.traceIgnoredException (e);
View Full Code Here


      throws IOException,
        EncodingException
  {
    final String k1 = RiakDriverTest.keyPrefix + "_key_fantastic";
    final byte[] b1 = this.encoder.encode ("fantastic", new EncodingMetadata ("text/plain", "identity")).data;
    KeyValueMessage mssg = new KeyValueMessage (k1, b1, "identity", "text/plain");
    final IOperationCompletionHandler<Boolean> handler1 = new TestLoggingHandler<Boolean> ("set 1");
    final IResult<Boolean> r1 = this.wrapper.invokeSetOperation (RiakDriverTest.keyPrefix, mssg, handler1);
    Assert.assertNotNull (r1);
    final String k2 = RiakDriverTest.keyPrefix + "_key_famous";
    final byte[] b2 = this.encoder.encode ("famous", new EncodingMetadata ("text/plain", "identity")).data;
    mssg = new KeyValueMessage (k2, b2, "identity", "text/plain");
    final IOperationCompletionHandler<Boolean> handler2 = new TestLoggingHandler<Boolean> ("set 2");
    final IResult<Boolean> r2 = this.wrapper.invokeSetOperation (RiakDriverTest.keyPrefix, mssg, handler2);
    Assert.assertNotNull (r2);
    try {
      Assert.assertTrue (r1.getResult ());
View Full Code Here

    return new GenericOperation<KeyValueMessage> (new Callable<KeyValueMessage> () {
      @Override
      public KeyValueMessage call ()
          throws IOException
      {
        KeyValueMessage result = null;
        final String key = (String) parameters[0];
        final EncodingMetadata expectedEncoding = (EncodingMetadata) parameters[1];
        // FIXME: use the vector clock...
        IRiakObject riakObj = null;
        try {
          riakObj = RiakOperationFactory.this.bucket.fetch (key).execute ();
        } catch (final UnresolvedConflictException e) {
          FallbackExceptionTracer.defaultInstance.traceIgnoredException (e);
        } catch (final RiakRetryFailedException e) {
          // TODO: shutdown all connectors for this bucket?
          FallbackExceptionTracer.defaultInstance.traceIgnoredException (e);
        } catch (final ConversionException e) {
          FallbackExceptionTracer.defaultInstance.traceIgnoredException (e);
        }
        if (null != riakObj) {
          result = new KeyValueMessage (key, riakObj.getValue (), riakObj.getUsermeta (IOperationFactory.CONTENT_ENCODING), riakObj.getContentType ());
        } else {
          result = new KeyValueMessage (key, null, expectedEncoding.getContentEncoding (), expectedEncoding.getContentType ());
        }
        return result;
      }
    });
  }
View Full Code Here

    return new GenericOperation<Boolean> (new Callable<Boolean> () {
      @Override
      public Boolean call ()
          throws IOException
      {
        final KeyValueMessage kvMessage = (KeyValueMessage) parameters[0];
        final String key = kvMessage.getKey ();
        // FIXME: use the vector clock...
        final IRiakObject riakObject = RiakObjectBuilder.newBuilder (RiakOperationFactory.this.bucket.getName (), key).addUsermeta (IOperationFactory.CONTENT_ENCODING, kvMessage.getContentEncoding ()).withContentType (kvMessage.getContentType ()).withValue (kvMessage.getData ()).build ();
        final RiakBucket riakBucket = RiakBucket.newRiakBucket (RiakOperationFactory.this.bucket);
        try {
          riakBucket.store (riakObject);
        } catch (final RiakException e) {
          // TODO: shutdown all connectors for this bucket?
View Full Code Here

  {
    final String k1 = RedisDriverTest.keyPrefix + "_key_fantastic";
    final IOperationCompletionHandler<KeyValueMessage> handler = new TestLoggingHandler<KeyValueMessage> ("get");
    final IResult<KeyValueMessage> r1 = this.wrapper.invokeGetOperation (RedisDriverTest.keyPrefix, k1, new EncodingMetadata ("text/plain", "identity"), handler);
    try {
      final KeyValueMessage mssg = r1.getResult ();
      Assert.assertEquals ("fantastic", this.encoder.decode (mssg.getData (), new EncodingMetadata ("text/plain", "identity")));
    } catch (final InterruptedException e) {
      this.exceptions.traceIgnoredException (e);
      Assert.fail ();
    } catch (final ExecutionException e) {
      this.exceptions.traceIgnoredException (e);
View Full Code Here

        EncodingException
  {
    final String k1 = RedisDriverTest.keyPrefix + "_key_fantastic";
    final byte[] b1 = this.encoder.encode ("fantastic", new EncodingMetadata ("text/plain", "identity")).data;
    ;
    KeyValueMessage mssg = new KeyValueMessage (k1, b1, RedisDriver.DEFAULT_CONTENT_ENCODING, RedisDriver.DEFAULT_CONTENT_TYPE);
    final IOperationCompletionHandler<Boolean> handler1 = new TestLoggingHandler<Boolean> ("set 1");
    final IResult<Boolean> r1 = this.wrapper.invokeSetOperation (RedisDriverTest.keyPrefix, mssg, handler1);
    Assert.assertNotNull (r1);
    final String k2 = RedisDriverTest.keyPrefix + "_key_famous";
    final byte[] b2 = this.encoder.encode ("famous", new EncodingMetadata ("text/plain", "identity")).data;
    mssg = new KeyValueMessage (k2, b2, RedisDriver.DEFAULT_CONTENT_ENCODING, RedisDriver.DEFAULT_CONTENT_TYPE);
    final IOperationCompletionHandler<Boolean> handler2 = new TestLoggingHandler<Boolean> ("set 2");
    final IResult<Boolean> r2 = this.wrapper.invokeSetOperation (RedisDriverTest.keyPrefix, mssg, handler2);
    Assert.assertNotNull (r2);
    try {
      Assert.assertTrue (r1.getResult ());
View Full Code Here

      {
        final String key = (String) parameters[0];
        final byte[] keyBytes = SafeEncoder.encode (key);
        final byte[] result = RedisOperationFactory.this.redisClient.get (keyBytes);
        final EncodingMetadata expectedEncoding = (EncodingMetadata) parameters[1];
        KeyValueMessage kvMessage = null;
        kvMessage = new KeyValueMessage (key, result, expectedEncoding.getContentEncoding (), expectedEncoding.getContentType ());
        return kvMessage;
      }
    });
  }
View Full Code Here

  {
    return new GenericOperation<Boolean> (new Callable<Boolean> () {
      @Override
      public Boolean call ()
      {
        final KeyValueMessage kvMessage = (KeyValueMessage) parameters[0];
        final byte[] keyBytes = SafeEncoder.encode ((String) kvMessage.getKey ());
        final byte[] dataBytes = kvMessage.getData ();
        String opResult = RedisOperationFactory.this.redisClient.set (keyBytes, dataBytes);
        opResult = opResult.trim ();
        if (opResult.equalsIgnoreCase ("OK")) {
          return true;
        }
View Full Code Here

  {
    final String k1 = MemcachedDriverTest.keyPrefix + "_key_fantastic";
    final String k2 = MemcachedDriverTest.keyPrefix + "_key_fabulous";
    final byte[] b1 = this.encoder.encode ("wrong", new EncodingMetadata ("text/plain", "identity")).data;
    final byte[] b2 = this.encoder.encode ("fabulous", new EncodingMetadata ("text/plain", "identity")).data;
    final KeyValueMessage mssg1 = new KeyValueMessage (k1, b1, "identity", "text/plain");
    final KeyValueMessage mssg2 = new KeyValueMessage (k2, b2, "identity", "text/plain");
    final IOperationCompletionHandler<Boolean> handler1 = new TestLoggingHandler<Boolean> ("add1");
    final IOperationCompletionHandler<Boolean> handler2 = new TestLoggingHandler<Boolean> ("add2");
    final IResult<Boolean> r1 = this.wrapper.invokeAddOperation (MemcachedDriverTest.keyPrefix, mssg1, 30, handler1);
    final IResult<Boolean> r2 = this.wrapper.invokeAddOperation (MemcachedDriverTest.keyPrefix, mssg2, 30, handler2);
    try {
View Full Code Here

        ClassNotFoundException,
        EncodingException
  {
    final String k1 = MemcachedDriverTest.keyPrefix + "_key_fabulous";
    final byte[] b1 = this.encoder.encode (" and miraculous", new EncodingMetadata ("text/plain", "identity")).data;
    final KeyValueMessage mssg1 = new KeyValueMessage (k1, b1, "identity", "text/plain");
    final IOperationCompletionHandler<Boolean> handler = new TestLoggingHandler<Boolean> ("append");
    final IResult<Boolean> r1 = this.wrapper.invokeAppendOperation (MemcachedDriverTest.keyPrefix, mssg1, handler);
    try {
      Assert.assertTrue (r1.getResult ());
    } catch (final InterruptedException e) {
      this.exceptions.traceIgnoredException (e);
      Assert.fail ();
    } catch (final ExecutionException e) {
      this.exceptions.traceIgnoredException (e);
      Assert.fail ();
    }
    final IOperationCompletionHandler<KeyValueMessage> handler1 = new TestLoggingHandler<KeyValueMessage> ("Get after append");
    final IResult<KeyValueMessage> r2 = this.wrapper.invokeGetOperation (MemcachedDriverTest.keyPrefix, k1, new EncodingMetadata ("text/plain", "identity"), handler1);
    try {
      final KeyValueMessage mssg = r2.getResult ();
      Assert.assertEquals ("fantabulous and miraculous", this.encoder.decode (mssg.getData (), new EncodingMetadata ("text/plain", "identity")));
    } catch (final InterruptedException e) {
      this.exceptions.traceIgnoredException (e);
      Assert.fail ();
    } catch (final ExecutionException e) {
      this.exceptions.traceIgnoredException (e);
View Full Code Here

TOP

Related Classes of eu.mosaic_cloud.platform.interop.common.kv.KeyValueMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.