Search in sources :

Example 1 with CreateTxnRequest

use of io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest in project pravega by pravega.

the class ControllerImplTest method setup.

@Before
public void setup() throws IOException {
    // Setup test server generating different success and failure responses.
    testServerImpl = new ControllerServiceImplBase() {

        @Override
        public void createStream(StreamConfig request, StreamObserver<CreateStreamStatus> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1") || request.getStreamInfo().getStream().equals("stream8")) {
                responseObserver.onNext(CreateStreamStatus.newBuilder().setStatus(CreateStreamStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream2")) {
                responseObserver.onNext(CreateStreamStatus.newBuilder().setStatus(CreateStreamStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream3")) {
                responseObserver.onNext(CreateStreamStatus.newBuilder().setStatus(CreateStreamStatus.Status.SCOPE_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream4")) {
                responseObserver.onNext(CreateStreamStatus.newBuilder().setStatus(CreateStreamStatus.Status.STREAM_EXISTS).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream5")) {
                responseObserver.onNext(CreateStreamStatus.newBuilder().setStatus(CreateStreamStatus.Status.INVALID_STREAM_NAME).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("streamparallel")) {
                // Simulating delay in sending response.
                Exceptions.handleInterrupted(() -> Thread.sleep(500));
                responseObserver.onNext(CreateStreamStatus.newBuilder().setStatus(CreateStreamStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("streamdelayed")) {
                // Simulating delay in sending response. This is used for the keepalive test,
                // where response time > 30 seconds is required to simulate a failure.
                Exceptions.handleInterrupted(() -> Thread.sleep(40000));
                responseObserver.onNext(CreateStreamStatus.newBuilder().setStatus(CreateStreamStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("streamretryfailure")) {
                responseObserver.onError(Status.UNKNOWN.withDescription("Transport error").asRuntimeException());
            } else if (request.getStreamInfo().getStream().equals("streamretrysuccess")) {
                if (retryAttempts.incrementAndGet() > 3) {
                    responseObserver.onNext(CreateStreamStatus.newBuilder().setStatus(CreateStreamStatus.Status.SUCCESS).build());
                    responseObserver.onCompleted();
                } else {
                    responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
                }
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void updateStream(StreamConfig request, StreamObserver<UpdateStreamStatus> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream2")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream3")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.SCOPE_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream4")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.STREAM_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream5")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.UNRECOGNIZED).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void truncateStream(Controller.StreamCut request, StreamObserver<UpdateStreamStatus> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream2")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream3")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.SCOPE_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream4")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.STREAM_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream5")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.UNRECOGNIZED).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void sealStream(StreamInfo request, StreamObserver<UpdateStreamStatus> responseObserver) {
            if (request.getStream().equals("stream1")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("stream2")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("stream3")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.SCOPE_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("stream4")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.STREAM_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void deleteStream(StreamInfo request, StreamObserver<DeleteStreamStatus> responseObserver) {
            if (request.getStream().equals("stream1")) {
                responseObserver.onNext(DeleteStreamStatus.newBuilder().setStatus(DeleteStreamStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("stream2")) {
                responseObserver.onNext(DeleteStreamStatus.newBuilder().setStatus(DeleteStreamStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("stream3")) {
                responseObserver.onNext(DeleteStreamStatus.newBuilder().setStatus(DeleteStreamStatus.Status.STREAM_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("stream4")) {
                responseObserver.onNext(DeleteStreamStatus.newBuilder().setStatus(DeleteStreamStatus.Status.STREAM_NOT_SEALED).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void getCurrentSegments(StreamInfo request, StreamObserver<SegmentRanges> responseObserver) {
            if (request.getStream().equals("stream1")) {
                responseObserver.onNext(SegmentRanges.newBuilder().addSegmentRanges(ModelHelper.createSegmentRange("scope1", "stream1", 6, 0.0, 0.4)).addSegmentRanges(ModelHelper.createSegmentRange("scope1", "stream1", 7, 0.4, 1.0)).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("stream8")) {
                responseObserver.onNext(SegmentRanges.newBuilder().addSegmentRanges(ModelHelper.createSegmentRange("scope1", "stream8", 9, 0.0, 0.5)).addSegmentRanges(ModelHelper.createSegmentRange("scope1", "stream8", 10, 0.5, 1.0)).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("streamparallel")) {
                Exceptions.handleInterrupted(() -> Thread.sleep(500));
                responseObserver.onNext(SegmentRanges.newBuilder().addSegmentRanges(ModelHelper.createSegmentRange("scope1", "streamparallel", 0, 0.0, 0.4)).addSegmentRanges(ModelHelper.createSegmentRange("scope1", "streamparallel", 1, 0.4, 1.0)).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void getSegments(GetSegmentsRequest request, StreamObserver<SegmentsAtTime> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                SegmentId segment1 = ModelHelper.createSegmentId("scope1", "stream1", 0);
                SegmentId segment2 = ModelHelper.createSegmentId("scope1", "stream1", 1);
                responseObserver.onNext(SegmentsAtTime.newBuilder().addSegments(SegmentLocation.newBuilder().setSegmentId(segment1).setOffset(10).build()).addSegments(SegmentLocation.newBuilder().setSegmentId(segment2).setOffset(20).build()).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream8")) {
                SegmentId segment1 = ModelHelper.createSegmentId("scope1", "stream8", 0);
                SegmentId segment2 = ModelHelper.createSegmentId("scope1", "stream8", 1);
                SegmentId segment3 = ModelHelper.createSegmentId("scope1", "stream8", 2);
                responseObserver.onNext(SegmentsAtTime.newBuilder().addSegments(SegmentLocation.newBuilder().setSegmentId(segment1).setOffset(10).build()).addSegments(SegmentLocation.newBuilder().setSegmentId(segment2).setOffset(20).build()).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void getSegmentsImmediatlyFollowing(SegmentId request, StreamObserver<SuccessorResponse> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                Map<SegmentId, Pair<Double, Double>> result = new HashMap<>();
                if (request.getSegmentNumber() == 0) {
                    result.put(ModelHelper.createSegmentId("scope1", "stream1", 2), Pair.of(0.0, 0.25));
                    result.put(ModelHelper.createSegmentId("scope1", "stream1", 3), Pair.of(0.25, 0.5));
                } else if (request.getSegmentNumber() == 1) {
                    result.put(ModelHelper.createSegmentId("scope1", "stream1", 4), Pair.of(0.5, 0.75));
                    result.put(ModelHelper.createSegmentId("scope1", "stream1", 5), Pair.of(0.75, 1.0));
                } else if (request.getSegmentNumber() == 2 || request.getSegmentNumber() == 3) {
                    result.put(ModelHelper.createSegmentId("scope1", "stream1", 6), Pair.of(0.0, 0.5));
                } else if (request.getSegmentNumber() == 4 || request.getSegmentNumber() == 5) {
                    result.put(ModelHelper.createSegmentId("scope1", "stream1", 7), Pair.of(0.5, 0.25));
                }
                val builder = SuccessorResponse.newBuilder();
                for (Entry<SegmentId, Pair<Double, Double>> entry : result.entrySet()) {
                    builder.addSegments(SuccessorResponse.SegmentEntry.newBuilder().setSegment(Controller.SegmentRange.newBuilder().setSegmentId(entry.getKey()).setMinKey(entry.getValue().getLeft()).setMaxKey(entry.getValue().getRight()).build()).addValue(10 * entry.getKey().getSegmentNumber()).build());
                }
                responseObserver.onNext(builder.build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream8")) {
                Map<SegmentId, Pair<Double, Double>> result = new HashMap<>();
                if (request.getSegmentNumber() == 0) {
                    result.put(ModelHelper.createSegmentId("scope1", "stream8", 3), Pair.of(0.0, 0.2));
                    result.put(ModelHelper.createSegmentId("scope1", "stream8", 4), Pair.of(0.2, 0.33));
                } else if (request.getSegmentNumber() == 1) {
                    result.put(ModelHelper.createSegmentId("scope1", "stream8", 5), Pair.of(0.33, 0.5));
                    result.put(ModelHelper.createSegmentId("scope1", "stream8", 6), Pair.of(0.5, 0.66));
                } else if (request.getSegmentNumber() == 2) {
                    result.put(ModelHelper.createSegmentId("scope1", "stream8", 7), Pair.of(0.66, 0.8));
                    result.put(ModelHelper.createSegmentId("scope1", "stream8", 8), Pair.of(0.8, 1.0));
                } else if (request.getSegmentNumber() == 3 || request.getSegmentNumber() == 4 || request.getSegmentNumber() == 5) {
                    result.put(ModelHelper.createSegmentId("scope1", "stream8", 9), Pair.of(0.0, 0.5));
                } else if (request.getSegmentNumber() == 6 || request.getSegmentNumber() == 7 || request.getSegmentNumber() == 8) {
                    result.put(ModelHelper.createSegmentId("scope1", "stream8", 10), Pair.of(0.5, 1.0));
                }
                val builder = SuccessorResponse.newBuilder();
                for (Entry<SegmentId, Pair<Double, Double>> entry : result.entrySet()) {
                    builder.addSegments(SuccessorResponse.SegmentEntry.newBuilder().setSegment(Controller.SegmentRange.newBuilder().setSegmentId(entry.getKey()).setMinKey(entry.getValue().getLeft()).setMaxKey(entry.getValue().getRight()).build()).addValue(10 * entry.getKey().getSegmentNumber()).build());
                }
                responseObserver.onNext(builder.build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void scale(ScaleRequest request, StreamObserver<ScaleResponse> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(ScaleResponse.newBuilder().setStatus(ScaleResponse.ScaleStreamStatus.STARTED).addSegments(ModelHelper.createSegmentRange("scope1", "stream1", 0, 0.0, 0.5)).addSegments(ModelHelper.createSegmentRange("scope1", "stream1", 1, 0.5, 1.0)).setEpoch(0).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void checkScale(ScaleStatusRequest request, StreamObserver<ScaleStatusResponse> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(ScaleStatusResponse.newBuilder().setStatus(ScaleStatusResponse.ScaleStatus.SUCCESS).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void getURI(SegmentId request, StreamObserver<NodeUri> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(NodeUri.newBuilder().setEndpoint("localhost").setPort(SERVICE_PORT).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void isSegmentValid(SegmentId request, StreamObserver<SegmentValidityResponse> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(SegmentValidityResponse.newBuilder().setResponse(true).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream2")) {
                responseObserver.onNext(SegmentValidityResponse.newBuilder().setResponse(false).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @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());
            }
        }

        @Override
        public void commitTransaction(TxnRequest request, StreamObserver<Controller.TxnStatus> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(Controller.TxnStatus.newBuilder().setStatus(Controller.TxnStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream2")) {
                responseObserver.onNext(Controller.TxnStatus.newBuilder().setStatus(Controller.TxnStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream3")) {
                responseObserver.onNext(Controller.TxnStatus.newBuilder().setStatus(Controller.TxnStatus.Status.STREAM_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream4")) {
                responseObserver.onNext(Controller.TxnStatus.newBuilder().setStatus(Controller.TxnStatus.Status.TRANSACTION_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void abortTransaction(TxnRequest request, StreamObserver<Controller.TxnStatus> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(Controller.TxnStatus.newBuilder().setStatus(Controller.TxnStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream2")) {
                responseObserver.onNext(Controller.TxnStatus.newBuilder().setStatus(Controller.TxnStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream3")) {
                responseObserver.onNext(Controller.TxnStatus.newBuilder().setStatus(Controller.TxnStatus.Status.STREAM_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream4")) {
                responseObserver.onNext(Controller.TxnStatus.newBuilder().setStatus(Controller.TxnStatus.Status.TRANSACTION_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void pingTransaction(PingTxnRequest request, StreamObserver<PingTxnStatus> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(PingTxnStatus.newBuilder().setStatus(PingTxnStatus.Status.OK).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void checkTransactionState(TxnRequest request, StreamObserver<TxnState> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(TxnState.newBuilder().setState(TxnState.State.OPEN).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream2")) {
                responseObserver.onNext(TxnState.newBuilder().setState(TxnState.State.UNKNOWN).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream3")) {
                responseObserver.onNext(TxnState.newBuilder().setState(TxnState.State.COMMITTING).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream4")) {
                responseObserver.onNext(TxnState.newBuilder().setState(TxnState.State.COMMITTED).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream5")) {
                responseObserver.onNext(TxnState.newBuilder().setState(TxnState.State.ABORTING).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream6")) {
                responseObserver.onNext(TxnState.newBuilder().setState(TxnState.State.ABORTED).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void createScope(ScopeInfo request, StreamObserver<CreateScopeStatus> responseObserver) {
            if (request.getScope().equals("scope1")) {
                responseObserver.onNext(CreateScopeStatus.newBuilder().setStatus(CreateScopeStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getScope().equals("scope2")) {
                responseObserver.onNext(CreateScopeStatus.newBuilder().setStatus(CreateScopeStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getScope().equals("scope3")) {
                responseObserver.onNext(CreateScopeStatus.newBuilder().setStatus(CreateScopeStatus.Status.INVALID_SCOPE_NAME).build());
                responseObserver.onCompleted();
            } else if (request.getScope().equals("scope4")) {
                responseObserver.onNext(CreateScopeStatus.newBuilder().setStatus(CreateScopeStatus.Status.SCOPE_EXISTS).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void getDelegationToken(io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo request, io.grpc.stub.StreamObserver<io.pravega.controller.stream.api.grpc.v1.Controller.DelegationToken> responseObserver) {
            responseObserver.onNext(Controller.DelegationToken.newBuilder().setDelegationToken("token").build());
            responseObserver.onCompleted();
        }

        @Override
        public void deleteScope(ScopeInfo request, StreamObserver<DeleteScopeStatus> responseObserver) {
            if (request.getScope().equals("scope1")) {
                responseObserver.onNext(DeleteScopeStatus.newBuilder().setStatus(DeleteScopeStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getScope().equals("scope2")) {
                responseObserver.onNext(DeleteScopeStatus.newBuilder().setStatus(DeleteScopeStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getScope().equals("scope3")) {
                responseObserver.onNext(DeleteScopeStatus.newBuilder().setStatus(DeleteScopeStatus.Status.SCOPE_NOT_EMPTY).build());
                responseObserver.onCompleted();
            } else if (request.getScope().equals("scope4")) {
                responseObserver.onNext(DeleteScopeStatus.newBuilder().setStatus(DeleteScopeStatus.Status.SCOPE_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }
    };
    serverPort = TestUtils.getAvailableListenPort();
    serverBuilder = NettyServerBuilder.forPort(serverPort).addService(testServerImpl);
    if (testSecure) {
        serverBuilder = serverBuilder.useTransportSecurity(new File("../config/cert.pem"), new File("../config/key.pem"));
        creds = new DefaultCredentials("1111_aaaa", "admin");
    }
    testGRPCServer = serverBuilder.build().start();
    executor = Executors.newSingleThreadScheduledExecutor();
    controllerClient = new ControllerImpl(ControllerImplConfig.builder().clientConfig(ClientConfig.builder().controllerURI(URI.create((testSecure ? "tls://" : "tcp://") + "localhost:" + serverPort)).credentials(new DefaultCredentials("1111_aaaa", "admin")).trustStore("../config/cert.pem").build()).retryAttempts(1).build(), executor);
}
Also used : ScaleStatusRequest(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleStatusRequest) HashMap(java.util.HashMap) NettyServerBuilder(io.grpc.netty.NettyServerBuilder) NettyChannelBuilder(io.grpc.netty.NettyChannelBuilder) PingTxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnRequest) CreateTxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest) TxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.TxnRequest) UpdateStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateStreamStatus) CreateScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateScopeStatus) SuccessorResponse(io.pravega.controller.stream.api.grpc.v1.Controller.SuccessorResponse) ScaleRequest(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleRequest) lombok.val(lombok.val) ScaleStatusResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleStatusResponse) PravegaNodeUri(io.pravega.shared.protocol.netty.PravegaNodeUri) NodeUri(io.pravega.controller.stream.api.grpc.v1.Controller.NodeUri) PingTxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnRequest) TxnState(io.pravega.controller.stream.api.grpc.v1.Controller.TxnState) SegmentRanges(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRanges) GetSegmentsRequest(io.pravega.controller.stream.api.grpc.v1.Controller.GetSegmentsRequest) CreateTxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest) Map(java.util.Map) HashMap(java.util.HashMap) File(java.io.File) SegmentsAtTime(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentsAtTime) SegmentValidityResponse(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentValidityResponse) PingTxnStatus(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus) Entry(java.util.Map.Entry) StreamInfo(io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo) Pair(org.apache.commons.lang3.tuple.Pair) ControllerServiceImplBase(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceImplBase) CreateStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateStreamStatus) SegmentId(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentId) StreamConfig(io.pravega.controller.stream.api.grpc.v1.Controller.StreamConfig) ScaleResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleResponse) ScopeInfo(io.pravega.controller.stream.api.grpc.v1.Controller.ScopeInfo) Controller(io.pravega.controller.stream.api.grpc.v1.Controller) DeleteScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteScopeStatus) DeleteStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteStreamStatus) StreamInfo(io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo) PingTxnStatus(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus) Before(org.junit.Before)

Example 2 with CreateTxnRequest

use of io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest in project pravega by pravega.

the class ControllerImplTest method setup.

@Before
public void setup() throws IOException {
    // Setup test server generating different success and failure responses.
    testServerImpl = new ControllerServiceImplBase() {

        @Override
        public void listScopes(Controller.ScopesRequest request, StreamObserver<Controller.ScopesResponse> responseObserver) {
            if (Strings.isNullOrEmpty(request.getContinuationToken().getToken())) {
                List<String> list1 = new LinkedList<>();
                list1.add("scope1");
                list1.add("scope2");
                responseObserver.onNext(Controller.ScopesResponse.newBuilder().addAllScopes(list1).setContinuationToken(Controller.ContinuationToken.newBuilder().setToken("myToken").build()).build());
                responseObserver.onCompleted();
            } else if (request.getContinuationToken().getToken().equals("myToken")) {
                List<String> list2 = new LinkedList<>();
                list2.add("scope3");
                responseObserver.onNext(Controller.ScopesResponse.newBuilder().addAllScopes(list2).setContinuationToken(Controller.ContinuationToken.newBuilder().setToken("myToken2").build()).build());
                responseObserver.onCompleted();
            } else if (request.getContinuationToken().getToken().equals("myToken2")) {
                List<String> list3 = new LinkedList<>();
                responseObserver.onNext(Controller.ScopesResponse.newBuilder().addAllScopes(list3).setContinuationToken(Controller.ContinuationToken.newBuilder().setToken("myToken2").build()).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void checkScopeExists(ScopeInfo request, StreamObserver<Controller.ExistsResponse> responseObserver) {
            if (!request.getScope().equals("throwing")) {
                responseObserver.onNext(Controller.ExistsResponse.newBuilder().setExists(request.getScope().equals("scope1")).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void checkStreamExists(StreamInfo request, StreamObserver<Controller.ExistsResponse> responseObserver) {
            if (!request.getScope().equals("throwing")) {
                responseObserver.onNext(Controller.ExistsResponse.newBuilder().setExists(request.getStream().equals("stream1")).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void createStream(StreamConfig request, StreamObserver<CreateStreamStatus> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1") || request.getStreamInfo().getStream().equals("stream8")) {
                responseObserver.onNext(CreateStreamStatus.newBuilder().setStatus(CreateStreamStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream2")) {
                responseObserver.onNext(CreateStreamStatus.newBuilder().setStatus(CreateStreamStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream3")) {
                responseObserver.onNext(CreateStreamStatus.newBuilder().setStatus(CreateStreamStatus.Status.SCOPE_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream4")) {
                responseObserver.onNext(CreateStreamStatus.newBuilder().setStatus(CreateStreamStatus.Status.STREAM_EXISTS).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream5")) {
                responseObserver.onNext(CreateStreamStatus.newBuilder().setStatus(CreateStreamStatus.Status.INVALID_STREAM_NAME).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("streamparallel")) {
                // Simulating delay in sending response.
                Exceptions.handleInterrupted(() -> Thread.sleep(500));
                responseObserver.onNext(CreateStreamStatus.newBuilder().setStatus(CreateStreamStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("streamdelayed")) {
                // Simulating delay in sending response. This is used for the keepalive test,
                // where response time > 30 seconds is required to simulate a failure.
                Exceptions.handleInterrupted(() -> Thread.sleep(KEEP_ALIVE_TEST_STREAM_CREATE_DELAY_MILLIS));
                responseObserver.onNext(CreateStreamStatus.newBuilder().setStatus(CreateStreamStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("streamretryfailure")) {
                responseObserver.onError(Status.UNKNOWN.withDescription("Transport error").asRuntimeException());
            } else if (request.getStreamInfo().getStream().equals("streamretrysuccess")) {
                if (retryAttempts.incrementAndGet() > 3) {
                    responseObserver.onNext(CreateStreamStatus.newBuilder().setStatus(CreateStreamStatus.Status.SUCCESS).build());
                    responseObserver.onCompleted();
                } else {
                    responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
                }
            } else if (request.getStreamInfo().getStream().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void getStreamConfiguration(StreamInfo request, StreamObserver<StreamConfig> responseObserver) {
            StreamConfiguration cfg = StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(3)).tag("tx").build();
            if (request.getStream().equals("stream1")) {
                responseObserver.onNext(decode(request.getScope(), request.getStream(), cfg));
                responseObserver.onCompleted();
            } else if (request.getStream().equals("stream2")) {
                responseObserver.onNext(decode(request.getScope(), request.getStream(), cfg.toBuilder().clearTags().build()));
                responseObserver.onCompleted();
            } else if (request.getStream().equals("stream3")) {
                responseObserver.onError(Status.NOT_FOUND.asRuntimeException());
            } else if (request.getStream().equals("deadline")) {
            // do not send any response.
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void updateStream(StreamConfig request, StreamObserver<UpdateStreamStatus> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream2")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream3")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.SCOPE_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream4")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.STREAM_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream5")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.UNRECOGNIZED).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void listSubscribers(StreamInfo request, StreamObserver<SubscribersResponse> responseObserver) {
            if (request.getStream().equals("stream1")) {
                responseObserver.onNext(SubscribersResponse.newBuilder().setStatus(SubscribersResponse.Status.SUCCESS).addSubscribers("sub1").addSubscribers("sub2").addSubscribers("sub3").build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("stream2")) {
                responseObserver.onNext(SubscribersResponse.newBuilder().setStatus(SubscribersResponse.Status.STREAM_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void createReaderGroup(ReaderGroupConfiguration request, StreamObserver<CreateReaderGroupResponse> responseObserver) {
            if (request.getReaderGroupName().equals("rg1")) {
                responseObserver.onNext(CreateReaderGroupResponse.newBuilder().setConfig(request).setStatus(CreateReaderGroupResponse.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getReaderGroupName().equals("rg2")) {
                responseObserver.onNext(CreateReaderGroupResponse.newBuilder().setConfig(request).setStatus(CreateReaderGroupResponse.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getReaderGroupName().equals("rg3")) {
                responseObserver.onNext(CreateReaderGroupResponse.newBuilder().setConfig(request).setStatus(CreateReaderGroupResponse.Status.SCOPE_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getReaderGroupName().equals("rg4")) {
                responseObserver.onNext(CreateReaderGroupResponse.newBuilder().setConfig(request).setStatus(CreateReaderGroupResponse.Status.INVALID_RG_NAME).build());
                responseObserver.onCompleted();
            }
        }

        @Override
        public void updateReaderGroup(ReaderGroupConfiguration request, StreamObserver<UpdateReaderGroupResponse> responseObserver) {
            if (request.getReaderGroupName().equals("rg1")) {
                responseObserver.onNext(UpdateReaderGroupResponse.newBuilder().setStatus(UpdateReaderGroupResponse.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getReaderGroupName().equals("rg2")) {
                responseObserver.onNext(UpdateReaderGroupResponse.newBuilder().setStatus(UpdateReaderGroupResponse.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getReaderGroupName().equals("rg3")) {
                responseObserver.onNext(UpdateReaderGroupResponse.newBuilder().setStatus(UpdateReaderGroupResponse.Status.RG_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getReaderGroupName().equals("rg4")) {
                responseObserver.onNext(UpdateReaderGroupResponse.newBuilder().setStatus(UpdateReaderGroupResponse.Status.INVALID_CONFIG).build());
                responseObserver.onCompleted();
            }
        }

        @Override
        public void deleteReaderGroup(ReaderGroupInfo request, StreamObserver<DeleteReaderGroupStatus> responseObserver) {
            if (request.getReaderGroup().equals("rg1")) {
                responseObserver.onNext(DeleteReaderGroupStatus.newBuilder().setStatus(DeleteReaderGroupStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getReaderGroup().equals("rg2")) {
                responseObserver.onNext(DeleteReaderGroupStatus.newBuilder().setStatus(DeleteReaderGroupStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getReaderGroup().equals("rg3")) {
                responseObserver.onNext(DeleteReaderGroupStatus.newBuilder().setStatus(DeleteReaderGroupStatus.Status.RG_NOT_FOUND).build());
                responseObserver.onCompleted();
            }
        }

        @Override
        public void getReaderGroupConfig(ReaderGroupInfo request, StreamObserver<ReaderGroupConfigResponse> responseObserver) {
            final Segment seg0 = new Segment("scope1", "stream1", 0L);
            final Segment seg1 = new Segment("scope1", "stream1", 1L);
            ImmutableMap<Segment, Long> startStreamCut = ImmutableMap.of(seg0, 10L, seg1, 10L);
            Map<Stream, StreamCut> startSC = ImmutableMap.of(Stream.of("scope1", "stream1"), new StreamCutImpl(Stream.of("scope1", "stream1"), startStreamCut));
            ImmutableMap<Segment, Long> endStreamCut = ImmutableMap.of(seg0, 200L, seg1, 300L);
            Map<Stream, StreamCut> endSC = ImmutableMap.of(Stream.of("scope1", "stream1"), new StreamCutImpl(Stream.of("scope1", "stream1"), endStreamCut));
            ReaderGroupConfig rgConfig = ReaderGroupConfig.builder().automaticCheckpointIntervalMillis(30000L).groupRefreshTimeMillis(20000L).maxOutstandingCheckpointRequest(2).retentionType(ReaderGroupConfig.StreamDataRetention.AUTOMATIC_RELEASE_AT_LAST_CHECKPOINT).startingStreamCuts(startSC).endingStreamCuts(endSC).build();
            rgConfig = ReaderGroupConfig.cloneConfig(rgConfig, UUID.randomUUID(), 0L);
            if (request.getReaderGroup().equals("rg1")) {
                responseObserver.onNext(ReaderGroupConfigResponse.newBuilder().setStatus(ReaderGroupConfigResponse.Status.SUCCESS).setConfig(decode("scope1", "rg1", rgConfig)).build());
                responseObserver.onCompleted();
            } else if (request.getReaderGroup().equals("rg2")) {
                responseObserver.onNext(ReaderGroupConfigResponse.newBuilder().setStatus(ReaderGroupConfigResponse.Status.FAILURE).setConfig(ReaderGroupConfiguration.getDefaultInstance()).build());
                responseObserver.onCompleted();
            } else if (request.getReaderGroup().equals("rg3")) {
                responseObserver.onNext(ReaderGroupConfigResponse.newBuilder().setStatus(ReaderGroupConfigResponse.Status.RG_NOT_FOUND).setConfig(ReaderGroupConfiguration.getDefaultInstance()).build());
                responseObserver.onCompleted();
            }
        }

        @Override
        public void updateSubscriberStreamCut(SubscriberStreamCut request, StreamObserver<UpdateSubscriberStatus> responseObserver) {
            if (request.getStreamCut().getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(UpdateSubscriberStatus.newBuilder().setStatus(UpdateSubscriberStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStreamCut().getStreamInfo().getStream().equals("stream2")) {
                responseObserver.onNext(UpdateSubscriberStatus.newBuilder().setStatus(UpdateSubscriberStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getStreamCut().getStreamInfo().getStream().equals("stream3")) {
                responseObserver.onNext(UpdateSubscriberStatus.newBuilder().setStatus(UpdateSubscriberStatus.Status.STREAM_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStreamCut().getStreamInfo().getStream().equals("stream4")) {
                responseObserver.onNext(UpdateSubscriberStatus.newBuilder().setStatus(UpdateSubscriberStatus.Status.UNRECOGNIZED).build());
                responseObserver.onCompleted();
            } else if (request.getStreamCut().getStreamInfo().getStream().equals("stream5")) {
                responseObserver.onNext(UpdateSubscriberStatus.newBuilder().setStatus(UpdateSubscriberStatus.Status.STREAM_CUT_NOT_VALID).build());
                responseObserver.onCompleted();
            } else if (request.getStreamCut().getStreamInfo().getStream().equals("stream6")) {
                responseObserver.onNext(UpdateSubscriberStatus.newBuilder().setStatus(UpdateSubscriberStatus.Status.SUBSCRIBER_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStreamCut().getStreamInfo().getStream().equals("stream7")) {
                responseObserver.onNext(UpdateSubscriberStatus.newBuilder().setStatus(UpdateSubscriberStatus.Status.GENERATION_MISMATCH).build());
                responseObserver.onCompleted();
            } else if (request.getStreamCut().getStreamInfo().getStream().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void truncateStream(Controller.StreamCut request, StreamObserver<UpdateStreamStatus> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream2")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream3")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.SCOPE_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream4")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.STREAM_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream5")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.UNRECOGNIZED).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void sealStream(StreamInfo request, StreamObserver<UpdateStreamStatus> responseObserver) {
            if (request.getStream().equals("stream1")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("stream2")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("stream3")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.SCOPE_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("stream4")) {
                responseObserver.onNext(UpdateStreamStatus.newBuilder().setStatus(UpdateStreamStatus.Status.STREAM_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void deleteStream(StreamInfo request, StreamObserver<DeleteStreamStatus> responseObserver) {
            if (request.getStream().equals("stream1")) {
                responseObserver.onNext(DeleteStreamStatus.newBuilder().setStatus(DeleteStreamStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("stream2")) {
                responseObserver.onNext(DeleteStreamStatus.newBuilder().setStatus(DeleteStreamStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("stream3")) {
                responseObserver.onNext(DeleteStreamStatus.newBuilder().setStatus(DeleteStreamStatus.Status.STREAM_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("stream4")) {
                responseObserver.onNext(DeleteStreamStatus.newBuilder().setStatus(DeleteStreamStatus.Status.STREAM_NOT_SEALED).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void getCurrentSegments(StreamInfo request, StreamObserver<SegmentRanges> responseObserver) {
            if (request.getStream().equals("stream1")) {
                responseObserver.onNext(SegmentRanges.newBuilder().addSegmentRanges(ModelHelper.createSegmentRange("scope1", "stream1", 6, 0.0, 0.4)).addSegmentRanges(ModelHelper.createSegmentRange("scope1", "stream1", 7, 0.4, 1.0)).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("stream8")) {
                responseObserver.onNext(SegmentRanges.newBuilder().addSegmentRanges(ModelHelper.createSegmentRange("scope1", "stream8", 9, 0.0, 0.5)).addSegmentRanges(ModelHelper.createSegmentRange("scope1", "stream8", 10, 0.5, 1.0)).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("streamparallel")) {
                Exceptions.handleInterrupted(() -> Thread.sleep(500));
                responseObserver.onNext(SegmentRanges.newBuilder().addSegmentRanges(ModelHelper.createSegmentRange("scope1", "streamparallel", 0, 0.0, 0.4)).addSegmentRanges(ModelHelper.createSegmentRange("scope1", "streamparallel", 1, 0.4, 1.0)).build());
                responseObserver.onCompleted();
            } else if (request.getStream().equals("deadline")) {
            // dont send any response
            } else if (request.getStream().equals("sealedStream")) {
                // empty response if the Stream is sealed.
                responseObserver.onNext(SegmentRanges.newBuilder().build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void getEpochSegments(GetEpochSegmentsRequest request, StreamObserver<io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRanges> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(SegmentRanges.newBuilder().addSegmentRanges(ModelHelper.createSegmentRange("scope1", "stream1", 6, 0.0, 0.4)).addSegmentRanges(ModelHelper.createSegmentRange("scope1", "stream1", 7, 0.4, 1.0)).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void getSegments(GetSegmentsRequest request, StreamObserver<SegmentsAtTime> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                SegmentId segment1 = ModelHelper.createSegmentId("scope1", "stream1", 0);
                SegmentId segment2 = ModelHelper.createSegmentId("scope1", "stream1", 1);
                responseObserver.onNext(SegmentsAtTime.newBuilder().addSegments(SegmentLocation.newBuilder().setSegmentId(segment1).setOffset(10).build()).addSegments(SegmentLocation.newBuilder().setSegmentId(segment2).setOffset(20).build()).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream8")) {
                SegmentId segment1 = ModelHelper.createSegmentId("scope1", "stream8", 0);
                SegmentId segment2 = ModelHelper.createSegmentId("scope1", "stream8", 1);
                SegmentId segment3 = ModelHelper.createSegmentId("scope1", "stream8", 2);
                responseObserver.onNext(SegmentsAtTime.newBuilder().addSegments(SegmentLocation.newBuilder().setSegmentId(segment1).setOffset(10).build()).addSegments(SegmentLocation.newBuilder().setSegmentId(segment2).setOffset(20).build()).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void getSegmentsImmediatelyFollowing(SegmentId request, StreamObserver<SuccessorResponse> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                Map<SegmentId, Pair<Double, Double>> result = new HashMap<>();
                if (request.getSegmentId() == 0) {
                    result.put(ModelHelper.createSegmentId("scope1", "stream1", 2), Pair.of(0.0, 0.25));
                    result.put(ModelHelper.createSegmentId("scope1", "stream1", 3), Pair.of(0.25, 0.5));
                } else if (request.getSegmentId() == 1) {
                    result.put(ModelHelper.createSegmentId("scope1", "stream1", 4), Pair.of(0.5, 0.75));
                    result.put(ModelHelper.createSegmentId("scope1", "stream1", 5), Pair.of(0.75, 1.0));
                } else if (request.getSegmentId() == 2 || request.getSegmentId() == 3) {
                    result.put(ModelHelper.createSegmentId("scope1", "stream1", 6), Pair.of(0.0, 0.5));
                } else if (request.getSegmentId() == 4 || request.getSegmentId() == 5) {
                    result.put(ModelHelper.createSegmentId("scope1", "stream1", 7), Pair.of(0.5, 0.25));
                }
                val builder = SuccessorResponse.newBuilder();
                for (Entry<SegmentId, Pair<Double, Double>> entry : result.entrySet()) {
                    builder.addSegments(SuccessorResponse.SegmentEntry.newBuilder().setSegment(Controller.SegmentRange.newBuilder().setSegmentId(entry.getKey()).setMinKey(entry.getValue().getLeft()).setMaxKey(entry.getValue().getRight()).build()).addValue(10 * entry.getKey().getSegmentId()).build());
                }
                responseObserver.onNext(builder.build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream8")) {
                Map<SegmentId, Pair<Double, Double>> result = new HashMap<>();
                if (request.getSegmentId() == 0) {
                    result.put(ModelHelper.createSegmentId("scope1", "stream8", 3), Pair.of(0.0, 0.2));
                    result.put(ModelHelper.createSegmentId("scope1", "stream8", 4), Pair.of(0.2, 0.33));
                } else if (request.getSegmentId() == 1) {
                    result.put(ModelHelper.createSegmentId("scope1", "stream8", 5), Pair.of(0.33, 0.5));
                    result.put(ModelHelper.createSegmentId("scope1", "stream8", 6), Pair.of(0.5, 0.66));
                } else if (request.getSegmentId() == 2) {
                    result.put(ModelHelper.createSegmentId("scope1", "stream8", 7), Pair.of(0.66, 0.8));
                    result.put(ModelHelper.createSegmentId("scope1", "stream8", 8), Pair.of(0.8, 1.0));
                } else if (request.getSegmentId() == 3 || request.getSegmentId() == 4 || request.getSegmentId() == 5) {
                    result.put(ModelHelper.createSegmentId("scope1", "stream8", 9), Pair.of(0.0, 0.5));
                } else if (request.getSegmentId() == 6 || request.getSegmentId() == 7 || request.getSegmentId() == 8) {
                    result.put(ModelHelper.createSegmentId("scope1", "stream8", 10), Pair.of(0.5, 1.0));
                }
                val builder = SuccessorResponse.newBuilder();
                for (Entry<SegmentId, Pair<Double, Double>> entry : result.entrySet()) {
                    builder.addSegments(SuccessorResponse.SegmentEntry.newBuilder().setSegment(Controller.SegmentRange.newBuilder().setSegmentId(entry.getKey()).setMinKey(entry.getValue().getLeft()).setMaxKey(entry.getValue().getRight()).build()).addValue(10 * entry.getKey().getSegmentId()).build());
                }
                responseObserver.onNext(builder.build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void getSegmentsBetween(Controller.StreamCutRange request, StreamObserver<Controller.StreamCutRangeResponse> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                SegmentId segment1 = ModelHelper.createSegmentId("scope1", "stream1", 0L);
                SegmentId segment2 = ModelHelper.createSegmentId("scope1", "stream1", 1L);
                responseObserver.onNext(Controller.StreamCutRangeResponse.newBuilder().addSegments(segment1).addSegments(segment2).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void scale(ScaleRequest request, StreamObserver<ScaleResponse> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(ScaleResponse.newBuilder().setStatus(ScaleResponse.ScaleStreamStatus.STARTED).addSegments(ModelHelper.createSegmentRange("scope1", "stream1", 0, 0.0, 0.5)).addSegments(ModelHelper.createSegmentRange("scope1", "stream1", 1, 0.5, 1.0)).setEpoch(0).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("deadline")) {
            // dont send response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void checkScale(ScaleStatusRequest request, StreamObserver<ScaleStatusResponse> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(ScaleStatusResponse.newBuilder().setStatus(ScaleStatusResponse.ScaleStatus.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void getURI(SegmentId request, StreamObserver<NodeUri> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(NodeUri.newBuilder().setEndpoint("localhost").setPort(SERVICE_PORT).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void isSegmentValid(SegmentId request, StreamObserver<SegmentValidityResponse> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(SegmentValidityResponse.newBuilder().setResponse(true).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream2")) {
                responseObserver.onNext(SegmentValidityResponse.newBuilder().setResponse(false).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @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 if (request.getStreamInfo().getStream().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void commitTransaction(TxnRequest request, StreamObserver<Controller.TxnStatus> responseObserver) {
            lastRequest.set(request);
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(Controller.TxnStatus.newBuilder().setStatus(Controller.TxnStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream2")) {
                responseObserver.onNext(Controller.TxnStatus.newBuilder().setStatus(Controller.TxnStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream3")) {
                responseObserver.onNext(Controller.TxnStatus.newBuilder().setStatus(Controller.TxnStatus.Status.STREAM_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream4")) {
                responseObserver.onNext(Controller.TxnStatus.newBuilder().setStatus(Controller.TxnStatus.Status.TRANSACTION_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void abortTransaction(TxnRequest request, StreamObserver<Controller.TxnStatus> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(Controller.TxnStatus.newBuilder().setStatus(Controller.TxnStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream2")) {
                responseObserver.onNext(Controller.TxnStatus.newBuilder().setStatus(Controller.TxnStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream3")) {
                responseObserver.onNext(Controller.TxnStatus.newBuilder().setStatus(Controller.TxnStatus.Status.STREAM_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream4")) {
                responseObserver.onNext(Controller.TxnStatus.newBuilder().setStatus(Controller.TxnStatus.Status.TRANSACTION_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void pingTransaction(PingTxnRequest request, StreamObserver<PingTxnStatus> responseObserver) {
            switch(request.getStreamInfo().getStream()) {
                case "stream1":
                    responseObserver.onNext(PingTxnStatus.newBuilder().setStatus(PingTxnStatus.Status.OK).build());
                    responseObserver.onCompleted();
                    break;
                case "stream2":
                    responseObserver.onNext(PingTxnStatus.newBuilder().setStatus(PingTxnStatus.Status.LEASE_TOO_LARGE).build());
                    responseObserver.onCompleted();
                    break;
                case "stream3":
                    responseObserver.onNext(PingTxnStatus.newBuilder().setStatus(PingTxnStatus.Status.MAX_EXECUTION_TIME_EXCEEDED).build());
                    responseObserver.onCompleted();
                    break;
                case "stream4":
                    responseObserver.onNext(PingTxnStatus.newBuilder().setStatus(PingTxnStatus.Status.DISCONNECTED).build());
                    responseObserver.onCompleted();
                    break;
                case "stream5":
                    responseObserver.onNext(PingTxnStatus.newBuilder().setStatus(PingTxnStatus.Status.COMMITTED).build());
                    responseObserver.onCompleted();
                    break;
                case "stream6":
                    responseObserver.onNext(PingTxnStatus.newBuilder().setStatus(PingTxnStatus.Status.ABORTED).build());
                    responseObserver.onCompleted();
                    break;
                case "stream8":
                    responseObserver.onNext(PingTxnStatus.newBuilder().setStatus(PingTxnStatus.Status.UNKNOWN).build());
                    responseObserver.onCompleted();
                    break;
                case "deadline":
                    break;
                default:
                    responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
                    break;
            }
        }

        @Override
        public void checkTransactionState(TxnRequest request, StreamObserver<TxnState> responseObserver) {
            if (request.getStreamInfo().getStream().equals("stream1")) {
                responseObserver.onNext(TxnState.newBuilder().setState(TxnState.State.OPEN).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream2")) {
                responseObserver.onNext(TxnState.newBuilder().setState(TxnState.State.UNKNOWN).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream3")) {
                responseObserver.onNext(TxnState.newBuilder().setState(TxnState.State.COMMITTING).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream4")) {
                responseObserver.onNext(TxnState.newBuilder().setState(TxnState.State.COMMITTED).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream5")) {
                responseObserver.onNext(TxnState.newBuilder().setState(TxnState.State.ABORTING).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("stream6")) {
                responseObserver.onNext(TxnState.newBuilder().setState(TxnState.State.ABORTED).build());
                responseObserver.onCompleted();
            } else if (request.getStreamInfo().getStream().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void createScope(ScopeInfo request, StreamObserver<CreateScopeStatus> responseObserver) {
            if (request.getScope().equals("scope1")) {
                responseObserver.onNext(CreateScopeStatus.newBuilder().setStatus(CreateScopeStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getScope().equals("scope2")) {
                responseObserver.onNext(CreateScopeStatus.newBuilder().setStatus(CreateScopeStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getScope().equals("scope3")) {
                responseObserver.onNext(CreateScopeStatus.newBuilder().setStatus(CreateScopeStatus.Status.INVALID_SCOPE_NAME).build());
                responseObserver.onCompleted();
            } else if (request.getScope().equals("scope4")) {
                responseObserver.onNext(CreateScopeStatus.newBuilder().setStatus(CreateScopeStatus.Status.SCOPE_EXISTS).build());
                responseObserver.onCompleted();
            } else if (request.getScope().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void getDelegationToken(StreamInfo request, StreamObserver<Controller.DelegationToken> responseObserver) {
            if (request.getStream().equals("deadline")) {
            // dont send any response
            } else {
                responseObserver.onNext(Controller.DelegationToken.newBuilder().setDelegationToken("token").build());
                responseObserver.onCompleted();
            }
        }

        @Override
        public void deleteScope(ScopeInfo request, StreamObserver<DeleteScopeStatus> responseObserver) {
            if (request.getScope().equals("scope1")) {
                responseObserver.onNext(DeleteScopeStatus.newBuilder().setStatus(DeleteScopeStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getScope().equals("scope2")) {
                responseObserver.onNext(DeleteScopeStatus.newBuilder().setStatus(DeleteScopeStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getScope().equals("scope3")) {
                responseObserver.onNext(DeleteScopeStatus.newBuilder().setStatus(DeleteScopeStatus.Status.SCOPE_NOT_EMPTY).build());
                responseObserver.onCompleted();
            } else if (request.getScope().equals("scope4")) {
                responseObserver.onNext(DeleteScopeStatus.newBuilder().setStatus(DeleteScopeStatus.Status.SCOPE_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getScope().equals("deadline")) {
            // don't send any response
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void deleteScopeRecursive(ScopeInfo request, StreamObserver<Controller.DeleteScopeStatus> responseObserver) {
            if (request.getScope().equals("scope1")) {
                responseObserver.onNext(Controller.DeleteScopeStatus.newBuilder().setStatus(Controller.DeleteScopeStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getScope().equals("scope2")) {
                responseObserver.onNext(Controller.DeleteScopeStatus.newBuilder().setStatus(Controller.DeleteScopeStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getScope().equals("scope3")) {
                responseObserver.onNext(Controller.DeleteScopeStatus.newBuilder().setStatus(Controller.DeleteScopeStatus.Status.SCOPE_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void listStreamsInScope(Controller.StreamsInScopeRequest request, StreamObserver<Controller.StreamsInScopeResponse> responseObserver) {
            if (request.getScope().getScope().equals(NON_EXISTENT)) {
                responseObserver.onNext(Controller.StreamsInScopeResponse.newBuilder().setStatus(Controller.StreamsInScopeResponse.Status.SCOPE_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getScope().getScope().equals("deadline")) {
            // dont send any response
            } else if (request.getScope().getScope().equals(FAILING)) {
                responseObserver.onNext(Controller.StreamsInScopeResponse.newBuilder().setStatus(Controller.StreamsInScopeResponse.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (Strings.isNullOrEmpty(request.getContinuationToken().getToken())) {
                List<StreamInfo> list1 = new LinkedList<>();
                list1.add(StreamInfo.newBuilder().setScope(request.getScope().getScope()).setStream("stream1").build());
                list1.add(StreamInfo.newBuilder().setScope(request.getScope().getScope()).setStream("stream2").build());
                responseObserver.onNext(Controller.StreamsInScopeResponse.newBuilder().setStatus(Controller.StreamsInScopeResponse.Status.SUCCESS).addAllStreams(list1).setContinuationToken(Controller.ContinuationToken.newBuilder().setToken("myToken").build()).build());
                responseObserver.onCompleted();
            } else if (request.getContinuationToken().getToken().equals("myToken")) {
                List<StreamInfo> list2 = new LinkedList<>();
                list2.add(StreamInfo.newBuilder().setScope(request.getScope().getScope()).setStream("stream3").build());
                responseObserver.onNext(Controller.StreamsInScopeResponse.newBuilder().addAllStreams(list2).setStatus(Controller.StreamsInScopeResponse.Status.SUCCESS).setContinuationToken(Controller.ContinuationToken.newBuilder().setToken("myToken2").build()).build());
                responseObserver.onCompleted();
            } else if (request.getContinuationToken().getToken().equals("myToken2")) {
                List<StreamInfo> list3 = new LinkedList<>();
                responseObserver.onNext(Controller.StreamsInScopeResponse.newBuilder().addAllStreams(list3).setStatus(Controller.StreamsInScopeResponse.Status.SUCCESS).setContinuationToken(Controller.ContinuationToken.newBuilder().setToken("").build()).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void listStreamsInScopeForTag(Controller.StreamsInScopeWithTagRequest request, StreamObserver<Controller.StreamsInScopeResponse> responseObserver) {
            if (request.getScope().getScope().equals(NON_EXISTENT)) {
                responseObserver.onNext(Controller.StreamsInScopeResponse.newBuilder().setStatus(Controller.StreamsInScopeResponse.Status.SCOPE_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getScope().getScope().equals("deadline")) {
            // dont send any response
            } else if (request.getScope().getScope().equals(FAILING)) {
                responseObserver.onNext(Controller.StreamsInScopeResponse.newBuilder().setStatus(Controller.StreamsInScopeResponse.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (Strings.isNullOrEmpty(request.getContinuationToken().getToken())) {
                List<StreamInfo> list1 = new LinkedList<>();
                list1.add(StreamInfo.newBuilder().setScope(request.getScope().getScope()).setStream("stream1").build());
                list1.add(StreamInfo.newBuilder().setScope(request.getScope().getScope()).setStream("stream2").build());
                responseObserver.onNext(Controller.StreamsInScopeResponse.newBuilder().setStatus(Controller.StreamsInScopeResponse.Status.SUCCESS).addAllStreams(list1).setContinuationToken(Controller.ContinuationToken.newBuilder().setToken("chunk0").build()).build());
                responseObserver.onCompleted();
            } else if (request.getContinuationToken().getToken().equals("chunk0")) {
                List<StreamInfo> list2 = new LinkedList<>();
                list2.add(StreamInfo.newBuilder().setScope(request.getScope().getScope()).setStream("stream3").build());
                responseObserver.onNext(Controller.StreamsInScopeResponse.newBuilder().addAllStreams(list2).setStatus(Controller.StreamsInScopeResponse.Status.SUCCESS).setContinuationToken(Controller.ContinuationToken.newBuilder().setToken("chunk1").build()).build());
                responseObserver.onCompleted();
            } else if (request.getContinuationToken().getToken().equals("chunk1")) {
                List<StreamInfo> list3 = new LinkedList<>();
                responseObserver.onNext(Controller.StreamsInScopeResponse.newBuilder().addAllStreams(list3).setStatus(Controller.StreamsInScopeResponse.Status.SUCCESS).setContinuationToken(Controller.ContinuationToken.newBuilder().setToken("chunk24").build()).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void isStreamCutValid(Controller.StreamCut request, StreamObserver<Controller.StreamCutValidityResponse> responseObserver) {
            if (request.getStreamInfo().getStream().equals("deadline")) {
            // do nothing
            } else {
                responseObserver.onNext(Controller.StreamCutValidityResponse.newBuilder().setResponse(true).build());
                responseObserver.onCompleted();
            }
        }

        @Override
        public void removeWriter(Controller.RemoveWriterRequest request, StreamObserver<Controller.RemoveWriterResponse> responseObserver) {
            if (request.getStream().getStream().equals("deadline")) {
            // do nothing
            } else {
                responseObserver.onNext(Controller.RemoveWriterResponse.newBuilder().setResult(Controller.RemoveWriterResponse.Status.SUCCESS).build());
                responseObserver.onCompleted();
            }
        }

        @Override
        public void noteTimestampFromWriter(Controller.TimestampFromWriter request, StreamObserver<Controller.TimestampResponse> responseObserver) {
            if (request.getWriter().equals("deadline")) {
            // do nothing
            } else {
                responseObserver.onNext(Controller.TimestampResponse.newBuilder().setResult(Controller.TimestampResponse.Status.SUCCESS).build());
                responseObserver.onCompleted();
            }
        }

        @Override
        public void createKeyValueTable(KeyValueTableConfig request, StreamObserver<CreateKeyValueTableStatus> responseObserver) {
            if (request.getKvtName().equals("kvtable1")) {
                responseObserver.onNext(CreateKeyValueTableStatus.newBuilder().setStatus(CreateKeyValueTableStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getKvtName().equals("kvtable2")) {
                responseObserver.onNext(CreateKeyValueTableStatus.newBuilder().setStatus(CreateKeyValueTableStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getKvtName().equals("kvtable3")) {
                responseObserver.onNext(CreateKeyValueTableStatus.newBuilder().setStatus(CreateKeyValueTableStatus.Status.SCOPE_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getKvtName().equals("kvtable4")) {
                responseObserver.onNext(CreateKeyValueTableStatus.newBuilder().setStatus(CreateKeyValueTableStatus.Status.TABLE_EXISTS).build());
                responseObserver.onCompleted();
            } else if (request.getKvtName().equals("kvtable5")) {
                responseObserver.onNext(CreateKeyValueTableStatus.newBuilder().setStatus(CreateKeyValueTableStatus.Status.INVALID_TABLE_NAME).build());
                responseObserver.onCompleted();
            }
        }

        @Override
        public void getCurrentSegmentsKeyValueTable(Controller.KeyValueTableInfo request, StreamObserver<SegmentRanges> responseObserver) {
            if (request.getKvtName().equals("kvtable1")) {
                responseObserver.onNext(SegmentRanges.newBuilder().addSegmentRanges(ModelHelper.createSegmentRange("scope1", "kvtable1", 4, 0.0, 0.4)).addSegmentRanges(ModelHelper.createSegmentRange("scope1", "kvtable1", 5, 0.4, 1.0)).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void listKeyValueTablesInScope(Controller.KVTablesInScopeRequest request, StreamObserver<Controller.KVTablesInScopeResponse> responseObserver) {
            if (request.getScope().getScope().equals(NON_EXISTENT)) {
                responseObserver.onNext(Controller.KVTablesInScopeResponse.newBuilder().setStatus(Controller.KVTablesInScopeResponse.Status.SCOPE_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getScope().getScope().equals(FAILING)) {
                responseObserver.onNext(Controller.KVTablesInScopeResponse.newBuilder().setStatus(Controller.KVTablesInScopeResponse.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (Strings.isNullOrEmpty(request.getContinuationToken().getToken())) {
                List<KeyValueTableInfo> list1 = new LinkedList<>();
                list1.add(KeyValueTableInfo.newBuilder().setScope(request.getScope().getScope()).setKvtName("kvtable1").build());
                list1.add(KeyValueTableInfo.newBuilder().setScope(request.getScope().getScope()).setKvtName("kvtable2").build());
                responseObserver.onNext(Controller.KVTablesInScopeResponse.newBuilder().setStatus(Controller.KVTablesInScopeResponse.Status.SUCCESS).addAllKvtables(list1).setContinuationToken(Controller.ContinuationToken.newBuilder().setToken("myToken").build()).build());
                responseObserver.onCompleted();
            } else if (request.getContinuationToken().getToken().equals("myToken")) {
                List<KeyValueTableInfo> list2 = new LinkedList<>();
                list2.add(KeyValueTableInfo.newBuilder().setScope(request.getScope().getScope()).setKvtName("kvtable3").build());
                responseObserver.onNext(Controller.KVTablesInScopeResponse.newBuilder().addAllKvtables(list2).setStatus(Controller.KVTablesInScopeResponse.Status.SUCCESS).setContinuationToken(Controller.ContinuationToken.newBuilder().setToken("myToken2").build()).build());
                responseObserver.onCompleted();
            } else if (request.getContinuationToken().getToken().equals("myToken2")) {
                List<KeyValueTableInfo> list3 = new LinkedList<>();
                responseObserver.onNext(Controller.KVTablesInScopeResponse.newBuilder().addAllKvtables(list3).setStatus(Controller.KVTablesInScopeResponse.Status.SUCCESS).setContinuationToken(Controller.ContinuationToken.newBuilder().setToken("").build()).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void getKeyValueTableConfiguration(KeyValueTableInfo request, StreamObserver<KeyValueTableConfigResponse> responseObserver) {
            KeyValueTableConfiguration config = KeyValueTableConfiguration.builder().partitionCount(3).primaryKeyLength(Integer.BYTES).secondaryKeyLength(Long.BYTES).build();
            if (request.getKvtName().equals("kvtable")) {
                responseObserver.onNext(KeyValueTableConfigResponse.newBuilder().setConfig(ModelHelper.decode(request.getScope(), request.getKvtName(), config)).setStatus(KeyValueTableConfigResponse.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getKvtName().equals(NON_EXISTENT)) {
                responseObserver.onNext(KeyValueTableConfigResponse.newBuilder().setStatus(KeyValueTableConfigResponse.Status.TABLE_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else if (request.getKvtName().equals(FAILING)) {
                responseObserver.onNext(KeyValueTableConfigResponse.newBuilder().setStatus(KeyValueTableConfigResponse.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }

        @Override
        public void deleteKeyValueTable(KeyValueTableInfo request, StreamObserver<DeleteKVTableStatus> responseObserver) {
            if (request.getKvtName().equals("kvtable1")) {
                responseObserver.onNext(DeleteKVTableStatus.newBuilder().setStatus(DeleteKVTableStatus.Status.SUCCESS).build());
                responseObserver.onCompleted();
            } else if (request.getKvtName().equals("kvtable2")) {
                responseObserver.onNext(DeleteKVTableStatus.newBuilder().setStatus(DeleteKVTableStatus.Status.FAILURE).build());
                responseObserver.onCompleted();
            } else if (request.getKvtName().equals("kvtable3")) {
                responseObserver.onNext(DeleteKVTableStatus.newBuilder().setStatus(DeleteKVTableStatus.Status.TABLE_NOT_FOUND).build());
                responseObserver.onCompleted();
            } else {
                responseObserver.onError(Status.INTERNAL.withDescription("Server error").asRuntimeException());
            }
        }
    };
    serverPort = TestUtils.getAvailableListenPort();
    serverBuilder = NettyServerBuilder.forPort(serverPort).addService(testServerImpl);
    if (testSecure) {
        serverBuilder = serverBuilder.useTransportSecurity(new File(SecurityConfigDefaults.TLS_SERVER_CERT_PATH), new File(SecurityConfigDefaults.TLS_SERVER_PRIVATE_KEY_PATH));
    }
    testGRPCServer = serverBuilder.build().start();
    executor = ExecutorServiceHelpers.newScheduledThreadPool(1, "test");
    controllerClient = new ControllerImpl(ControllerImplConfig.builder().clientConfig(ClientConfig.builder().controllerURI(URI.create((testSecure ? "tls://" : "tcp://") + "localhost:" + serverPort)).credentials(new DefaultCredentials("1111_aaaa", "admin")).trustStore(SecurityConfigDefaults.TLS_CA_CERT_PATH).build()).retryAttempts(1).build(), executor);
}
Also used : ScaleStatusRequest(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleStatusRequest) DeleteKVTableStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteKVTableStatus) CreateReaderGroupResponse(io.pravega.controller.stream.api.grpc.v1.Controller.CreateReaderGroupResponse) SuccessorResponse(io.pravega.controller.stream.api.grpc.v1.Controller.SuccessorResponse) ScaleRequest(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleRequest) ReaderGroupConfig(io.pravega.client.stream.ReaderGroupConfig) lombok.val(lombok.val) KeyValueTableInfo(io.pravega.controller.stream.api.grpc.v1.Controller.KeyValueTableInfo) KeyValueTableConfig(io.pravega.controller.stream.api.grpc.v1.Controller.KeyValueTableConfig) ScaleStatusResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleStatusResponse) PingTxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnRequest) TxnState(io.pravega.controller.stream.api.grpc.v1.Controller.TxnState) CreateTxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) SegmentsAtTime(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentsAtTime) DeleteReaderGroupStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteReaderGroupStatus) ReaderGroupConfiguration(io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupConfiguration) PingTxnStatus(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus) Entry(java.util.Map.Entry) UpdateReaderGroupResponse(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateReaderGroupResponse) SubscribersResponse(io.pravega.controller.stream.api.grpc.v1.Controller.SubscribersResponse) Controller(io.pravega.controller.stream.api.grpc.v1.Controller) DeleteScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteScopeStatus) DeleteStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteStreamStatus) UpdateSubscriberStatus(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateSubscriberStatus) HashMap(java.util.HashMap) ReaderGroupConfigResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupConfigResponse) NettyServerBuilder(io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder) NettyChannelBuilder(io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder) PingTxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnRequest) CreateTxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest) TxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.TxnRequest) UpdateStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateStreamStatus) KeyValueTableConfigResponse(io.pravega.controller.stream.api.grpc.v1.Controller.KeyValueTableConfigResponse) CreateScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateScopeStatus) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) SubscriberStreamCut(io.pravega.controller.stream.api.grpc.v1.Controller.SubscriberStreamCut) KeyValueTableConfiguration(io.pravega.client.tables.KeyValueTableConfiguration) NodeUri(io.pravega.controller.stream.api.grpc.v1.Controller.NodeUri) PravegaNodeUri(io.pravega.shared.protocol.netty.PravegaNodeUri) LinkedList(java.util.LinkedList) ImmutableMap(com.google.common.collect.ImmutableMap) SegmentRanges(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRanges) CreateKeyValueTableStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateKeyValueTableStatus) GetSegmentsRequest(io.pravega.controller.stream.api.grpc.v1.Controller.GetSegmentsRequest) File(java.io.File) StreamCutImpl(io.pravega.client.stream.impl.StreamCutImpl) SegmentValidityResponse(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentValidityResponse) Segment(io.pravega.client.segment.impl.Segment) KeyValueTableInfo(io.pravega.controller.stream.api.grpc.v1.Controller.KeyValueTableInfo) DefaultCredentials(io.pravega.shared.security.auth.DefaultCredentials) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) Pair(org.apache.commons.lang3.tuple.Pair) ReaderGroupInfo(io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupInfo) ControllerServiceImplBase(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceImplBase) CreateStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateStreamStatus) SegmentId(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentId) StreamConfig(io.pravega.controller.stream.api.grpc.v1.Controller.StreamConfig) ScaleResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleResponse) ScopeInfo(io.pravega.controller.stream.api.grpc.v1.Controller.ScopeInfo) GetEpochSegmentsRequest(io.pravega.controller.stream.api.grpc.v1.Controller.GetEpochSegmentsRequest) StreamInfo(io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo) PingTxnStatus(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus) Before(org.junit.Before)

Example 3 with CreateTxnRequest

use of io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest 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));
}
Also used : CreateTxnResponse(io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnResponse) CreateTxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest) StreamInfo(io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo) Test(org.junit.Test)

Example 4 with CreateTxnRequest

use of io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest 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));
}
Also used : CreateTxnResponse(io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnResponse) CreateTxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest) StreamInfo(io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo) Test(org.junit.Test)

Example 5 with CreateTxnRequest

use of io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest in project pravega by pravega.

the class ControllerServiceImpl method createTransaction.

@Override
public void createTransaction(CreateTxnRequest request, StreamObserver<Controller.CreateTxnResponse> responseObserver) {
    RequestTag requestTag = requestTracker.initializeAndTrackRequestTag(controllerService.nextRequestId(), CREATE_TRANSACTION, request.getStreamInfo().getScope(), request.getStreamInfo().getStream(), Long.toString(request.getLease()));
    log.info(requestTag.getRequestId(), "createTransaction called for stream {}/{}.", request.getStreamInfo().getScope(), request.getStreamInfo().getStream());
    authenticateExecuteAndProcessResults(() -> this.grpcAuthHelper.checkAuthorizationAndCreateToken(authorizationResource.ofStreamInScope(request.getStreamInfo().getScope(), request.getStreamInfo().getStream()), AuthHandler.Permissions.READ_UPDATE), delegationToken -> controllerService.createTransaction(request.getStreamInfo().getScope(), request.getStreamInfo().getStream(), request.getLease(), requestTag.getRequestId()).thenApply(pair -> Controller.CreateTxnResponse.newBuilder().setDelegationToken(delegationToken).setTxnId(decode(pair.getKey())).addAllActiveSegments(pair.getValue()).build()), responseObserver, requestTag);
}
Also used : StreamCut(io.pravega.controller.stream.api.grpc.v1.Controller.StreamCut) StreamConfig(io.pravega.controller.stream.api.grpc.v1.Controller.StreamConfig) AuthHandler(io.pravega.auth.AuthHandler) PingTxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnRequest) DELETE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.DELETE_STREAM) SegmentRanges(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRanges) StreamAuthParams(io.pravega.controller.server.security.auth.StreamAuthParams) StoreException(io.pravega.controller.store.stream.StoreException) Pair(org.apache.commons.lang3.tuple.Pair) TRUNCATE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.TRUNCATE_STREAM) AuthContext(io.pravega.controller.server.security.auth.handler.AuthContext) AccessOperation(io.pravega.shared.security.auth.AccessOperation) KeyValueTableInfo(io.pravega.controller.stream.api.grpc.v1.Controller.KeyValueTableInfo) SubscriberStreamCut(io.pravega.controller.stream.api.grpc.v1.Controller.SubscriberStreamCut) LIST_SCOPES(io.pravega.shared.controller.tracing.RPCTracingTags.LIST_SCOPES) Status(io.grpc.Status) LockFailedException(io.pravega.controller.store.task.LockFailedException) UPDATE_READER_GROUP(io.pravega.shared.controller.tracing.RPCTracingTags.UPDATE_READER_GROUP) UPDATE_TRUNCATION_STREAM_CUT(io.pravega.shared.controller.tracing.RPCTracingTags.UPDATE_TRUNCATION_STREAM_CUT) DeleteScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteScopeStatus) GET_SEGMENTS_IMMEDIATELY_FOLLOWING(io.pravega.shared.controller.tracing.RPCTracingTags.GET_SEGMENTS_IMMEDIATELY_FOLLOWING) ReaderGroupInfo(io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupInfo) AuthorizationResource(io.pravega.shared.security.auth.AuthorizationResource) REMOVE_WRITER(io.pravega.shared.controller.tracing.RPCTracingTags.REMOVE_WRITER) AuthorizationException(io.pravega.auth.AuthorizationException) NonNull(lombok.NonNull) GET_SEGMENTS_BETWEEN_STREAM_CUTS(io.pravega.shared.controller.tracing.RPCTracingTags.GET_SEGMENTS_BETWEEN_STREAM_CUTS) LIST_STREAMS_IN_SCOPE(io.pravega.shared.controller.tracing.RPCTracingTags.LIST_STREAMS_IN_SCOPE) RequestTracker(io.pravega.common.tracing.RequestTracker) GET_STREAM_CONFIGURATION(io.pravega.shared.controller.tracing.RPCTracingTags.GET_STREAM_CONFIGURATION) GrpcAuthHelper(io.pravega.controller.server.security.auth.GrpcAuthHelper) SegmentId(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentId) CreateReaderGroupResponse(io.pravega.controller.stream.api.grpc.v1.Controller.CreateReaderGroupResponse) LIST_KEY_VALUE_TABLES(io.pravega.shared.controller.tracing.RPCTracingTags.LIST_KEY_VALUE_TABLES) KeyValueTableConfig(io.pravega.controller.stream.api.grpc.v1.Controller.KeyValueTableConfig) Exceptions(io.pravega.common.Exceptions) ModelHelper.decode(io.pravega.client.control.impl.ModelHelper.decode) ServerRequest(io.pravega.controller.stream.api.grpc.v1.Controller.ServerRequest) ScopeInfo(io.pravega.controller.stream.api.grpc.v1.Controller.ScopeInfo) GET_KEY_VALUE_TABLE_CONFIGURATION(io.pravega.shared.controller.tracing.RPCTracingTags.GET_KEY_VALUE_TABLE_CONFIGURATION) IS_STREAMCUT_VALID(io.pravega.shared.controller.tracing.RPCTracingTags.IS_STREAMCUT_VALID) Supplier(java.util.function.Supplier) UpdateSubscriberStatus(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateSubscriberStatus) ArrayList(java.util.ArrayList) Strings(com.google.common.base.Strings) NodeUri(io.pravega.controller.stream.api.grpc.v1.Controller.NodeUri) ReaderGroupConfiguration(io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupConfiguration) StreamInfo(io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo) ControllerServiceGrpc(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc) SegmentLocation(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentsAtTime.SegmentLocation) Throwables(com.google.common.base.Throwables) AuthenticationException(io.pravega.auth.AuthenticationException) CREATE_TRANSACTION(io.pravega.shared.controller.tracing.RPCTracingTags.CREATE_TRANSACTION) LIST_STREAMS_IN_SCOPE_FOR_TAG(io.pravega.shared.controller.tracing.RPCTracingTags.LIST_STREAMS_IN_SCOPE_FOR_TAG) TxnStatus(io.pravega.controller.stream.api.grpc.v1.Controller.TxnStatus) DeleteReaderGroupStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteReaderGroupStatus) SegmentsAtTime(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentsAtTime) CreateKeyValueTableStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateKeyValueTableStatus) GET_CURRENT_SEGMENTS(io.pravega.shared.controller.tracing.RPCTracingTags.GET_CURRENT_SEGMENTS) CHECK_TRANSACTION_STATE(io.pravega.shared.controller.tracing.RPCTracingTags.CHECK_TRANSACTION_STATE) CREATE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.CREATE_STREAM) ServerResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ServerResponse) BiFunction(java.util.function.BiFunction) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) GetSegmentsRequest(io.pravega.controller.stream.api.grpc.v1.Controller.GetSegmentsRequest) StreamObserver(io.grpc.stub.StreamObserver) TagLogger(io.pravega.common.tracing.TagLogger) CREATE_KEY_VALUE_TABLE(io.pravega.shared.controller.tracing.RPCTracingTags.CREATE_KEY_VALUE_TABLE) SubscribersResponse(io.pravega.controller.stream.api.grpc.v1.Controller.SubscribersResponse) Controller(io.pravega.controller.stream.api.grpc.v1.Controller) DELETE_KEY_VALUE_TABLE(io.pravega.shared.controller.tracing.RPCTracingTags.DELETE_KEY_VALUE_TABLE) CreateStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateStreamStatus) CHECK_SCOPE_EXISTS(io.pravega.shared.controller.tracing.RPCTracingTags.CHECK_SCOPE_EXISTS) LIST_SUBSCRIBERS(io.pravega.shared.controller.tracing.RPCTracingTags.LIST_SUBSCRIBERS) ImmutableMap(com.google.common.collect.ImmutableMap) Predicate(java.util.function.Predicate) CHECK_STREAM_EXISTS(io.pravega.shared.controller.tracing.RPCTracingTags.CHECK_STREAM_EXISTS) CREATE_SCOPE(io.pravega.shared.controller.tracing.RPCTracingTags.CREATE_SCOPE) RequestTag(io.pravega.common.tracing.RequestTag) DelegationToken(io.pravega.controller.stream.api.grpc.v1.Controller.DelegationToken) CompletionException(java.util.concurrent.CompletionException) UUID(java.util.UUID) COMMIT_TRANSACTION(io.pravega.shared.controller.tracing.RPCTracingTags.COMMIT_TRANSACTION) Collectors(java.util.stream.Collectors) GET_SEGMENTS(io.pravega.shared.controller.tracing.RPCTracingTags.GET_SEGMENTS) GET_EPOCH_SEGMENTS(io.pravega.shared.controller.tracing.RPCTracingTags.GET_EPOCH_SEGMENTS) SEAL_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.SEAL_STREAM) List(java.util.List) ABORT_TRANSACTION(io.pravega.shared.controller.tracing.RPCTracingTags.ABORT_TRANSACTION) GET_URI(io.pravega.shared.controller.tracing.RPCTracingTags.GET_URI) Entry(java.util.Map.Entry) GetEpochSegmentsRequest(io.pravega.controller.stream.api.grpc.v1.Controller.GetEpochSegmentsRequest) DELETE_READER_GROUP(io.pravega.shared.controller.tracing.RPCTracingTags.DELETE_READER_GROUP) DELETE_SCOPE(io.pravega.shared.controller.tracing.RPCTracingTags.DELETE_SCOPE) PING_TRANSACTION(io.pravega.shared.controller.tracing.RPCTracingTags.PING_TRANSACTION) PingTxnStatus(io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus) DELETE_SCOPE_RECURSIVE(io.pravega.shared.controller.tracing.RPCTracingTags.DELETE_SCOPE_RECURSIVE) CreateScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateScopeStatus) ScaleStatusRequest(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleStatusRequest) ModelHelper(io.pravega.client.control.impl.ModelHelper) IS_SEGMENT_OPEN(io.pravega.shared.controller.tracing.RPCTracingTags.IS_SEGMENT_OPEN) ScaleStatusResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleStatusResponse) TxnState(io.pravega.controller.stream.api.grpc.v1.Controller.TxnState) CompletableFuture(java.util.concurrent.CompletableFuture) Function(java.util.function.Function) SuccessorResponse(io.pravega.controller.stream.api.grpc.v1.Controller.SuccessorResponse) GET_OR_REFRESH_DELEGATION_TOKEN_FOR(io.pravega.shared.controller.tracing.RPCTracingTags.GET_OR_REFRESH_DELEGATION_TOKEN_FOR) ScaleRequest(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleRequest) DeleteKVTableStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteKVTableStatus) CreateTxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest) GET_CURRENT_SEGMENTS_KEY_VALUE_TABLE(io.pravega.shared.controller.tracing.RPCTracingTags.GET_CURRENT_SEGMENTS_KEY_VALUE_TABLE) DeleteStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteStreamStatus) NOTE_TIMESTAMP_FROM_WRITER(io.pravega.shared.controller.tracing.RPCTracingTags.NOTE_TIMESTAMP_FROM_WRITER) CHECK_SCALE(io.pravega.shared.controller.tracing.RPCTracingTags.CHECK_SCALE) UPDATE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.UPDATE_STREAM) CREATE_READER_GROUP(io.pravega.shared.controller.tracing.RPCTracingTags.CREATE_READER_GROUP) ScaleResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleResponse) AuthorizationResourceImpl(io.pravega.shared.security.auth.AuthorizationResourceImpl) SCALE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.SCALE_STREAM) ControllerService(io.pravega.controller.server.ControllerService) UpdateReaderGroupResponse(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateReaderGroupResponse) NameUtils(io.pravega.shared.NameUtils) GET_READER_GROUP_CONFIG(io.pravega.shared.controller.tracing.RPCTracingTags.GET_READER_GROUP_CONFIG) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) UpdateStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateStreamStatus) VisibleForTesting(com.google.common.annotations.VisibleForTesting) TxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.TxnRequest) AllArgsConstructor(lombok.AllArgsConstructor) ReaderGroupConfigResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupConfigResponse) SegmentValidityResponse(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentValidityResponse) RequestTag(io.pravega.common.tracing.RequestTag)

Aggregations

CreateTxnRequest (io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnRequest)5 StreamInfo (io.pravega.controller.stream.api.grpc.v1.Controller.StreamInfo)5 Controller (io.pravega.controller.stream.api.grpc.v1.Controller)3 CreateScopeStatus (io.pravega.controller.stream.api.grpc.v1.Controller.CreateScopeStatus)3 CreateStreamStatus (io.pravega.controller.stream.api.grpc.v1.Controller.CreateStreamStatus)3 DeleteScopeStatus (io.pravega.controller.stream.api.grpc.v1.Controller.DeleteScopeStatus)3 DeleteStreamStatus (io.pravega.controller.stream.api.grpc.v1.Controller.DeleteStreamStatus)3 GetSegmentsRequest (io.pravega.controller.stream.api.grpc.v1.Controller.GetSegmentsRequest)3 NodeUri (io.pravega.controller.stream.api.grpc.v1.Controller.NodeUri)3 PingTxnRequest (io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnRequest)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 PingTxnStatus (io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus)2 ScaleRequest (io.pravega.controller.stream.api.grpc.v1.Controller.ScaleRequest)2 ScaleResponse (io.pravega.controller.stream.api.grpc.v1.Controller.ScaleResponse)2 ScaleStatusRequest (io.pravega.controller.stream.api.grpc.v1.Controller.ScaleStatusRequest)2 ScaleStatusResponse (io.pravega.controller.stream.api.grpc.v1.Controller.ScaleStatusResponse)2 ScopeInfo (io.pravega.controller.stream.api.grpc.v1.Controller.ScopeInfo)2 SegmentId (io.pravega.controller.stream.api.grpc.v1.Controller.SegmentId)2 SegmentRanges (io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRanges)2 SegmentValidityResponse (io.pravega.controller.stream.api.grpc.v1.Controller.SegmentValidityResponse)2