Search in sources :

Example 11 with PravegaConnectionListener

use of io.pravega.segmentstore.server.host.handler.PravegaConnectionListener in project pravega by pravega.

the class UnreadBytesTest method setUp.

@Before
public void setUp() throws Exception {
    executor = Executors.newSingleThreadScheduledExecutor();
    zkTestServer = new TestingServerStarter().start();
    serviceBuilder = ServiceBuilder.newInMemoryBuilder(ServiceBuilderConfig.getDefaultConfig());
    serviceBuilder.initialize();
    StreamSegmentStore store = serviceBuilder.createStreamSegmentService();
    server = new PravegaConnectionListener(false, servicePort, store);
    server.startListening();
    controllerWrapper = new ControllerWrapper(zkTestServer.getConnectString(), false, controllerPort, serviceHost, servicePort, containerCount);
    controllerWrapper.awaitRunning();
}
Also used : StreamSegmentStore(io.pravega.segmentstore.contracts.StreamSegmentStore) TestingServerStarter(io.pravega.test.common.TestingServerStarter) PravegaConnectionListener(io.pravega.segmentstore.server.host.handler.PravegaConnectionListener) ControllerWrapper(io.pravega.test.integration.demo.ControllerWrapper) Before(org.junit.Before)

Example 12 with PravegaConnectionListener

use of io.pravega.segmentstore.server.host.handler.PravegaConnectionListener in project pravega by pravega.

the class ControllerServiceTest method setUp.

@Before
public void setUp() throws Exception {
    zkTestServer = new TestingServerStarter().start();
    serviceBuilder = ServiceBuilder.newInMemoryBuilder(ServiceBuilderConfig.getDefaultConfig());
    serviceBuilder.initialize();
    StreamSegmentStore store = serviceBuilder.createStreamSegmentService();
    server = new PravegaConnectionListener(false, servicePort, store);
    server.startListening();
    controllerWrapper = new ControllerWrapper(zkTestServer.getConnectString(), false, controllerPort, serviceHost, servicePort, containerCount);
    controllerWrapper.awaitRunning();
}
Also used : StreamSegmentStore(io.pravega.segmentstore.contracts.StreamSegmentStore) TestingServerStarter(io.pravega.test.common.TestingServerStarter) PravegaConnectionListener(io.pravega.segmentstore.server.host.handler.PravegaConnectionListener) ControllerWrapper(io.pravega.test.integration.demo.ControllerWrapper) Before(org.junit.Before)

Example 13 with PravegaConnectionListener

use of io.pravega.segmentstore.server.host.handler.PravegaConnectionListener in project pravega by pravega.

the class EventProcessorTest method testEventProcessor.

