/** * Returns TxnId object instance for a given transaction with UUID. * * @param txnId UUID * @return Instance of TxnId. */ public static final TxnId decode(final UUID txnId) { Preconditions.checkNotNull(txnId, "txnId"); return TxnId.newBuilder() .setHighBits(txnId.getMostSignificantBits()) .setLowBits(txnId.getLeastSignificantBits()) .build(); }
private TxnId convert(UUID uuid) { return TxnId.newBuilder() .setHighBits(uuid.getMostSignificantBits()) .setLowBits(uuid.getLeastSignificantBits()) .build(); }
@Test(timeout = 10000) public void testUnknownTxnPingSuccess() throws InterruptedException { UUID txnId = streamStore.generateTransactionId(SCOPE, STREAM, null, executor).join(); VersionedTransactionData txData = streamStore.createTransaction(SCOPE, STREAM, txnId, LEASE, 10 * LEASE, null, executor).join(); TxnId tx = TxnId.newBuilder() .setHighBits(txnId.getMostSignificantBits()) .setLowBits(txnId.getLeastSignificantBits()) .build(); controllerService.pingTransaction(SCOPE, STREAM, tx, LEASE); TxnStatus status = streamStore.transactionStatus(SCOPE, STREAM, txData.getId(), null, executor).join(); Assert.assertEquals(TxnStatus.OPEN, status); }
@Override public void createTransaction(CreateTxnRequest request, StreamObserver<Controller.CreateTxnResponse> responseObserver) { Controller.CreateTxnResponse.Builder builder = Controller.CreateTxnResponse.newBuilder(); if (request.getStreamInfo().getStream().equals("stream1")) { builder.setTxnId(TxnId.newBuilder().setHighBits(11L).setLowBits(22L).build()); builder.addActiveSegments(ModelHelper.createSegmentRange("scope1", "stream1", 0, 0.0, 0.5)); builder.addActiveSegments(ModelHelper.createSegmentRange("scope1", "stream1", 1, 0.5, 1.0)); responseObserver.onNext(builder.build()); responseObserver.onCompleted(); } else if (request.getStreamInfo().getStream().equals("stream2")) { builder.addActiveSegments(ModelHelper.createSegmentRange("scope1", "stream2", 0, 0.0, 1.0)); builder.setTxnId(TxnId.newBuilder().setHighBits(33L).setLowBits(44L).build()); responseObserver.onNext(builder.build()); responseObserver.onCompleted(); } else { responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException()); } }
public Builder mergeFrom(io.pravega.controller.stream.api.grpc.v1.Controller.TxnId other) { if (other == io.pravega.controller.stream.api.grpc.v1.Controller.TxnId.getDefaultInstance()) return this; if (other.getHighBits() != 0L) { setHighBits(other.getHighBits()); } if (other.getLowBits() != 0L) { setLowBits(other.getLowBits()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }