Search in sources :

Example 1 with StreamMetadataStore

use of io.pravega.controller.store.stream.StreamMetadataStore in project pravega by pravega.

the class ZkStoreRetentionTest method testOwnershipOfExistingBucket.

@Test(timeout = 10000)
public void testOwnershipOfExistingBucket() throws Exception {
    TestingServer zkServer2 = new TestingServerStarter().start();
    zkServer2.start();
    CuratorFramework zkClient2 = CuratorFrameworkFactory.newClient(zkServer2.getConnectString(), 10000, 1000, (r, e, s) -> false);
    zkClient2.start();
    ScheduledExecutorService executor2 = Executors.newScheduledThreadPool(10);
    String hostId = UUID.randomUUID().toString();
    StreamMetadataStore streamMetadataStore2 = StreamStoreFactory.createZKStore(zkClient2, 1, executor2);
    TaskMetadataStore taskMetadataStore = TaskStoreFactory.createInMemoryStore(executor2);
    HostControllerStore hostStore = HostStoreFactory.createInMemoryStore(HostMonitorConfigImpl.dummyConfig());
    SegmentHelper segmentHelper = SegmentHelperMock.getSegmentHelperMock();
    ConnectionFactoryImpl connectionFactory = new ConnectionFactoryImpl(ClientConfig.builder().build());
    StreamMetadataTasks streamMetadataTasks2 = new StreamMetadataTasks(streamMetadataStore2, hostStore, taskMetadataStore, segmentHelper, executor2, hostId, connectionFactory, false, "");
    String scope = "scope1";
    String streamName = "stream1";
    streamMetadataStore2.addUpdateStreamForAutoStreamCut(scope, streamName, RetentionPolicy.builder().build(), null, executor2).join();
    String scope2 = "scope2";
    String streamName2 = "stream2";
    streamMetadataStore2.addUpdateStreamForAutoStreamCut(scope2, streamName2, RetentionPolicy.builder().build(), null, executor2).join();
    StreamCutService service2 = new StreamCutService(1, hostId, streamMetadataStore2, streamMetadataTasks2, executor2);
    service2.startAsync();
    service2.awaitRunning();
    assertTrue(service2.getBuckets().stream().allMatch(x -> x.getRetentionFutureMap().size() == 2));
    service2.stopAsync();
    service2.awaitTerminated();
    zkClient2.close();
    zkServer2.close();
    streamMetadataTasks2.close();
    connectionFactory.close();
    executor2.shutdown();
}
Also used : TestingServer(org.apache.curator.test.TestingServer) CuratorFrameworkFactory(org.apache.curator.framework.CuratorFrameworkFactory) StreamStoreFactory(io.pravega.controller.store.stream.StreamStoreFactory) StreamImpl(io.pravega.client.stream.impl.StreamImpl) SegmentHelper(io.pravega.controller.server.SegmentHelper) RetentionPolicy(io.pravega.client.stream.RetentionPolicy) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CompletableFuture(java.util.concurrent.CompletableFuture) Lists(com.google.common.collect.Lists) TaskMetadataStore(io.pravega.controller.store.task.TaskMetadataStore) TestingServerStarter(io.pravega.test.common.TestingServerStarter) Stream(io.pravega.client.stream.Stream) Duration(java.time.Duration) After(org.junit.After) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) TestingServer(org.apache.curator.test.TestingServer) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) HostMonitorConfigImpl(io.pravega.controller.store.host.impl.HostMonitorConfigImpl) RetryHelper(io.pravega.controller.util.RetryHelper) Before(org.junit.Before) SegmentHelperMock(io.pravega.controller.mocks.SegmentHelperMock) Executor(java.util.concurrent.Executor) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) UUID(java.util.UUID) HostStoreFactory(io.pravega.controller.store.host.HostStoreFactory) Executors(java.util.concurrent.Executors) List(java.util.List) TaskStoreFactory(io.pravega.controller.store.task.TaskStoreFactory) CuratorFramework(org.apache.curator.framework.CuratorFramework) ConnectionFactoryImpl(io.pravega.client.netty.impl.ConnectionFactoryImpl) HostControllerStore(io.pravega.controller.store.host.HostControllerStore) Assert.assertFalse(org.junit.Assert.assertFalse) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) ClientConfig(io.pravega.client.ClientConfig) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) TestingServerStarter(io.pravega.test.common.TestingServerStarter) TaskMetadataStore(io.pravega.controller.store.task.TaskMetadataStore) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) SegmentHelper(io.pravega.controller.server.SegmentHelper) CuratorFramework(org.apache.curator.framework.CuratorFramework) HostControllerStore(io.pravega.controller.store.host.HostControllerStore) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) ConnectionFactoryImpl(io.pravega.client.netty.impl.ConnectionFactoryImpl) Test(org.junit.Test)

