/**
   * Makes an asynchronous call.
   *
   * @param method the method on the API to call
   * @param request the request to forward to the API
   * @param responseBuilder the response builder used to fill the response
   * @param deadline the deadline of the call. if it is null, the default api deadline will be used
   */
  private <T extends GeneratedMessage.Builder<T>> Future<T> makeAsyncCall(
      String method, GeneratedMessage request, final T responseBuilder, Double deadline) {
    Future<byte[]> response;
    if (deadline == null) {
      response = ApiProxy.makeAsyncCall(PACKAGE, method, request.toByteArray());
    } else {
      ApiProxy.ApiConfig apiConfig = new ApiProxy.ApiConfig();
      apiConfig.setDeadlineInSeconds(deadline);
      response = ApiProxy.makeAsyncCall(PACKAGE, method, request.toByteArray(), apiConfig);
    }
    return new FutureWrapper<byte[], T>(response) {
      @Override
      protected T wrap(byte[] responseBytes) {
        if (responseBytes != null) {
          try {
            responseBuilder.mergeFrom(responseBytes);
          } catch (InvalidProtocolBufferException e) {
            throw new SearchServiceException(e.toString());
          }
        }
        return responseBuilder;
      }

      @Override
      protected Throwable convertException(Throwable cause) {
        return cause;
      }
    };
  }
 public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
   if (((bitField0_ & 0x00000001) == 0x00000001)) {
     com.google.protobuf.GeneratedMessage.writeString(output, 1, uid_);
   }
   if (((bitField0_ & 0x00000002) == 0x00000002)) {
     com.google.protobuf.GeneratedMessage.writeString(output, 2, error_);
   }
   unknownFields.writeTo(output);
 }
Beispiel #3
0
 public boolean write(GeneratedMessage message) throws IOException {
   int msgSize = message.getSerializedSize();
   if (msgSize > Constants.MAX_RECORD_SIZE) {
     return false;
   }
   if (msgBuffer == null || msgBuffer.length < msgSize) {
     msgBuffer = new byte[msgSize];
   }
   CodedOutputStream cos = CodedOutputStream.newInstance(msgBuffer, 0, msgSize);
   message.writeTo(cos);
   cos.flush();
   return write(msgBuffer, 0, msgSize);
 }
  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    if (((bitField0_ & 0x00000001) == 0x00000001)) {
      size += com.google.protobuf.GeneratedMessage.computeStringSize(1, uid_);
    }
    if (((bitField0_ & 0x00000002) == 0x00000002)) {
      size += com.google.protobuf.GeneratedMessage.computeStringSize(2, error_);
    }
    size += unknownFields.getSerializedSize();
    memoizedSize = size;
    return size;
  }
 public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
   if (!getNameBytes().isEmpty()) {
     com.google.protobuf.GeneratedMessage.writeString(output, 1, name_);
   }
   for (int i = 0; i < columns_.size(); i++) {
     output.writeMessage(2, columns_.get(i));
   }
 }
  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    if (!getFileNameBytes().isEmpty()) {
      size += com.google.protobuf.GeneratedMessage.computeStringSize(1, fileName_);
    }
    memoizedSize = size;
    return size;
  }
  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    if (!getNameBytes().isEmpty()) {
      size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_);
    }
    for (int i = 0; i < columns_.size(); i++) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, columns_.get(i));
    }
    memoizedSize = size;
    return size;
  }
 public void sendMessage(
     ChannelHandlerContext ctx,
     short serviceId,
     short commandId,
     GeneratedMessage msg,
     Packetlistener packetlistener,
     short seqnum) {
   if (ctx != null) {
     Header header = new Header();
     header.setCommandId(commandId);
     header.setServiceId(serviceId);
     if (seqnum != 0) {
       header.setSeqnum(seqnum);
     }
     if (packetlistener != null && seqnum == 0) {
       short reqSeqnum = header.getSeqnum();
       listenerQueue.push(reqSeqnum, packetlistener);
     }
     header.setLength(SysConstant.HEADER_LENGTH + msg.getSerializedSize());
     messageServerThread.sendMessage(ctx, header, msg);
   }
 }
