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();
}
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();
}
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();
}
Aggregations