@Test(timeout = 60000)
public void testEventProcessor() throws Exception {
    @Cleanup TestingServer zkTestServer = new TestingServerStarter().start();
    ServiceBuilder serviceBuilder = ServiceBuilder.newInMemoryBuilder(ServiceBuilderConfig.getDefaultConfig());
    serviceBuilder.initialize();
    StreamSegmentStore store = serviceBuilder.createStreamSegmentService();
    int servicePort = TestUtils.getAvailableListenPort();
    @Cleanup PravegaConnectionListener server = new PravegaConnectionListener(false, servicePort, store);
    server.startListening();
    int controllerPort = TestUtils.getAvailableListenPort();
    @Cleanup ControllerWrapper controllerWrapper = new ControllerWrapper(zkTestServer.getConnectString(), true, controllerPort, "localhost", servicePort, 4);
    controllerWrapper.awaitRunning();
    Controller controller = controllerWrapper.getController();
    // Create controller object for testing against a separate controller process.
    // ControllerImpl controller = new ControllerImpl("localhost", 9090);
    final String host = "host";
    final String scope = "controllerScope";
    final String streamName = "stream1";
    final String readerGroup = "readerGroup";
    final CompletableFuture<Boolean> createScopeStatus = controller.createScope(scope);
    if (!createScopeStatus.join()) {
        throw new RuntimeException("Scope already existed");
    }
    final StreamConfiguration config = StreamConfiguration.builder().scope(scope).streamName(streamName).scalingPolicy(ScalingPolicy.fixed(1)).build();
    System.err.println(String.format("Creating stream (%s, %s)", scope, streamName));
    CompletableFuture<Boolean> createStatus = controller.createStream(config);
    if (!createStatus.get()) {
        System.err.println("Stream alrady existed, exiting");
        return;
    }
    @Cleanup ConnectionFactoryImpl connectionFactory = new ConnectionFactoryImpl(ClientConfig.builder().build());
    @Cleanup ClientFactory clientFactory = new ClientFactoryImpl(scope, controller, connectionFactory);
    @Cleanup EventStreamWriter<TestEvent> producer = clientFactory.createEventWriter(streamName, new JavaSerializer<>(), EventWriterConfig.builder().build());
    int[] input = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    int expectedSum = input.length * (input.length + 1) / 2;
    for (int i = 0; i < input.length; i++) {
        producer.writeEvent("key", new TestEvent(input[i]));
    }
    producer.writeEvent("key", new TestEvent(-1));
    producer.flush();
    EventProcessorSystem system = new EventProcessorSystemImpl("Controller", host, scope, new ClientFactoryImpl(scope, controller, connectionFactory), new ReaderGroupManagerImpl(scope, controller, clientFactory, connectionFactory));
    CheckpointConfig.CheckpointPeriod period = CheckpointConfig.CheckpointPeriod.builder().numEvents(1).numSeconds(1).build();
    CheckpointConfig checkpointConfig = CheckpointConfig.builder().type(CheckpointConfig.Type.Periodic).checkpointPeriod(period).build();
    EventProcessorGroupConfig eventProcessorGroupConfig = EventProcessorGroupConfigImpl.builder().eventProcessorCount(1).readerGroupName(readerGroup).streamName(streamName).checkpointConfig(checkpointConfig).build();
    CompletableFuture<Long> result = new CompletableFuture<>();
    // Test case 1. Actor does not throw any exception during normal operation.
    EventProcessorConfig<TestEvent> eventProcessorConfig = EventProcessorConfig.<TestEvent>builder().supplier(() -> new TestEventProcessor(false, result)).serializer(new JavaSerializer<>()).decider((Throwable e) -> ExceptionHandler.Directive.Stop).config(eventProcessorGroupConfig).build();
    @Cleanup EventProcessorGroup<TestEvent> eventProcessorGroup = system.createEventProcessorGroup(eventProcessorConfig, CheckpointStoreFactory.createInMemoryStore());
    Long value = result.join();
    Assert.assertEquals(expectedSum, value.longValue());
    log.info("SUCCESS: received expected sum = " + expectedSum);
}
Also used : EventProcessorSystem(io.pravega.controller.eventProcessor.EventProcessorSystem) ClientFactory(io.pravega.client.ClientFactory) Cleanup(lombok.Cleanup) PravegaConnectionListener(io.pravega.segmentstore.server.host.handler.PravegaConnectionListener) JavaSerializer(io.pravega.client.stream.impl.JavaSerializer) ServiceBuilder(io.pravega.segmentstore.server.store.ServiceBuilder) ClientFactoryImpl(io.pravega.client.stream.impl.ClientFactoryImpl) CompletableFuture(java.util.concurrent.CompletableFuture) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) ReaderGroupManagerImpl(io.pravega.client.admin.impl.ReaderGroupManagerImpl) ControllerWrapper(io.pravega.test.integration.demo.ControllerWrapper) TestingServer(org.apache.curator.test.TestingServer) TestingServerStarter(io.pravega.test.common.TestingServerStarter) CheckpointConfig(io.pravega.controller.eventProcessor.CheckpointConfig) Controller(io.pravega.client.stream.impl.Controller) EventProcessorSystemImpl(io.pravega.controller.eventProcessor.impl.EventProcessorSystemImpl) StreamSegmentStore(io.pravega.segmentstore.contracts.StreamSegmentStore) EventProcessorGroupConfig(io.pravega.controller.eventProcessor.EventProcessorGroupConfig) ConnectionFactoryImpl(io.pravega.client.netty.impl.ConnectionFactoryImpl) Test(org.junit.Test)