Example 2 with StreamMetadataStore

use of io.pravega.controller.store.stream.StreamMetadataStore in project pravega by pravega.

the class ControllerDescribeStreamCommand method execute.

@Override
public void execute() {
    ensureArgCount(2);
    final String scope = getArg(0);
    final String stream = getArg(1);
    try {
        @Cleanup CuratorFramework zkClient = createZKClient();
        ScheduledExecutorService executor = getCommandArgs().getState().getExecutor();
        @Cleanup ConnectionPool pool = createConnectionPool();
        // The Pravega Controller service may store metadata either at Zookeeper or the Segment Store service
        // (tables). We need to instantiate the correct type of metadata store object based on the cluster at hand.
        StreamMetadataStore store;
        @Cleanup SegmentHelper segmentHelper = null;
        if (getCLIControllerConfig().getMetadataBackend().equals(CLIConfig.MetadataBackends.ZOOKEEPER.name())) {
            store = StreamStoreFactory.createZKStore(zkClient, executor);
        } else {
            segmentHelper = instantiateSegmentHelper(zkClient, pool);
            GrpcAuthHelper authHelper;
            authHelper = GrpcAuthHelper.getDisabledAuthHelper();
            store = StreamStoreFactory.createPravegaTablesStore(segmentHelper, authHelper, zkClient, executor);
        }
        // Output the configuration of this Stream.
        CompletableFuture<StreamConfiguration> streamConfig = store.getConfiguration(scope, stream, null, executor);
        prettyJSONOutput("stream_config", streamConfig.join());
        // Output the state for this Stream.
        prettyJSONOutput("stream_state", store.getState(scope, stream, true, null, executor).join());
        // Output the total number of segments for this Stream.
        Set<Long> segments = store.getAllSegmentIds(scope, stream, null, executor).join();
        prettyJSONOutput("segment_count", segments.size());
        // Check if the Stream is sealed.
        prettyJSONOutput("is_sealed", store.isSealed(scope, stream, null, executor).join());
        // Output the active epoch for this Stream.
        prettyJSONOutput("active_epoch", store.getActiveEpoch(scope, stream, null, true, executor).join());
        // Output the number of active Transactions for ths Stream.
        Map<UUID, ActiveTxnRecord> activeTxn = store.getActiveTxns(scope, stream, null, getCommandArgs().getState().getExecutor()).join();
        if (!activeTxn.isEmpty()) {
            prettyJSONOutput("active_transactions", activeTxn);
        }
        // Output Truncation point.
        prettyJSONOutput("truncation_record", store.getTruncationRecord(scope, stream, null, executor).join().getObject());
        // Output the metadata that describes all the scaling information for this Stream.
        prettyJSONOutput("scaling_info", store.getScaleMetadata(scope, stream, segments.stream().min(Long::compareTo).get(), segments.stream().max(Long::compareTo).get(), null, executor).join());
        // Cleanup resources.
        if (segmentHelper != null) {
            segmentHelper.close();
            store.close();
        }
    } catch (Exception e) {
        System.err.println("Exception accessing the metadata store: " + e.getMessage());
    }
}
Also used : ConnectionPool(io.pravega.client.connection.impl.ConnectionPool) ActiveTxnRecord(io.pravega.controller.store.stream.records.ActiveTxnRecord) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) SegmentHelper(io.pravega.controller.server.SegmentHelper) Cleanup(lombok.Cleanup) CuratorFramework(org.apache.curator.framework.CuratorFramework) GrpcAuthHelper(io.pravega.controller.server.security.auth.GrpcAuthHelper) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) UUID(java.util.UUID)