Beispiel #9
0
public final class KeyValueMessages {
  private KeyValueMessages() {}

  public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) {
    registry.add(
        org.opendaylight.controller.cluster.example.protobuff.messages.KeyValueMessages.key);
    registry.add(
        org.opendaylight.controller.cluster.example.protobuff.messages.KeyValueMessages.value);
  }

  public static final int KEY_FIELD_NUMBER = 2;
  /**
   * <code>
   * extend .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload { ... }
   * </code>
   */
  public static final com.google.protobuf.GeneratedMessage.GeneratedExtension<
          org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages
              .AppendEntries.ReplicatedLogEntry.Payload,
          java.lang.String>
      key =
          com.google.protobuf.GeneratedMessage.newFileScopedGeneratedExtension(
              java.lang.String.class, null);

  public static final int VALUE_FIELD_NUMBER = 3;
  /**
   * <code>
   * extend .org.opendaylight.controller.cluster.raft.AppendEntries.ReplicatedLogEntry.Payload { ... }
   * </code>
   */
  public static final com.google.protobuf.GeneratedMessage.GeneratedExtension<
          org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages
              .AppendEntries.ReplicatedLogEntry.Payload,
          java.lang.String>
      value =
          com.google.protobuf.GeneratedMessage.newFileScopedGeneratedExtension(
              java.lang.String.class, null);

  public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
    return descriptor;
  }

  private static com.google.protobuf.Descriptors.FileDescriptor descriptor;

  static {
    java.lang.String[] descriptorData = {
      "\n\026KeyValueMessages.proto\022(org.opendaylig"
          + "ht.controller.cluster.raft\032\033AppendEntrie"
          + "sMessages.proto:_\n\003key\022R.org.opendayligh"
          + "t.controller.cluster.raft.AppendEntries."
          + "ReplicatedLogEntry.Payload\030\002 \001(\t:a\n\005valu"
          + "e\022R.org.opendaylight.controller.cluster."
          + "raft.AppendEntries.ReplicatedLogEntry.Pa"
          + "yload\030\003 \001(\tBT\n>org.opendaylight.controll"
          + "er.cluster.example.protobuff.messagesB\020K"
          + "eyValueMessagesH\001"
    };
    com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
        new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
          public com.google.protobuf.ExtensionRegistry assignDescriptors(
              com.google.protobuf.Descriptors.FileDescriptor root) {
            descriptor = root;
            key.internalInit(descriptor.getExtensions().get(0));
            value.internalInit(descriptor.getExtensions().get(1));
            return null;
          }
        };
    com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(
        descriptorData,
        new com.google.protobuf.Descriptors.FileDescriptor[] {
          org.opendaylight.controller.cluster.raft.protobuff.messages.AppendEntriesMessages
              .getDescriptor(),
        },
        assigner);
  }

  // @@protoc_insertion_point(outer_class_scope)
}
Beispiel #10
0
public final class TestDataFormats {
  private TestDataFormats() {}

