public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (txnId_ != null) { output.writeMessage(1, getTxnId()); } for (int i = 0; i < activeSegments_.size(); i++) { output.writeMessage(2, activeSegments_.get(i)); } if (!getDelegationTokenBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 3, delegationToken_); } unknownFields.writeTo(output); }
public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (txnId_ != null) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(1, getTxnId()); } for (int i = 0; i < activeSegments_.size(); i++) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(2, activeSegments_.get(i)); } if (!getDelegationTokenBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, delegationToken_); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (hasTxnId()) { hash = (37 * hash) + TXNID_FIELD_NUMBER; hash = (53 * hash) + getTxnId().hashCode(); } if (getActiveSegmentsCount() > 0) { hash = (37 * hash) + ACTIVESEGMENTS_FIELD_NUMBER; hash = (53 * hash) + getActiveSegmentsList().hashCode(); } hash = (37 * hash) + DELEGATIONTOKEN_FIELD_NUMBER; hash = (53 * hash) + getDelegationToken().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
public Builder mergeFrom(io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnResponse other) { if (other == io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnResponse.getDefaultInstance()) return this; if (other.hasTxnId()) { mergeTxnId(other.getTxnId());
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnResponse)) { return super.equals(obj); } io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnResponse other = (io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnResponse) obj; boolean result = true; result = result && (hasTxnId() == other.hasTxnId()); if (hasTxnId()) { result = result && getTxnId() .equals(other.getTxnId()); } result = result && getActiveSegmentsList() .equals(other.getActiveSegmentsList()); result = result && getDelegationToken() .equals(other.getDelegationToken()); result = result && unknownFields.equals(other.unknownFields); return result; }
@Test public void transactionTests() { createScopeAndStream(SCOPE1, STREAM1, ScalingPolicy.fixed(4)); Controller.TxnId txnId1 = createTransaction(SCOPE1, STREAM1, 10000).getTxnId(); Controller.TxnId txnId2 = createTransaction(SCOPE1, STREAM1, 10000).getTxnId(); // Abort first txn. Controller.TxnStatus status = closeTransaction(SCOPE1, STREAM1, txnId1, true); Assert.assertEquals(Controller.TxnStatus.Status.SUCCESS, status.getStatus()); // Commit second txn. status = closeTransaction(SCOPE1, STREAM1, txnId2, false); Assert.assertEquals(Controller.TxnStatus.Status.SUCCESS, status.getStatus()); }
/** * <code>.io.pravega.controller.stream.api.grpc.v1.TxnId txnId = 1;</code> */ public io.pravega.controller.stream.api.grpc.v1.Controller.TxnIdOrBuilder getTxnIdOrBuilder() { return getTxnId(); }
private TxnSegments convert(CreateTxnResponse response) { NavigableMap<Double, SegmentWithRange> rangeMap = new TreeMap<>(); for (SegmentRange r : response.getActiveSegmentsList()) { Preconditions.checkState(r.getMinKey() <= r.getMaxKey()); rangeMap.put(r.getMaxKey(), new SegmentWithRange(ModelHelper.encode(r.getSegmentId()), r.getMinKey(), r.getMaxKey())); } StreamSegments segments = new StreamSegments(rangeMap, response.getDelegationToken()); return new TxnSegments(segments, ModelHelper.encode(response.getTxnId())); }