Example 3 with StreamMetadataStore

use of io.pravega.controller.store.stream.StreamMetadataStore in project pravega by pravega.

the class ControllerEventProcessorsTest method testBootstrap.

@Test(timeout = 30000L)
public void testBootstrap() throws Exception {
    LocalController controller = mock(LocalController.class);
    CheckpointStore checkpointStore = mock(CheckpointStore.class);
    StreamMetadataStore streamStore = mock(StreamMetadataStore.class);
    BucketStore bucketStore = mock(BucketStore.class);
    ConnectionPool connectionPool = mock(ConnectionPool.class);
    StreamMetadataTasks streamMetadataTasks = mock(StreamMetadataTasks.class);
    StreamTransactionMetadataTasks streamTransactionMetadataTasks = mock(StreamTransactionMetadataTasks.class);
    KVTableMetadataStore kvtStore = mock(KVTableMetadataStore.class);
    TableMetadataTasks kvtTasks = mock(TableMetadataTasks.class);
    ControllerEventProcessorConfig config = ControllerEventProcessorConfigImpl.withDefault();
    EventProcessorSystem system = mock(EventProcessorSystem.class);
    doAnswer(x -> null).when(streamMetadataTasks).initializeStreamWriters(any(), any());
    doAnswer(x -> null).when(streamTransactionMetadataTasks).initializeStreamWriters(any(EventStreamClientFactory.class), any(ControllerEventProcessorConfig.class));
    LinkedBlockingQueue<CompletableFuture<Boolean>> createScopeResponses = new LinkedBlockingQueue<>();
    LinkedBlockingQueue<CompletableFuture<Void>> createScopeSignals = new LinkedBlockingQueue<>();
    List<CompletableFuture<Boolean>> createScopeResponsesList = new LinkedList<>();
    List<CompletableFuture<Void>> createScopeSignalsList = new LinkedList<>();
    for (int i = 0; i < 2; i++) {
        CompletableFuture<Boolean> responseFuture = new CompletableFuture<>();
        CompletableFuture<Void> signalFuture = new CompletableFuture<>();
        createScopeResponsesList.add(responseFuture);
        createScopeResponses.add(responseFuture);
        createScopeSignalsList.add(signalFuture);
        createScopeSignals.add(signalFuture);
    }
    // return a future from latches queue
    doAnswer(x -> {
        createScopeSignals.take().complete(null);
        return createScopeResponses.take();
    }).when(controller).createScope(anyString());
    LinkedBlockingQueue<CompletableFuture<Boolean>> createStreamResponses = new LinkedBlockingQueue<>();
    LinkedBlockingQueue<CompletableFuture<Void>> createStreamSignals = new LinkedBlockingQueue<>();
    List<CompletableFuture<Boolean>> createStreamResponsesList = new LinkedList<>();
    List<CompletableFuture<Void>> createStreamSignalsList = new LinkedList<>();
    for (int i = 0; i < 8; i++) {
        CompletableFuture<Boolean> responseFuture = new CompletableFuture<>();
        CompletableFuture<Void> signalFuture = new CompletableFuture<>();
        createStreamResponsesList.add(responseFuture);
        createStreamResponses.add(responseFuture);
        createStreamSignalsList.add(signalFuture);
        createStreamSignals.add(signalFuture);
    }
    // return a future from latches queue
    doAnswer(x -> {
        createStreamSignals.take().complete(null);
        return createStreamResponses.take();
    }).when(controller).createInternalStream(anyString(), anyString(), any());
    @Cleanup ControllerEventProcessors processors = new ControllerEventProcessors("host1", config, controller, checkpointStore, streamStore, bucketStore, connectionPool, streamMetadataTasks, streamTransactionMetadataTasks, kvtStore, kvtTasks, system, executorService());
    // call bootstrap on ControllerEventProcessors
    processors.bootstrap(streamTransactionMetadataTasks, streamMetadataTasks, kvtTasks);
    // wait on create scope being called.
    createScopeSignalsList.get(0).join();
    verify(controller, times(1)).createScope(any());
    // complete scopeFuture1 exceptionally. this should result in a retry.
    createScopeResponsesList.get(0).completeExceptionally(new RuntimeException());
    // wait on second scope signal being called
    createScopeSignalsList.get(1).join();
    verify(controller, times(2)).createScope(any());
    // so far no create stream should have been invoked
    verify(controller, times(0)).createInternalStream(anyString(), anyString(), any());
    // complete scopeFuture2 successfully
    createScopeResponsesList.get(1).complete(true);
    // create streams should be called now
    // since we call four create streams. We will wait on first three signal futures
    createStreamSignalsList.get(0).join();
    createStreamSignalsList.get(1).join();
    createStreamSignalsList.get(2).join();
    createStreamSignalsList.get(3).join();
    verify(controller, times(4)).createInternalStream(anyString(), anyString(), any());
    // fail first four requests
    createStreamResponsesList.get(0).completeExceptionally(new RuntimeException());
    createStreamResponsesList.get(1).completeExceptionally(new RuntimeException());
    createStreamResponsesList.get(2).completeExceptionally(new RuntimeException());
    createStreamResponsesList.get(3).completeExceptionally(new RuntimeException());
    // this should result in a retry for four create streams. wait on next four signals
    createStreamSignalsList.get(4).join();
    createStreamSignalsList.get(5).join();
    createStreamSignalsList.get(6).join();
    createStreamSignalsList.get(7).join();
    verify(controller, times(8)).createInternalStream(anyString(), anyString(), any());
    // complete successfully
    createStreamResponsesList.get(4).complete(true);
    createStreamResponsesList.get(5).complete(true);
    createStreamResponsesList.get(6).complete(true);
    createStreamResponsesList.get(7).complete(true);
    AssertExtensions.assertEventuallyEquals(true, () -> processors.getBootstrapCompleted().get(), 10000);
}
Also used : ConnectionPool(io.pravega.client.connection.impl.ConnectionPool) EventProcessorSystem(io.pravega.controller.eventProcessor.EventProcessorSystem) EventStreamClientFactory(io.pravega.client.EventStreamClientFactory) CheckpointStore(io.pravega.controller.store.checkpoint.CheckpointStore) ZKCheckpointStore(io.pravega.controller.store.checkpoint.ZKCheckpointStore) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Cleanup(lombok.Cleanup) CompletableFuture(java.util.concurrent.CompletableFuture) StreamTransactionMetadataTasks(io.pravega.controller.task.Stream.StreamTransactionMetadataTasks) TableMetadataTasks(io.pravega.controller.task.KeyValueTable.TableMetadataTasks) BucketStore(io.pravega.controller.store.stream.BucketStore) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) KVTableMetadataStore(io.pravega.controller.store.kvtable.KVTableMetadataStore) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 4 with StreamMetadataStore

use of io.pravega.controller.store.stream.StreamMetadataStore in project pravega by pravega.

the class ControllerEventProcessorsTest method testIsReady.

@Test(timeout = 30000L)
public void testIsReady() throws Exception {
    LocalController controller = mock(LocalController.class);
    StreamMetadataStore streamStore = mock(StreamMetadataStore.class);
    BucketStore bucketStore = mock(BucketStore.class);
    ConnectionPool connectionPool = mock(ConnectionPool.class);
    StreamMetadataTasks streamMetadataTasks = mock(StreamMetadataTasks.class);
    StreamTransactionMetadataTasks streamTransactionMetadataTasks = mock(StreamTransactionMetadataTasks.class);
    KVTableMetadataStore kvtStore = mock(KVTableMetadataStore.class);
    TableMetadataTasks kvtTasks = mock(TableMetadataTasks.class);
    ControllerEventProcessorConfig config = ControllerEventProcessorConfigImpl.withDefault();
    EventProcessorSystem system = mock(EventProcessorSystem.class);
    CuratorZookeeperClient curatorZKClientMock = mock(CuratorZookeeperClient.class);
    CuratorFramework client = mock(CuratorFramework.class);
    Listenable listen = mock(Listenable.class);
    doNothing().when(listen).addListener(any(ConnectionStateListener.class));
    doReturn(listen).when(client).getConnectionStateListenable();
    doReturn(curatorZKClientMock).when(client).getZookeeperClient();
    doReturn(true).when(curatorZKClientMock).isConnected();
    ZKCheckpointStore checkpointStore = (ZKCheckpointStore) CheckpointStoreFactory.createZKStore(client);
    doAnswer(x -> null).when(streamMetadataTasks).initializeStreamWriters(any(), any());
    doAnswer(x -> null).when(streamTransactionMetadataTasks).initializeStreamWriters(any(EventStreamClientFactory.class), any(ControllerEventProcessorConfig.class));
    CompletableFuture<Boolean> createScopeResponseFuture = new CompletableFuture<>();
    CompletableFuture<Void> createScopeSignalFuture = new CompletableFuture<>();
    doAnswer(x -> {
        createScopeSignalFuture.complete(null);
        return createScopeResponseFuture;
    }).when(controller).createScope(anyString());
    LinkedBlockingQueue<CompletableFuture<Boolean>> createStreamResponses = new LinkedBlockingQueue<>();
    LinkedBlockingQueue<CompletableFuture<Void>> createStreamSignals = new LinkedBlockingQueue<>();
    List<CompletableFuture<Boolean>> createStreamResponsesList = new LinkedList<>();
    List<CompletableFuture<Void>> createStreamSignalsList = new LinkedList<>();
    for (int i = 0; i < 4; i++) {
        CompletableFuture<Boolean> responseFuture = new CompletableFuture<>();
        CompletableFuture<Void> signalFuture = new CompletableFuture<>();
        createStreamResponsesList.add(responseFuture);
        createStreamResponses.add(responseFuture);
        createStreamSignalsList.add(signalFuture);
        createStreamSignals.add(signalFuture);
    }
    // return a future from latches queue
    doAnswer(x -> {
        createStreamSignals.take().complete(null);
        return createStreamResponses.take();
    }).when(controller).createInternalStream(anyString(), anyString(), any());
    @Cleanup ControllerEventProcessors processors = spy(new ControllerEventProcessors("host1", config, controller, checkpointStore, streamStore, bucketStore, connectionPool, streamMetadataTasks, streamTransactionMetadataTasks, kvtStore, kvtTasks, system, executorService()));
    // Check isReady() method before invoking bootstrap
    Assert.assertFalse(processors.getBootstrapCompleted().get());
    Assert.assertTrue(processors.isMetadataServiceConnected());
    Assert.assertFalse(processors.isRunning());
    Assert.assertFalse(processors.isReady());
    // Call bootstrap on ControllerEventProcessors
    processors.bootstrap(streamTransactionMetadataTasks, streamMetadataTasks, kvtTasks);
    // Wait on create scope being called.
    createScopeSignalFuture.join();
    createScopeResponseFuture.complete(true);
    createStreamSignalsList.get(0).join();
    createStreamSignalsList.get(1).join();
    createStreamSignalsList.get(2).join();
    createStreamSignalsList.get(3).join();
    createStreamResponsesList.get(0).complete(true);
    createStreamResponsesList.get(1).complete(true);
    createStreamResponsesList.get(2).complete(true);
    createStreamResponsesList.get(3).complete(true);
    AssertExtensions.assertEventuallyEquals(true, () -> processors.getBootstrapCompleted().get(), 10000);
    Assert.assertTrue(processors.isMetadataServiceConnected());
    Assert.assertFalse(processors.isRunning());
    Assert.assertFalse(processors.isReady());
    EventProcessorGroup mockEventProcessorGroup = mock(EventProcessorGroup.class);
    doNothing().when(mockEventProcessorGroup).awaitRunning();
    doReturn(mockEventProcessorGroup).when(system).createEventProcessorGroup(any(EventProcessorConfig.class), any(CheckpointStore.class), any(ScheduledExecutorService.class));
    processors.startAsync();
    processors.awaitRunning();
    Assert.assertTrue(processors.isMetadataServiceConnected());
    Assert.assertTrue(processors.isBootstrapCompleted());
    Assert.assertTrue(processors.isRunning());
    Assert.assertTrue(processors.isReady());
}
Also used : ConnectionPool(io.pravega.client.connection.impl.ConnectionPool) EventProcessorSystem(io.pravega.controller.eventProcessor.EventProcessorSystem) EventStreamClientFactory(io.pravega.client.EventStreamClientFactory) CheckpointStore(io.pravega.controller.store.checkpoint.CheckpointStore) ZKCheckpointStore(io.pravega.controller.store.checkpoint.ZKCheckpointStore) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Cleanup(lombok.Cleanup) ZKCheckpointStore(io.pravega.controller.store.checkpoint.ZKCheckpointStore) CuratorFramework(org.apache.curator.framework.CuratorFramework) CompletableFuture(java.util.concurrent.CompletableFuture) StreamTransactionMetadataTasks(io.pravega.controller.task.Stream.StreamTransactionMetadataTasks) TableMetadataTasks(io.pravega.controller.task.KeyValueTable.TableMetadataTasks) BucketStore(io.pravega.controller.store.stream.BucketStore) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ConnectionStateListener(org.apache.curator.framework.state.ConnectionStateListener) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) KVTableMetadataStore(io.pravega.controller.store.kvtable.KVTableMetadataStore) EventProcessorGroup(io.pravega.controller.eventProcessor.EventProcessorGroup) LinkedList(java.util.LinkedList) Listenable(org.apache.curator.framework.listen.Listenable) CuratorZookeeperClient(org.apache.curator.CuratorZookeeperClient) EventProcessorConfig(io.pravega.controller.eventProcessor.EventProcessorConfig) Test(org.junit.Test)

