@Override public CompletableFuture<Transaction.Status> checkTransactionStatus(final Stream stream, final UUID txId) { Exceptions.checkNotClosed(closed.get(), this); Preconditions.checkNotNull(stream, "stream"); Preconditions.checkNotNull(txId, "txId"); long traceId = LoggerHelpers.traceEnter(log, "checkTransactionStatus", stream, txId); final CompletableFuture<TxnState> result = this.retryConfig.runAsync(() -> { RPCAsyncCallback<TxnState> callback = new RPCAsyncCallback<>(traceId, "checkTransactionStatus"); client.checkTransactionState(TxnRequest.newBuilder() .setStreamInfo(ModelHelper.createStreamInfo(stream.getScope(), stream.getStreamName())) .setTxnId(ModelHelper.decode(txId)) .build(), callback); return callback.getFuture(); }, this.executor); return result.thenApply(status -> ModelHelper.encode(status.getState(), stream + " " + txId)) .whenComplete((x, e) -> { if (e != null) { log.warn("checkTransactionStatus failed: ", e); } LoggerHelpers.traceLeave(log, "checkTransactionStatus", traceId); }); }
/** * <code>.io.pravega.controller.stream.api.grpc.v1.TxnId txnId = 2;</code> */ private com.google.protobuf.SingleFieldBuilderV3< io.pravega.controller.stream.api.grpc.v1.Controller.TxnId, io.pravega.controller.stream.api.grpc.v1.Controller.TxnId.Builder, io.pravega.controller.stream.api.grpc.v1.Controller.TxnIdOrBuilder> getTxnIdFieldBuilder() { if (txnIdBuilder_ == null) { txnIdBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< io.pravega.controller.stream.api.grpc.v1.Controller.TxnId, io.pravega.controller.stream.api.grpc.v1.Controller.TxnId.Builder, io.pravega.controller.stream.api.grpc.v1.Controller.TxnIdOrBuilder>( getTxnId(), getParentForChildren(), isClean()); txnId_ = null; } return txnIdBuilder_; } public final Builder setUnknownFields(
/** * <code>.io.pravega.controller.stream.api.grpc.v1.StreamInfo streamInfo = 1;</code> */ private com.google.protobuf.SingleFieldBuilderV3< io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo, io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo.Builder, io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfoOrBuilder> getStreamInfoFieldBuilder() { if (streamInfoBuilder_ == null) { streamInfoBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo, io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo.Builder, io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfoOrBuilder>( getStreamInfo(), getParentForChildren(), isClean()); streamInfo_ = null; } return streamInfoBuilder_; }
@Override public CompletableFuture<Void> abortTransaction(final Stream stream, final UUID txId) { Exceptions.checkNotClosed(closed.get(), this); Preconditions.checkNotNull(stream, "stream"); Preconditions.checkNotNull(txId, "txId"); long traceId = LoggerHelpers.traceEnter(log, "abortTransaction", stream, txId); final CompletableFuture<TxnStatus> result = this.retryConfig.runAsync(() -> { RPCAsyncCallback<TxnStatus> callback = new RPCAsyncCallback<>(traceId, "abortTransaction"); client.abortTransaction(TxnRequest.newBuilder() .setStreamInfo(ModelHelper.createStreamInfo(stream.getScope(), stream.getStreamName())) .setTxnId(ModelHelper.decode(txId)) .build(), callback); return callback.getFuture(); }, this.executor); return Futures.toVoidExpecting(result, TxnStatus.newBuilder().setStatus(TxnStatus.Status.SUCCESS).build(), TxnFailedException::new) .whenComplete((x, e) -> { if (e != null) { log.warn("abortTransaction failed: ", e); } LoggerHelpers.traceLeave(log, "abortTransaction", traceId); }); }
@Override public CompletableFuture<Void> commitTransaction(final Stream stream, final UUID txId) { Exceptions.checkNotClosed(closed.get(), this); Preconditions.checkNotNull(stream, "stream"); Preconditions.checkNotNull(txId, "txId"); long traceId = LoggerHelpers.traceEnter(log, "commitTransaction", stream, txId); final CompletableFuture<TxnStatus> result = this.retryConfig.runAsync(() -> { RPCAsyncCallback<TxnStatus> callback = new RPCAsyncCallback<>(traceId, "commitTransaction"); client.commitTransaction(TxnRequest.newBuilder() .setStreamInfo(ModelHelper.createStreamInfo(stream.getScope(), stream.getStreamName())) .setTxnId(ModelHelper.decode(txId)) .build(), callback); return callback.getFuture(); }, this.executor); return Futures.toVoidExpecting(result, TxnStatus.newBuilder().setStatus(TxnStatus.Status.SUCCESS).build(), TxnFailedException::new) .whenComplete((x, e) -> { if (e != null) { log.warn("commitTransaction failed: ", e); } LoggerHelpers.traceLeave(log, "commitTransaction", traceId); }); }
private Controller.TxnStatus closeTransaction(final String scope, final String stream, final Controller.TxnId txnId, final boolean abort) { Controller.StreamInfo streamInfo = ModelHelper.createStreamInfo(scope, stream); Controller.TxnRequest request = Controller.TxnRequest.newBuilder() .setStreamInfo(streamInfo) .setTxnId(txnId) .build(); ResultObserver<Controller.TxnStatus> resultObserver = new ResultObserver<>(); if (abort) { this.controllerService.abortTransaction(request, resultObserver); } else { this.controllerService.commitTransaction(request, resultObserver); } Controller.TxnStatus status = resultObserver.get(); Assert.assertNotNull(status); return resultObserver.get(); }
/** * <code>.io.pravega.controller.stream.api.grpc.v1.TxnId txnId = 2;</code> */ public io.pravega.controller.stream.api.grpc.v1.Controller.TxnId.Builder getTxnIdBuilder() { onChanged(); return getTxnIdFieldBuilder().getBuilder(); } /**
/** * <code>.io.pravega.controller.stream.api.grpc.v1.StreamInfo streamInfo = 1;</code> */ public io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo.Builder getStreamInfoBuilder() { onChanged(); return getStreamInfoFieldBuilder().getBuilder(); } /**
public io.pravega.controller.stream.api.grpc.v1.Controller.TxnRequest build() { io.pravega.controller.stream.api.grpc.v1.Controller.TxnRequest result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
@java.lang.Override protected Builder newBuilderForType( com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } /**