public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (streamInfo_ != null) { output.writeMessage(1, getStreamInfo()); } if (lease_ != 0L) { output.writeInt64(2, lease_); } if (scaleGracePeriod_ != 0L) { output.writeInt64(3, scaleGracePeriod_); } unknownFields.writeTo(output); }
public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (streamInfo_ != null) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(1, getStreamInfo()); } if (lease_ != 0L) { size += com.google.protobuf.CodedOutputStream .computeInt64Size(2, lease_); } if (scaleGracePeriod_ != 0L) { size += com.google.protobuf.CodedOutputStream .computeInt64Size(3, scaleGracePeriod_); } 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 (hasStreamInfo()) { hash = (37 * hash) + STREAMINFO_FIELD_NUMBER; hash = (53 * hash) + getStreamInfo().hashCode(); } hash = (37 * hash) + LEASE_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong( getLease()); hash = (37 * hash) + SCALEGRACEPERIOD_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong( getScaleGracePeriod()); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@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.CreateTxnRequest)) { return super.equals(obj); } io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest other = (io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest) obj; boolean result = true; result = result && (hasStreamInfo() == other.hasStreamInfo()); if (hasStreamInfo()) { result = result && getStreamInfo() .equals(other.getStreamInfo()); } result = result && (getLease() == other.getLease()); result = result && (getScaleGracePeriod() == other.getScaleGracePeriod()); result = result && unknownFields.equals(other.unknownFields); return result; }
@Override public void createTransaction(CreateTxnRequest request, StreamObserver<Controller.CreateTxnResponse> responseObserver) { log.info("createTransaction called for stream {}/{}.", request.getStreamInfo().getScope(), request.getStreamInfo().getStream()); authenticateExecuteAndProcessResults(() -> this.authHelper.checkAuthorizationAndCreateToken(request.getStreamInfo().getScope() + "/" + request.getStreamInfo().getStream(), AuthHandler.Permissions.READ_UPDATE), delegationToken -> controllerService.createTransaction(request.getStreamInfo().getScope(), request.getStreamInfo().getStream(), request.getLease()) .thenApply(pair -> Controller.CreateTxnResponse.newBuilder() .setDelegationToken(delegationToken) .setTxnId(ModelHelper.decode(pair.getKey())) .addAllActiveSegments(pair.getValue()) .build()), responseObserver); }
@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.CreateTxnRequest other) { if (other == io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest.getDefaultInstance()) return this; if (other.hasStreamInfo()) { mergeStreamInfo(other.getStreamInfo()); } if (other.getLease() != 0L) { setLease(other.getLease()); } if (other.getScaleGracePeriod() != 0L) { setScaleGracePeriod(other.getScaleGracePeriod()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
/** * <code>.io.pravega.controller.stream.api.grpc.v1.StreamInfo streamInfo = 1;</code> */ public io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfoOrBuilder getStreamInfoOrBuilder() { return getStreamInfo(); }