Example 5 with StreamMetadataStore

use of io.pravega.controller.store.stream.StreamMetadataStore in project pravega by pravega.

the class ControllerEventProcessorsTest method testHandleOrphaned.

@Test(timeout = 10000)
public void testHandleOrphaned() throws CheckpointStoreException {
    LocalController localController = mock(LocalController.class);
    CheckpointStore checkpointStore = mock(CheckpointStore.class);
    StreamMetadataStore streamStore = mock(StreamMetadataStore.class);
    BucketStore bucketStore = mock(BucketStore.class);
    ConnectionPool connectionPool = mock(ConnectionPool.class);
    StreamMetadataTasks streamMetadataTasks = mock(StreamMetadataTasks.class);
    StreamTransactionMetadataTasks streamTransactionMetadataTasks = mock(StreamTransactionMetadataTasks.class);
    KVTableMetadataStore kvtStore = mock(KVTableMetadataStore.class);
    TableMetadataTasks kvtTasks = mock(TableMetadataTasks.class);
    ControllerEventProcessorConfig config = ControllerEventProcessorConfigImpl.withDefault();
    EventProcessorSystem system = mock(EventProcessorSystem.class);
    EventProcessorGroup<ControllerEvent> processor = getProcessor();
    EventProcessorGroup<ControllerEvent> mockProcessor = spy(processor);
    doThrow(new CheckpointStoreException("host not found")).when(mockProcessor).notifyProcessFailure("host3");
    when(system.createEventProcessorGroup(any(), any(), any())).thenReturn(mockProcessor);
    @Cleanup ControllerEventProcessors processors = new ControllerEventProcessors("host1", config, localController, checkpointStore, streamStore, bucketStore, connectionPool, streamMetadataTasks, streamTransactionMetadataTasks, kvtStore, kvtTasks, system, executorService());
    // check for a case where init is not initialized so that kvtRequestProcessors don't get initialized and will be null
    assertTrue(Futures.await(processors.sweepFailedProcesses(() -> Sets.newHashSet("host1"))));
    Assert.assertFalse(processors.isReady());
    Assert.assertFalse(processors.isBootstrapCompleted());
    Assert.assertFalse(processors.isMetadataServiceConnected());
    processors.startAsync();
    processors.awaitRunning();
    assertTrue(Futures.await(processors.sweepFailedProcesses(() -> Sets.newHashSet("host1"))));
    assertTrue(Futures.await(processors.handleFailedProcess("host1")));
    AssertExtensions.assertFutureThrows("host not found", processors.handleFailedProcess("host3"), e -> e instanceof CheckpointStoreException);
    processors.shutDown();
}
Also used : ConnectionPool(io.pravega.client.connection.impl.ConnectionPool) KVTableMetadataStore(io.pravega.controller.store.kvtable.KVTableMetadataStore) EventProcessorSystem(io.pravega.controller.eventProcessor.EventProcessorSystem) CheckpointStore(io.pravega.controller.store.checkpoint.CheckpointStore) ZKCheckpointStore(io.pravega.controller.store.checkpoint.ZKCheckpointStore) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) Cleanup(lombok.Cleanup) ControllerEvent(io.pravega.shared.controller.event.ControllerEvent) StreamTransactionMetadataTasks(io.pravega.controller.task.Stream.StreamTransactionMetadataTasks) CheckpointStoreException(io.pravega.controller.store.checkpoint.CheckpointStoreException) TableMetadataTasks(io.pravega.controller.task.KeyValueTable.TableMetadataTasks) BucketStore(io.pravega.controller.store.stream.BucketStore) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) Test(org.junit.Test)

