Package eu.mosaic_cloud.interoperability.core

Examples of eu.mosaic_cloud.interoperability.core.Message


    } catch (final EncodingException exception) {
      this.exceptions.traceDeferredException (exception, "encoding the value for record with key `%s` failed; deferring!", key);
      result = CallbackCompletion.createFailure (exception);
    }
    if (result == null) {
      final Message message = new Message (MemcachedMessage.ADD_REQUEST, requestBuilder.build ());
      result = this.sendRequest (message, token, Void.class);
    }
    return result;
  }
View Full Code Here


    } catch (final EncodingException exception) {
      this.exceptions.traceDeferredException (exception, "encoding the value for record with key `%s` failed; deferring!", key);
      result = CallbackCompletion.createFailure (exception);
    }
    if (result == null) {
      final Message message = new Message (MemcachedMessage.APPEND_REQUEST, requestBuilder.build ());
      result = this.sendRequest (message, token, Void.class);
    }
    return result;
  }
View Full Code Here

    } catch (final EncodingException exception) {
      this.exceptions.traceDeferredException (exception, "encoding the value for record with key `%s` failed; deferring!", key);
      result = CallbackCompletion.createFailure (exception);
    }
    if (result == null) {
      final Message message = new Message (MemcachedMessage.CAS_REQUEST, requestBuilder.build ());
      result = this.sendRequest (message, token, Void.class);
    }
    return result;
  }
View Full Code Here

  {
    this.transcript.traceDebugging ("initializing proxy...");
    final InitRequest.Builder requestBuilder = InitRequest.newBuilder ();
    requestBuilder.setToken (this.generateToken ());
    requestBuilder.setBucket (this.bucket);
    return (this.connect (MemcachedSession.CONNECTOR, new Message (KeyValueMessage.ACCESS, requestBuilder.build ())));
  }
View Full Code Here

    } catch (final EncodingException exception) {
      this.exceptions.traceDeferredException (exception, "encoding the value for record with key `%s` failed; deferring!", key);
      result = CallbackCompletion.createFailure (exception);
    }
    if (result == null) {
      final Message message = new Message (MemcachedMessage.PREPEND_REQUEST, requestBuilder.build ());
      result = this.sendRequest (message, token, Void.class);
    }
    return result;
  }
View Full Code Here

    } catch (final EncodingException exception) {
      this.exceptions.traceDeferredException (exception, "encoding the value for record with key `%s` failed; deferring!", key);
      result = CallbackCompletion.createFailure (exception);
    }
    if (result == null) {
      final Message message = new Message (MemcachedMessage.REPLACE_REQUEST, requestBuilder.build ());
      result = this.sendRequest (message, token, Void.class);
    }
    return result;
  }
View Full Code Here

   *            the result of the operation
   * @return the message
   */
  protected Message buildKeyValueResponse (final KeyValueOperations operation, final CompletionToken token, final Object result)
  {
    Message message = null;
    switch (operation) {
      case SET :
      case DELETE :
        final boolean success = (Boolean) result;
        if (success) {
          final Ok.Builder okPayload = IdlCommon.Ok.newBuilder ();
          okPayload.setToken (token);
          message = new Message (KeyValueMessage.OK, okPayload.build ());
        } else {
          final NotOk.Builder nokPayload = IdlCommon.NotOk.newBuilder ();
          nokPayload.setToken (token);
          message = new Message (KeyValueMessage.NOK, nokPayload.build ());
        }
        break;
      case LIST :
        final ListReply.Builder listPayload = KeyValuePayloads.ListReply.newBuilder ();
        listPayload.setToken (token);
        @SuppressWarnings ("unchecked") final List<String> resList = (List<String>) result;
        listPayload.addAllKeys (resList);
        message = new Message (KeyValueMessage.LIST_REPLY, listPayload.build ());
        break;
      case GET :
        final GetReply.Builder getPayload = KeyValuePayloads.GetReply.newBuilder ();
        getPayload.setToken (token);
        @SuppressWarnings ("unchecked") final Map<String, eu.mosaic_cloud.platform.interop.common.kv.KeyValueMessage> resMap = (Map<String, eu.mosaic_cloud.platform.interop.common.kv.KeyValueMessage>) result;
        final List<KVEntry> getResults = new ArrayList<KVEntry> ();
        for (final Map.Entry<String, eu.mosaic_cloud.platform.interop.common.kv.KeyValueMessage> entry : resMap.entrySet ()) {
          final KVEntry.Builder kvEntry = KeyValuePayloads.KVEntry.newBuilder ();
          kvEntry.setKey (entry.getKey ());
          final IdlCommon.Envelope.Builder envelope = IdlCommon.Envelope.newBuilder ();
          if (null != entry.getValue ().getContentEncoding ())
            envelope.setContentEncoding (entry.getValue ().getContentEncoding ());
          else
            envelope.setContentEncoding ("");
          if (null != entry.getValue ().getContentType ())
            envelope.setContentType (entry.getValue ().getContentType ());
          else
            envelope.setContentType ("");
          kvEntry.setEnvelope (envelope.build ());
          if (entry.getValue ().getData () == null) {
            kvEntry.setValue (ByteString.EMPTY);
          } else {
            kvEntry.setValue (ByteString.copyFrom (entry.getValue ().getData ()));
          }
          getResults.add (kvEntry.build ());
        }
        getPayload.addAllResults (getResults);
        message = new Message (KeyValueMessage.GET_REPLY, getPayload.build ());
        break;
      default:
        break;
    }
    return message;
View Full Code Here

    return message;
  }
 
  protected void packAndSend (final Session session, final CompletionToken token, final KeyValueOperations operation, final Object result, final boolean isError)
  {
    Message message;
    this.logger.trace ("KeyValueResponseTransmitter: send response for " + operation + " request " + token.getMessageId () + " client id " + token.getClientId ());
    if (isError) {
      // NOTE: create error message
      final Error.Builder errorPayload = IdlCommon.Error.newBuilder ();
      errorPayload.setToken (token);
      errorPayload.setErrorMessage (result.toString ());
      message = new Message (KeyValueMessage.ERROR, errorPayload.build ());
    } else {
      message = this.buildKeyValueResponse (operation, token, result);
    }
    // NOTE: send response
    this.publishResponse (session, message);
View Full Code Here

          this.exceptions.traceIgnoredException (exception, "error encountered while decoding packet of type `%s` for session `%s`: coder `%s` failed; ignoring!", messageIdentifier, sessionIdentifier, coderKey);
          return;
        }
      else
        payload = null;
      final Message message = new Message (coder.specification, payload);
      this.enqueueDispatcher (new SessionReceivedDispatcher (session, message));
      if (coder.messageType == MessageType.Termination)
        this.enqueueDispatcher (new SessionDestroyedDispatcher (session));
    }
  }
View Full Code Here

TOP

Related Classes of eu.mosaic_cloud.interoperability.core.Message

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.