Example 14 with PravegaConnectionListener

use of io.pravega.segmentstore.server.host.handler.PravegaConnectionListener in project pravega by pravega.

the class EndToEndStatsTest method setUp.

@Before
public void setUp() throws Exception {
    zkTestServer = new TestingServerStarter().start();
    serviceBuilder = ServiceBuilder.newInMemoryBuilder(ServiceBuilderConfig.getDefaultConfig());
    serviceBuilder.initialize();
    StreamSegmentStore store = serviceBuilder.createStreamSegmentService();
    statsRecorder = new TestStatsRecorder();
    server = new PravegaConnectionListener(false, "localhost", servicePort, store, statsRecorder, null, null, null);
    server.startListening();
    controllerWrapper = new ControllerWrapper(zkTestServer.getConnectString(), false, controllerPort, serviceHost, servicePort, containerCount);
    controllerWrapper.awaitRunning();
}
Also used : StreamSegmentStore(io.pravega.segmentstore.contracts.StreamSegmentStore) TestingServerStarter(io.pravega.test.common.TestingServerStarter) PravegaConnectionListener(io.pravega.segmentstore.server.host.handler.PravegaConnectionListener) ControllerWrapper(io.pravega.test.integration.demo.ControllerWrapper) Before(org.junit.Before)

Example 15 with PravegaConnectionListener

use of io.pravega.segmentstore.server.host.handler.PravegaConnectionListener in project pravega by pravega.

the class EndToEndTruncationTest method setUp.

@Before
public void setUp() throws Exception {
    executor = Executors.newSingleThreadScheduledExecutor();
    zkTestServer = new TestingServerStarter().start();
    serviceBuilder = ServiceBuilder.newInMemoryBuilder(ServiceBuilderConfig.getDefaultConfig());
    serviceBuilder.initialize();
    StreamSegmentStore store = serviceBuilder.createStreamSegmentService();
    server = new PravegaConnectionListener(false, servicePort, store);
    server.startListening();
    controllerWrapper = new ControllerWrapper(zkTestServer.getConnectString(), false, controllerPort, serviceHost, servicePort, containerCount);
    controllerWrapper.awaitRunning();
}
Also used : StreamSegmentStore(io.pravega.segmentstore.contracts.StreamSegmentStore) TestingServerStarter(io.pravega.test.common.TestingServerStarter) PravegaConnectionListener(io.pravega.segmentstore.server.host.handler.PravegaConnectionListener) ControllerWrapper(io.pravega.test.integration.demo.ControllerWrapper) Before(org.junit.Before)

Aggregations

PravegaConnectionListener (io.pravega.segmentstore.server.host.handler.PravegaConnectionListener)46 StreamSegmentStore (io.pravega.segmentstore.contracts.StreamSegmentStore)45 Cleanup (lombok.Cleanup)28 Test (org.junit.Test)23 TestingServerStarter (io.pravega.test.common.TestingServerStarter)22 MockStreamManager (io.pravega.client.stream.mock.MockStreamManager)20 ServiceBuilder (io.pravega.segmentstore.server.store.ServiceBuilder)19 MockClientFactory (io.pravega.client.stream.mock.MockClientFactory)18 ControllerWrapper (io.pravega.test.integration.demo.ControllerWrapper)16 Before (org.junit.Before)14 ReaderGroupConfig (io.pravega.client.stream.ReaderGroupConfig)10 Controller (io.pravega.client.stream.impl.Controller)10 JavaSerializer (io.pravega.client.stream.impl.JavaSerializer)10 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)8 ConnectionFactoryImpl (io.pravega.client.netty.impl.ConnectionFactoryImpl)7 TestingServer (org.apache.curator.test.TestingServer)7 ClientFactoryImpl (io.pravega.client.stream.impl.ClientFactoryImpl)5 StreamImpl (io.pravega.client.stream.impl.StreamImpl)5 ClientFactory (io.pravega.client.ClientFactory)4 ScalingPolicy (io.pravega.client.stream.ScalingPolicy)4