Aggregations

StreamMetadataStore (io.pravega.controller.store.stream.StreamMetadataStore)38 Test (org.junit.Test)29 CompletableFuture (java.util.concurrent.CompletableFuture)23 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)17 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)17 UUID (java.util.UUID)14 StreamMetadataTasks (io.pravega.controller.task.Stream.StreamMetadataTasks)13 BucketStore (io.pravega.controller.store.stream.BucketStore)12 StreamTransactionMetadataTasks (io.pravega.controller.task.Stream.StreamTransactionMetadataTasks)12 Cleanup (lombok.Cleanup)12 SegmentHelper (io.pravega.controller.server.SegmentHelper)11 GrpcAuthHelper (io.pravega.controller.server.security.auth.GrpcAuthHelper)11 TaskMetadataStore (io.pravega.controller.store.task.TaskMetadataStore)11 KVTableMetadataStore (io.pravega.controller.store.kvtable.KVTableMetadataStore)10 UpdateStreamTask (io.pravega.controller.server.eventProcessor.requesthandlers.UpdateStreamTask)9 EventStreamWriterMock (io.pravega.controller.mocks.EventStreamWriterMock)8 ScaleOperationTask (io.pravega.controller.server.eventProcessor.requesthandlers.ScaleOperationTask)8 CommitEvent (io.pravega.shared.controller.event.CommitEvent)8 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)8 CuratorFramework (org.apache.curator.framework.CuratorFramework)8