use of com.scalar.db.rpc.TwoPhaseCommitTransactionRequest.StartRequest in project scalardb by scalar-labs.
the class GrpcTwoPhaseCommitTransactionOnBidirectionalStream method startTransaction.
public String startTransaction(@Nullable String transactionId) throws TransactionException {
throwIfTransactionFinished();
StartRequest request;
if (transactionId == null) {
request = StartRequest.getDefaultInstance();
} else {
request = StartRequest.newBuilder().setTransactionId(transactionId).build();
}
ResponseOrError responseOrError = sendRequest(TwoPhaseCommitTransactionRequest.newBuilder().setStartRequest(request).build());
throwIfErrorForStartOrJoin(responseOrError, true);
return responseOrError.getResponse().getStartResponse().getTransactionId();
}
Aggregations