  public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) {
    registry.add(org.apache.bookkeeper.proto.TestDataFormats.messageType);
  }
  /** Protobuf enum {@code AuthMessageType} */
  public enum AuthMessageType implements com.google.protobuf.ProtocolMessageEnum {
    /** <code>SUCCESS_RESPONSE = 1;</code> */
    SUCCESS_RESPONSE(0, 1),
    /** <code>FAILURE_RESPONSE = 2;</code> */
    FAILURE_RESPONSE(1, 2),
    /** <code>PAYLOAD_MESSAGE = 3;</code> */
    PAYLOAD_MESSAGE(2, 3),
    ;

    /** <code>SUCCESS_RESPONSE = 1;</code> */
    public static final int SUCCESS_RESPONSE_VALUE = 1;
    /** <code>FAILURE_RESPONSE = 2;</code> */
    public static final int FAILURE_RESPONSE_VALUE = 2;
    /** <code>PAYLOAD_MESSAGE = 3;</code> */
    public static final int PAYLOAD_MESSAGE_VALUE = 3;

    public final int getNumber() {
      return value;
    }

    public static AuthMessageType valueOf(int value) {
      switch (value) {
        case 1:
          return SUCCESS_RESPONSE;
        case 2:
          return FAILURE_RESPONSE;
        case 3:
          return PAYLOAD_MESSAGE;
        default:
          return null;
      }
    }

    public static com.google.protobuf.Internal.EnumLiteMap<AuthMessageType> internalGetValueMap() {
      return internalValueMap;
    }

    private static com.google.protobuf.Internal.EnumLiteMap<AuthMessageType> internalValueMap =
        new com.google.protobuf.Internal.EnumLiteMap<AuthMessageType>() {
          public AuthMessageType findValueByNumber(int number) {
            return AuthMessageType.valueOf(number);
          }
        };

    public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() {
      return getDescriptor().getValues().get(index);
    }

    public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() {
      return getDescriptor();
    }

    public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() {
      return org.apache.bookkeeper.proto.TestDataFormats.getDescriptor().getEnumTypes().get(0);
    }

    private static final AuthMessageType[] VALUES = values();

    public static AuthMessageType valueOf(
        com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
      if (desc.getType() != getDescriptor()) {
        throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type.");
      }
      return VALUES[desc.getIndex()];
    }

    private final int index;
    private final int value;

    private AuthMessageType(int index, int value) {
      this.index = index;
      this.value = value;
    }

    // @@protoc_insertion_point(enum_scope:AuthMessageType)
  }

  public static final int MESSAGETYPE_FIELD_NUMBER = 1000;
  /** <code>extend .AuthMessage { ... }</code> */
  public static final com.google.protobuf.GeneratedMessage.GeneratedExtension<
          org.apache.bookkeeper.proto.BookkeeperProtocol.AuthMessage,
          org.apache.bookkeeper.proto.TestDataFormats.AuthMessageType>
      messageType =
          com.google.protobuf.GeneratedMessage.newFileScopedGeneratedExtension(
              org.apache.bookkeeper.proto.TestDataFormats.AuthMessageType.class, null);

  public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
    return descriptor;
  }

  private static com.google.protobuf.Descriptors.FileDescriptor descriptor;

  static {
    java.lang.String[] descriptorData = {
      "\n$src/test/proto/TestDataFormats.proto\032\'"
          + "src/main/proto/BookkeeperProtocol.proto*"
          + "R\n\017AuthMessageType\022\024\n\020SUCCESS_RESPONSE\020\001"
          + "\022\024\n\020FAILURE_RESPONSE\020\002\022\023\n\017PAYLOAD_MESSAG"
          + "E\020\003:4\n\013messageType\022\014.AuthMessage\030\350\007 \001(\0162"
          + "\020.AuthMessageTypeB\037\n\033org.apache.bookkeep"
          + "er.protoH\001"
    };
    com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
        new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
          public com.google.protobuf.ExtensionRegistry assignDescriptors(
              com.google.protobuf.Descriptors.FileDescriptor root) {
            descriptor = root;
            return null;
          }
        };
    com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(
        descriptorData,
        new com.google.protobuf.Descriptors.FileDescriptor[] {
          org.apache.bookkeeper.proto.BookkeeperProtocol.getDescriptor(),
        },
        assigner);
    messageType.internalInit(descriptor.getExtensions().get(0));
    org.apache.bookkeeper.proto.BookkeeperProtocol.getDescriptor();
  }

  // @@protoc_insertion_point(outer_class_scope)
}
Beispiel #11
0
 private String toHex(GeneratedMessage m) {
   return java.util.Base64.getEncoder().encodeToString(m.toByteArray());
 }
 public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
   if (!getFileNameBytes().isEmpty()) {
     com.google.protobuf.GeneratedMessage.writeString(output, 1, fileName_);
   }
 }