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

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


        ClassNotFoundException,
        EncodingException
  {
    final String k1 = MemcachedDriverTest.keyPrefix + "_key_fabulous";
    final byte[] b1 = this.encoder.encode ("replaced by dummy", new EncodingMetadata ("text/plain", "identity")).data;
    final KeyValueMessage mssg1 = new KeyValueMessage (k1, b1, "identity", "text/plain");
    final IOperationCompletionHandler<Boolean> handler = new TestLoggingHandler<Boolean> ("cas");
    final IResult<Boolean> r1 = this.wrapper.invokeCASOperation (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 cas");
    final IResult<KeyValueMessage> r2 = this.wrapper.invokeGetOperation (MemcachedDriverTest.keyPrefix, k1, new EncodingMetadata ("text/plain", "identity"), handler1);
    try {
      final KeyValueMessage mssg = r2.getResult ();
      Assert.assertEquals ("replaced by dummy", 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


  {
    final String k1 = MemcachedDriverTest.keyPrefix + "_key_fantastic";
    final IOperationCompletionHandler<KeyValueMessage> handler = new TestLoggingHandler<KeyValueMessage> ("get");
    final IResult<KeyValueMessage> r1 = this.wrapper.invokeGetOperation (MemcachedDriverTest.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

    keys.add (k1);
    keys.add (k2);
    final IOperationCompletionHandler<Map<String, KeyValueMessage>> handler = new TestLoggingHandler<Map<String, KeyValueMessage>> ("getBulk");
    final IResult<Map<String, KeyValueMessage>> r1 = this.wrapper.invokeGetBulkOperation (MemcachedDriverTest.keyPrefix, keys, new EncodingMetadata ("text/plain", "identity"), handler);
    try {
      KeyValueMessage mssg = r1.getResult ().get (k1);
      Assert.assertEquals ("fantastic", this.encoder.decode (mssg.getData (), new EncodingMetadata ("text/plain", "identity")));
      mssg = r1.getResult ().get (k2);
      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

        ClassNotFoundException,
        EncodingException
  {
    final String k1 = MemcachedDriverTest.keyPrefix + "_key_fabulous";
    final byte[] b1 = this.encoder.encode ("it is ", new EncodingMetadata ("text/plain", "identity")).data;
    final KeyValueMessage mssg1 = new KeyValueMessage (k1, b1, "identity", "text/plain");
    final IOperationCompletionHandler<Boolean> handler = new TestLoggingHandler<Boolean> ("prepend");
    final IResult<Boolean> r1 = this.wrapper.invokePrependOperation (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 prepend");
    final IResult<KeyValueMessage> r2 = this.wrapper.invokeGetOperation (MemcachedDriverTest.keyPrefix, k1, new EncodingMetadata ("text/plain", "identity"), handler1);
    try {
      final KeyValueMessage mssg = r2.getResult ();
      Assert.assertEquals ("it is 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

        ClassNotFoundException,
        EncodingException
  {
    final String k1 = MemcachedDriverTest.keyPrefix + "_key_fabulous";
    final byte[] b1 = this.encoder.encode ("fantabulous", new EncodingMetadata ("text/plain", "identity")).data;
    final KeyValueMessage mssg1 = new KeyValueMessage (k1, b1, "identity", "text/plain");
    final IOperationCompletionHandler<Boolean> handler = new TestLoggingHandler<Boolean> ("replace");
    final IResult<Boolean> r1 = this.wrapper.invokeReplaceOperation (MemcachedDriverTest.keyPrefix, mssg1, 30, 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 replace");
    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", 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 = MemcachedDriverTest.keyPrefix + "_key_fantastic";
    final byte[] bytes1 = this.encoder.encode ("fantastic", new EncodingMetadata ("text/plain", "identity")).data;
    KeyValueMessage mssg = new KeyValueMessage (k1, bytes1, "identity", "text/plain");
    final IOperationCompletionHandler<Boolean> handler1 = new TestLoggingHandler<Boolean> ("set 1");
    final IResult<Boolean> r1 = this.wrapper.invokeSetOperation (MemcachedDriverTest.keyPrefix, mssg, 30, handler1);
    Assert.assertNotNull (r1);
    final String k2 = MemcachedDriverTest.keyPrefix + "_key_famous";
    final byte[] bytes2 = this.encoder.encode ("famous", new EncodingMetadata ("text/plain", "identity")).data;
    mssg = new KeyValueMessage (k2, bytes2, "identity", "text/plain");
    final IOperationCompletionHandler<Boolean> handler2 = new TestLoggingHandler<Boolean> ("set 2");
    final IResult<Boolean> r2 = this.wrapper.invokeSetOperation (MemcachedDriverTest.keyPrefix, mssg, 30, handler2);
    Assert.assertNotNull (r2);
    try {
      Assert.assertTrue (r1.getResult ());
View Full Code Here

      @Override
      public Boolean call ()
          throws ExecutionException,
            InterruptedException
      {
        final KeyValueMessage kvMessage = (KeyValueMessage) parameters[0];
        final int exp = (Integer) parameters[1];
        final Future<Boolean> opResult = MemcachedOperationFactory.this.mcClient.add (kvMessage.getKey (), exp, kvMessage.getData ());
        return opResult.get ();
      }
    });
  }
View Full Code Here

      @Override
      public Boolean call ()
          throws ExecutionException,
            InterruptedException
      {
        final KeyValueMessage kvMessage = (KeyValueMessage) parameters[0];
        final long cas = MemcachedOperationFactory.this.mcClient.gets (kvMessage.getKey ()).getCas ();
        final Future<Boolean> opResult = MemcachedOperationFactory.this.mcClient.append (cas, kvMessage.getKey (), kvMessage.getData ());
        return opResult.get ();
      }
    });
  }
View Full Code Here

      @Override
      public Boolean call ()
          throws ExecutionException,
            InterruptedException
      {
        final KeyValueMessage kvMessage = (KeyValueMessage) parameters[0];
        final long cas = MemcachedOperationFactory.this.mcClient.gets (kvMessage.getKey ()).getCas ();
        final Future<CASResponse> opResult = MemcachedOperationFactory.this.mcClient.asyncCAS (kvMessage.getKey (), cas, kvMessage.getData ());
        return (opResult.get () == CASResponse.OK);
      }
    });
  }
View Full Code Here

      {
        final String[] keys = (String[]) parameters[0];
        final EncodingMetadata expectedEncoding = (EncodingMetadata) parameters[1];
        final Future<Map<String, Object>> opResult = MemcachedOperationFactory.this.mcClient.asyncGetBulk (keys);
        final Map<String, KeyValueMessage> result = new HashMap<String, KeyValueMessage> ();
        KeyValueMessage kvMessage = null;
        for (final Map.Entry<String, Object> entry : opResult.get ().entrySet ()) {
          kvMessage = null;
          kvMessage = new KeyValueMessage (entry.getKey (), (byte[]) entry.getValue (), expectedEncoding.getContentEncoding (), expectedEncoding.getContentType ());
          result.put (entry.getKey (), kvMessage);
        }
        return result;
      }
    });
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.