use of io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnResponse in project pravega by pravega.
the class ControllerImpl method convert.
private TxnSegments convert(CreateTxnResponse response) {
NavigableMap<Double, Segment> rangeMap = new TreeMap<>();
for (SegmentRange r : response.getActiveSegmentsList()) {
rangeMap.put(r.getMaxKey(), ModelHelper.encode(r.getSegmentId()));
}
StreamSegments segments = new StreamSegments(rangeMap, response.getDelegationToken());
return new TxnSegments(segments, ModelHelper.encode(response.getTxnId()));
}
use of io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnResponse in project pravega by pravega.
the class ControllerServiceImplTest method createTransactionFailureTest.
@Test
public void createTransactionFailureTest() {
createScopeAndStream(SCOPE1, STREAM1, ScalingPolicy.fixed(4));
StreamInfo streamInfo = ModelHelper.createStreamInfo(SCOPE1, STREAM1);
// Invalid lease
CreateTxnRequest request = CreateTxnRequest.newBuilder().setStreamInfo(streamInfo).setLease(-1).build();
ResultObserver<CreateTxnResponse> resultObserver = new ResultObserver<>();
this.controllerService.createTransaction(request, resultObserver);
AssertExtensions.assertThrows("Lease lower bound violated ", resultObserver::get, e -> checkGRPCException(e, IllegalArgumentException.class));
}
use of io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnResponse in project pravega by pravega.
the class ControllerServiceImplTest method createTransactionFailureTest.
@Test
public void createTransactionFailureTest() {
createScopeAndStream(SCOPE1, STREAM1, ScalingPolicy.fixed(4));
StreamInfo streamInfo = ModelHelper.createStreamInfo(SCOPE1, STREAM1);
// Invalid lease
CreateTxnRequest request = CreateTxnRequest.newBuilder().setStreamInfo(streamInfo).setLease(-1).setScaleGracePeriod(10000).build();
ResultObserver<CreateTxnResponse> resultObserver = new ResultObserver<>();
this.controllerService.createTransaction(request, resultObserver);
AssertExtensions.assertThrows("Lease lower bound violated ", resultObserver::get, e -> checkGRPCException(e, IllegalArgumentException.class));
// Invalid ScaleGracePeriod
request = CreateTxnRequest.newBuilder().setStreamInfo(streamInfo).setLease(10000).setScaleGracePeriod(-1).build();
ResultObserver<CreateTxnResponse> resultObserver3 = new ResultObserver<>();
this.controllerService.createTransaction(request, resultObserver3);
AssertExtensions.assertThrows("Lease lower bound violated ", resultObserver3::get, e -> checkGRPCException(e, IllegalArgumentException.class));
}
use of io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnResponse in project pravega by pravega.
the class ControllerImpl method convert.
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(encode(r.getSegmentId()), r.getMinKey(), r.getMaxKey()));
}
StreamSegments segments = new StreamSegments(rangeMap);
return new TxnSegments(segments, encode(response.getTxnId()));
}
Aggregations