Search in sources :

Example 1 with Payload

use of io.grpc.benchmarks.proto.Messages.Payload in project grpc-java by grpc.

the class Utils method makeRequest.

/**
   * Construct a {@link SimpleRequest} with the specified dimensions.
   */
public static SimpleRequest makeRequest(Messages.PayloadType payloadType, int reqLength, int respLength) {
    ByteString body = ByteString.copyFrom(new byte[reqLength]);
    Payload payload = Payload.newBuilder().setType(payloadType).setBody(body).build();
    return SimpleRequest.newBuilder().setResponseType(payloadType).setResponseSize(respLength).setPayload(payload).build();
}
Also used : ByteString(com.google.protobuf.ByteString) Payload(io.grpc.benchmarks.proto.Messages.Payload)

Example 2 with Payload

use of io.grpc.benchmarks.proto.Messages.Payload in project grpc-java by grpc.

the class AsyncClient method newRequest.

private SimpleRequest newRequest() {
    ByteString body = ByteString.copyFrom(new byte[config.clientPayload]);
    Payload payload = Payload.newBuilder().setType(config.payloadType).setBody(body).build();
    return SimpleRequest.newBuilder().setResponseType(config.payloadType).setResponseSize(config.serverPayload).setPayload(payload).build();
}
Also used : ByteString(com.google.protobuf.ByteString) Payload(io.grpc.benchmarks.proto.Messages.Payload)

Example 3 with Payload

use of io.grpc.benchmarks.proto.Messages.Payload in project grpc-java by grpc.

the class Utils method makeResponse.

/**
   * Construct a {@link SimpleResponse} for the given request.
   */
public static SimpleResponse makeResponse(SimpleRequest request) {
    if (request.getResponseSize() > 0) {
        if (!Messages.PayloadType.COMPRESSABLE.equals(request.getResponseType())) {
            throw Status.INTERNAL.augmentDescription("Error creating payload.").asRuntimeException();
        }
        ByteString body = ByteString.copyFrom(new byte[request.getResponseSize()]);
        Messages.PayloadType type = request.getResponseType();
        Payload payload = Payload.newBuilder().setType(type).setBody(body).build();
        return SimpleResponse.newBuilder().setPayload(payload).build();
    }
    return SimpleResponse.getDefaultInstance();
}
Also used : Messages(io.grpc.benchmarks.proto.Messages) ByteString(com.google.protobuf.ByteString) Payload(io.grpc.benchmarks.proto.Messages.Payload)

Aggregations

ByteString (com.google.protobuf.ByteString)3 Payload (io.grpc.benchmarks.proto.Messages.Payload)3 Messages (io.grpc.benchmarks.proto.Messages)1