Search in sources :

Example 11 with KeyValueTableConfiguration

use of io.pravega.client.tables.KeyValueTableConfiguration in project pravega by pravega.

the class TableMetadataTasksTest method testCreateKeyValueTable.

@Test(timeout = 30000)
public void testCreateKeyValueTable() throws ExecutionException, InterruptedException {
    Assert.assertTrue(isScopeCreated);
    long creationTime = System.currentTimeMillis();
    KeyValueTableConfiguration kvtConfig = KeyValueTableConfiguration.builder().partitionCount(2).primaryKeyLength(4).secondaryKeyLength(4).build();
    CompletableFuture<Controller.CreateKeyValueTableStatus.Status> createOperationFuture = kvtMetadataTasks.createKeyValueTable(SCOPE, kvtable1, kvtConfig, creationTime, 0L);
    assertTrue(Futures.await(processEvent((TableMetadataTasksTest.WriterMock) requestEventWriter)));
    assertEquals(CreateKeyValueTableStatus.Status.SUCCESS, createOperationFuture.join());
    List<KVTSegmentRecord> segmentsList = kvtStore.getActiveSegments(SCOPE, kvtable1, null, executor).get();
    assertEquals(segmentsList.size(), kvtConfig.getPartitionCount());
    long storedCreationTime = kvtStore.getCreationTime(SCOPE, kvtable1, null, executor).get();
    assertEquals(storedCreationTime, creationTime);
    KeyValueTableConfiguration storedConfig = kvtStore.getConfiguration(SCOPE, kvtable1, null, executor).get();
    assertEquals(storedConfig.getPartitionCount(), kvtConfig.getPartitionCount());
    // check retry failures...
    EventHelper mockHelper = EventHelperMock.getFailingEventHelperMock();
    TableMetadataTasks kvtFailingMetaTasks = spy(new TableMetadataTasks(kvtStore, segmentHelperMock, executor, executor, "host", GrpcAuthHelper.getDisabledAuthHelper(), mockHelper));
    AssertExtensions.assertFutureThrows("addIndexAndSubmitTask throws exception", kvtFailingMetaTasks.createKeyValueTable(SCOPE, kvtable1, kvtConfig, creationTime, 0L), e -> Exceptions.unwrap(e) instanceof RuntimeException);
}
Also used : CreateScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateScopeStatus) DeleteKVTableStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteKVTableStatus) CreateKeyValueTableStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateKeyValueTableStatus) KeyValueTableConfiguration(io.pravega.client.tables.KeyValueTableConfiguration) EventHelper(io.pravega.controller.task.EventHelper) KVTSegmentRecord(io.pravega.controller.store.kvtable.records.KVTSegmentRecord) Controller(io.pravega.controller.stream.api.grpc.v1.Controller) Test(org.junit.Test)

Example 12 with KeyValueTableConfiguration

use of io.pravega.client.tables.KeyValueTableConfiguration in project pravega by pravega.

the class ControllerImplTest method testGetKeyValueTableConfiguration.

@Test
public void testGetKeyValueTableConfiguration() {
    KeyValueTableConfiguration kvtConfig = controllerClient.getKeyValueTableConfiguration("scope1", "kvtable").join();
    assertEquals(3, kvtConfig.getPartitionCount());
    assertEquals(Integer.BYTES, kvtConfig.getPrimaryKeyLength());
    assertEquals(Long.BYTES, kvtConfig.getSecondaryKeyLength());
    AssertExtensions.assertFutureThrows("Non existent key-value table", controllerClient.getKeyValueTableConfiguration("scope1", NON_EXISTENT), t -> t instanceof IllegalArgumentException);
    AssertExtensions.assertFutureThrows("Server should throw exception", controllerClient.getKeyValueTableConfiguration("scope1", FAILING), t -> t instanceof ControllerFailureException);
    AssertExtensions.assertFutureThrows("Server should throw exception", controllerClient.getKeyValueTableConfiguration("scope1", "failing request"), t -> t instanceof RetriesExhaustedException);
}
Also used : KeyValueTableConfiguration(io.pravega.client.tables.KeyValueTableConfiguration) RetriesExhaustedException(io.pravega.common.util.RetriesExhaustedException) Test(org.junit.Test)

Example 13 with KeyValueTableConfiguration

use of io.pravega.client.tables.KeyValueTableConfiguration in project pravega by pravega.

the class RequestHandlersTest method scopeDeleteTest.

@Test
public void scopeDeleteTest() {
    final String testScope = "testScope";
    final String testStream = "testStream";
    final String testRG = "_RGTestRG";
    final String testKVT = "testKVT";
    StreamMetadataStore streamStoreSpied = spy(getStore());
    KVTableMetadataStore kvtStoreSpied = spy(getKvtStore());
    StreamMetadataTasks streamMetadataTasks1 = mock(StreamMetadataTasks.class);
    TableMetadataTasks kvtTasksMocked = mock(TableMetadataTasks.class);
    streamStoreSpied.createScope(testScope, null, executor).join();
    OperationContext ctx = new OperationContext() {

        @Override
        public long getOperationStartTime() {
            return 0;
        }

        @Override
        public long getRequestId() {
            return 0;
        }
    };
    UUID scopeId = streamStoreSpied.getScopeId(testScope, ctx, executor).join();
    doAnswer(x -> {
        CompletableFuture<UUID> cf = new CompletableFuture<>();
        cf.complete(scopeId);
        return cf;
    }).when(streamStoreSpied).getScopeId(eq(testScope), eq(ctx), eq(executor));
    doAnswer(invocation -> {
        CompletableFuture<Boolean> cf = new CompletableFuture<>();
        cf.complete(true);
        return cf;
    }).when(streamStoreSpied).isScopeSealed(eq(testScope), any(), any());
    createStreamInStore(testStream, testScope);
    createStreamInStore(testRG, testScope);
    assertTrue(streamStore.checkStreamExists(testScope, testStream, ctx, executor).join());
    doAnswer(invocation -> {
        CompletableFuture<Controller.UpdateStreamStatus.Status> future = new CompletableFuture<>();
        future.complete(Controller.UpdateStreamStatus.Status.SUCCESS);
        return future;
    }).when(streamMetadataTasks1).sealStream(anyString(), anyString(), anyLong());
    doAnswer(invocation -> {
        CompletableFuture<Controller.DeleteStreamStatus.Status> future = new CompletableFuture<>();
        future.complete(Controller.DeleteStreamStatus.Status.SUCCESS);
        return future;
    }).when(streamMetadataTasks1).deleteStream(anyString(), anyString(), anyLong());
    // Create Reader Group
    ReaderGroupConfig rgConfig = ReaderGroupConfig.builder().stream(NameUtils.getScopedStreamName(testScope, testStream)).build();
    final ReaderGroupConfig config = ReaderGroupConfig.cloneConfig(rgConfig, UUID.randomUUID(), 123L);
    Controller.ReaderGroupConfiguration expectedConfig = ModelHelper.decode(testScope, testRG, config);
    doAnswer(invocationOnMock -> {
        CompletableFuture<Controller.CreateReaderGroupResponse.Status> createRG = new CompletableFuture<>();
        createRG.complete(Controller.CreateReaderGroupResponse.Status.SUCCESS);
        return createRG;
    }).when(streamMetadataTasks1).createReaderGroup(anyString(), any(), any(), anyLong(), anyLong());
    doAnswer(invocation -> CompletableFuture.completedFuture(Controller.ReaderGroupConfigResponse.newBuilder().setStatus(Controller.ReaderGroupConfigResponse.Status.SUCCESS).setConfig(expectedConfig).build())).when(streamMetadataTasks1).getReaderGroupConfig(eq(testScope), anyString(), anyLong());
    doAnswer(invocationOnMock -> {
        CompletableFuture<Controller.DeleteReaderGroupStatus.Status> future = new CompletableFuture<>();
        future.complete(Controller.DeleteReaderGroupStatus.Status.SUCCESS);
        return future;
    }).when(streamMetadataTasks1).deleteReaderGroup(anyString(), anyString(), anyString(), anyLong());
    // Create KVT
    KeyValueTableConfiguration kvtConfig = KeyValueTableConfiguration.builder().partitionCount(1).primaryKeyLength(1).secondaryKeyLength(1).build();
    doAnswer(invocationOnMock -> {
        CompletableFuture<Controller.CreateKeyValueTableStatus.Status> fut = new CompletableFuture<>();
        fut.complete(Controller.CreateKeyValueTableStatus.Status.SUCCESS);
        return fut;
    }).when(kvtTasksMocked).createKeyValueTable(anyString(), anyString(), any(), anyLong(), anyLong());
    List<String> tableList = new ArrayList<>();
    tableList.add(testKVT);
    Pair<List<String>, String> listOfKVTables = new ImmutablePair<>(tableList, "");
    doAnswer(invocationOnMock -> CompletableFuture.completedFuture(listOfKVTables)).doAnswer(invocationOnMock -> CompletableFuture.completedFuture(new ImmutablePair<>(Collections.emptyList(), invocationOnMock.getArgument(0)))).when(kvtStoreSpied).listKeyValueTables(anyString(), any(), anyInt(), any(), any());
    doAnswer(invocationOnMock -> {
        CompletableFuture<Controller.DeleteKVTableStatus.Status> future = new CompletableFuture<>();
        future.complete(Controller.DeleteKVTableStatus.Status.SUCCESS);
        return future;
    }).when(kvtTasksMocked).deleteKeyValueTable(anyString(), anyString(), anyLong());
    Controller.CreateKeyValueTableStatus.Status status = kvtTasksMocked.createKeyValueTable(testScope, testKVT, kvtConfig, System.currentTimeMillis(), 123L).join();
    assertEquals(status, Controller.CreateKeyValueTableStatus.Status.SUCCESS);
    DeleteScopeTask requestHandler = new DeleteScopeTask(streamMetadataTasks1, streamStoreSpied, kvtStoreSpied, kvtTasksMocked, executor);
    DeleteScopeEvent event = new DeleteScopeEvent(testScope, 123L, scopeId);
    CompletableFuture<Void> future = requestHandler.execute(event);
    future.join();
}
Also used : UpdateStreamEvent(io.pravega.shared.controller.event.UpdateStreamEvent) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) InetAddress(java.net.InetAddress) StoreException(io.pravega.controller.store.stream.StoreException) Pair(org.apache.commons.lang3.tuple.Pair) AutoScaleTask(io.pravega.controller.server.eventProcessor.requesthandlers.AutoScaleTask) TaskMetadataStore(io.pravega.controller.store.task.TaskMetadataStore) Map(java.util.Map) Mockito.doAnswer(org.mockito.Mockito.doAnswer) ReaderGroupConfig(io.pravega.client.stream.ReaderGroupConfig) StreamTruncationRecord(io.pravega.controller.store.stream.records.StreamTruncationRecord) DeleteStreamEvent(io.pravega.shared.controller.event.DeleteStreamEvent) Mockito.atLeastOnce(org.mockito.Mockito.atLeastOnce) RequestTracker(io.pravega.common.tracing.RequestTracker) KVTableMetadataStore(io.pravega.controller.store.kvtable.KVTableMetadataStore) Assert.assertFalse(org.junit.Assert.assertFalse) CreateReaderGroupTask(io.pravega.controller.server.eventProcessor.requesthandlers.CreateReaderGroupTask) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) EventStreamWriterMock(io.pravega.controller.mocks.EventStreamWriterMock) Futures(io.pravega.common.concurrent.Futures) GrpcAuthHelper(io.pravega.controller.server.security.auth.GrpcAuthHelper) Mockito.mock(org.mockito.Mockito.mock) CuratorFrameworkFactory(org.apache.curator.framework.CuratorFrameworkFactory) StreamMetrics(io.pravega.controller.metrics.StreamMetrics) StreamStoreFactory(io.pravega.controller.store.stream.StreamStoreFactory) TransactionMetrics(io.pravega.controller.metrics.TransactionMetrics) ConnectionFactory(io.pravega.client.connection.impl.ConnectionFactory) Exceptions(io.pravega.common.Exceptions) TruncateStreamEvent(io.pravega.shared.controller.event.TruncateStreamEvent) Mockito.spy(org.mockito.Mockito.spy) ArrayList(java.util.ArrayList) Lists(com.google.common.collect.Lists) TestingServerStarter(io.pravega.test.common.TestingServerStarter) TestingServer(org.apache.curator.test.TestingServer) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) WireCommandType(io.pravega.shared.protocol.netty.WireCommandType) UpdateReaderGroupTask(io.pravega.controller.server.eventProcessor.requesthandlers.UpdateReaderGroupTask) Before(org.junit.Before) SegmentHelperMock(io.pravega.controller.mocks.SegmentHelperMock) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) TableMetadataTasks(io.pravega.controller.task.KeyValueTable.TableMetadataTasks) UnknownHostException(java.net.UnknownHostException) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) StreamConfigurationRecord(io.pravega.controller.store.stream.records.StreamConfigurationRecord) TaskStoreFactory(io.pravega.controller.store.task.TaskStoreFactory) WireCommandFailedException(io.pravega.controller.server.WireCommandFailedException) Version(io.pravega.controller.store.Version) StreamTransactionMetadataTasks(io.pravega.controller.task.Stream.StreamTransactionMetadataTasks) DeleteStreamTask(io.pravega.controller.server.eventProcessor.requesthandlers.DeleteStreamTask) StreamRequestHandler(io.pravega.controller.server.eventProcessor.requesthandlers.StreamRequestHandler) CommitRequestHandler(io.pravega.controller.server.eventProcessor.requesthandlers.CommitRequestHandler) ScalingPolicy(io.pravega.client.stream.ScalingPolicy) Assert.assertEquals(org.junit.Assert.assertEquals) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CommitEvent(io.pravega.shared.controller.event.CommitEvent) AssertExtensions(io.pravega.test.common.AssertExtensions) KeyValueTableConfiguration(io.pravega.client.tables.KeyValueTableConfiguration) SealStreamEvent(io.pravega.shared.controller.event.SealStreamEvent) VersionedMetadata(io.pravega.controller.store.VersionedMetadata) After(org.junit.After) Controller(io.pravega.controller.stream.api.grpc.v1.Controller) SealStreamTask(io.pravega.controller.server.eventProcessor.requesthandlers.SealStreamTask) Predicate(java.util.function.Predicate) Collection(java.util.Collection) DeleteScopeEvent(io.pravega.shared.controller.event.DeleteScopeEvent) PravegaZkCuratorResource(io.pravega.controller.PravegaZkCuratorResource) UUID(java.util.UUID) ScaleOperationTask(io.pravega.controller.server.eventProcessor.requesthandlers.ScaleOperationTask) Collectors(java.util.stream.Collectors) List(java.util.List) CuratorFramework(org.apache.curator.framework.CuratorFramework) Config(io.pravega.controller.util.Config) UpdateStreamTask(io.pravega.controller.server.eventProcessor.requesthandlers.UpdateStreamTask) VersionedTransactionData(io.pravega.controller.store.stream.VersionedTransactionData) Optional(java.util.Optional) DeleteScopeTask(io.pravega.controller.server.eventProcessor.requesthandlers.DeleteScopeTask) TruncateStreamTask(io.pravega.controller.server.eventProcessor.requesthandlers.TruncateStreamTask) IntStream(java.util.stream.IntStream) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) OperationContext(io.pravega.controller.store.stream.OperationContext) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) CommittingTransactionsRecord(io.pravega.controller.store.stream.records.CommittingTransactionsRecord) SegmentHelper(io.pravega.controller.server.SegmentHelper) ModelHelper(io.pravega.client.control.impl.ModelHelper) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) BucketStore(io.pravega.controller.store.stream.BucketStore) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) EventStreamClientFactory(io.pravega.client.EventStreamClientFactory) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) SocketConnectionFactoryImpl(io.pravega.client.connection.impl.SocketConnectionFactoryImpl) NameUtils(io.pravega.shared.NameUtils) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Mockito.verify(org.mockito.Mockito.verify) AbstractMap(java.util.AbstractMap) EpochRecord(io.pravega.controller.store.stream.records.EpochRecord) State(io.pravega.controller.store.stream.State) ExecutorServiceHelpers(io.pravega.common.concurrent.ExecutorServiceHelpers) DeleteReaderGroupTask(io.pravega.controller.server.eventProcessor.requesthandlers.DeleteReaderGroupTask) ScaleOpEvent(io.pravega.shared.controller.event.ScaleOpEvent) Collections(java.util.Collections) ClientConfig(io.pravega.client.ClientConfig) DeleteScopeTask(io.pravega.controller.server.eventProcessor.requesthandlers.DeleteScopeTask) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) CompletableFuture(java.util.concurrent.CompletableFuture) TableMetadataTasks(io.pravega.controller.task.KeyValueTable.TableMetadataTasks) ArrayList(java.util.ArrayList) List(java.util.List) DeleteScopeEvent(io.pravega.shared.controller.event.DeleteScopeEvent) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) UUID(java.util.UUID) OperationContext(io.pravega.controller.store.stream.OperationContext) ReaderGroupConfig(io.pravega.client.stream.ReaderGroupConfig) KeyValueTableConfiguration(io.pravega.client.tables.KeyValueTableConfiguration) KVTableMetadataStore(io.pravega.controller.store.kvtable.KVTableMetadataStore) Controller(io.pravega.controller.stream.api.grpc.v1.Controller) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Test(org.junit.Test)

Example 14 with KeyValueTableConfiguration

use of io.pravega.client.tables.KeyValueTableConfiguration in project pravega by pravega.

the class CreateTableTask method execute.

@Override
public CompletableFuture<Void> execute(final CreateTableEvent request) {
    String scope = request.getScopeName();
    String kvt = request.getKvtName();
    int partitionCount = request.getPartitionCount();
    int primaryKeyLength = request.getPrimaryKeyLength();
    int secondaryKeyLength = request.getSecondaryKeyLength();
    long creationTime = request.getTimestamp();
    long requestId = request.getRequestId();
    long rolloverSize = request.getRolloverSizeBytes();
    String kvTableId = request.getTableId().toString();
    KeyValueTableConfiguration config = KeyValueTableConfiguration.builder().partitionCount(partitionCount).primaryKeyLength(primaryKeyLength).secondaryKeyLength(secondaryKeyLength).rolloverSizeBytes(rolloverSize).build();
    final OperationContext context = kvtMetadataStore.createContext(scope, kvt, requestId);
    return RetryHelper.withRetriesAsync(() -> getKeyValueTable(scope, kvt).thenCompose(table -> table.getId(context)).thenCompose(id -> {
        if (!id.equals(kvTableId)) {
            log.debug(requestId, "Skipped processing create event for KeyValueTable {}/{} with Id:{} as UUIDs did not match.", scope, kvt, id);
            return CompletableFuture.completedFuture(null);
        } else {
            return kvtMetadataStore.isScopeSealed(scope, context, executor).thenCompose(isScopeSealed -> {
                if (isScopeSealed) {
                    log.warn(requestId, "Scope {} is in sealed state: ", scope);
                    throw new IllegalStateException("Scope in sealed state: " + scope);
                }
                return this.kvtMetadataStore.createKeyValueTable(scope, kvt, config, creationTime, context, executor).thenComposeAsync(response -> {
                    // segments and change the state of the kvtable to active.
                    if (response.getStatus().equals(CreateKVTableResponse.CreateStatus.NEW) || response.getStatus().equals(CreateKVTableResponse.CreateStatus.EXISTS_CREATING)) {
                        final int startingSegmentNumber = response.getStartingSegmentNumber();
                        final int minNumSegments = response.getConfiguration().getPartitionCount();
                        final int keyLength = response.getConfiguration().getPrimaryKeyLength() + response.getConfiguration().getSecondaryKeyLength();
                        List<Long> newSegments = IntStream.range(startingSegmentNumber, startingSegmentNumber + minNumSegments).boxed().map(x -> NameUtils.computeSegmentId(x, 0)).collect(Collectors.toList());
                        kvtMetadataTasks.createNewSegments(scope, kvt, newSegments, keyLength, requestId, config.getRolloverSizeBytes()).thenCompose(y -> {
                            kvtMetadataStore.getVersionedState(scope, kvt, context, executor).thenCompose(state -> {
                                if (state.getObject().equals(KVTableState.CREATING)) {
                                    kvtMetadataStore.updateVersionedState(scope, kvt, KVTableState.ACTIVE, state, context, executor);
                                }
                                return CompletableFuture.completedFuture(null);
                            });
                            return CompletableFuture.completedFuture(null);
                        });
                    }
                    return CompletableFuture.completedFuture(null);
                }, executor);
            });
        }
    }), e -> Exceptions.unwrap(e) instanceof RetryableException, Integer.MAX_VALUE, executor);
}
Also used : OperationContext(io.pravega.controller.store.stream.OperationContext) IntStream(java.util.stream.IntStream) OperationContext(io.pravega.controller.store.stream.OperationContext) NameUtils(io.pravega.shared.NameUtils) KeyValueTable(io.pravega.controller.store.kvtable.KeyValueTable) Exceptions(io.pravega.common.Exceptions) LoggerFactory(org.slf4j.LoggerFactory) CompletableFuture(java.util.concurrent.CompletableFuture) CreateKVTableResponse(io.pravega.controller.store.kvtable.CreateKVTableResponse) KeyValueTableConfiguration(io.pravega.client.tables.KeyValueTableConfiguration) TableMetadataTasks(io.pravega.controller.task.KeyValueTable.TableMetadataTasks) Collectors(java.util.stream.Collectors) KVTableMetadataStore(io.pravega.controller.store.kvtable.KVTableMetadataStore) CreateTableEvent(io.pravega.shared.controller.event.kvtable.CreateTableEvent) List(java.util.List) TagLogger(io.pravega.common.tracing.TagLogger) RetryableException(io.pravega.controller.retryable.RetryableException) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Preconditions(com.google.common.base.Preconditions) KVTableState(io.pravega.controller.store.kvtable.KVTableState) RetryHelper(io.pravega.controller.util.RetryHelper) KeyValueTableConfiguration(io.pravega.client.tables.KeyValueTableConfiguration) RetryableException(io.pravega.controller.retryable.RetryableException) List(java.util.List)

Example 15 with KeyValueTableConfiguration

use of io.pravega.client.tables.KeyValueTableConfiguration in project pravega by pravega.

the class ScopeTest method testForceDeleteScope.

@Test
public void testForceDeleteScope() throws Exception {
    final String scope = "test";
    final String streamName1 = "test1";
    final String streamName2 = "test2";
    final String streamName3 = "test3";
    final String kvtName1 = "kvt1";
    final String kvtName2 = "kvt2";
    final String groupName1 = "rg1";
    final String groupName2 = "rg2";
    StreamConfiguration config = StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(1)).build();
    @Cleanup Controller controller = controllerWrapper.getController();
    ClientConfig clientConfig = ClientConfig.builder().controllerURI(URI.create("tcp://localhost:" + controllerPort)).build();
    @Cleanup ConnectionPool cp = new ConnectionPoolImpl(clientConfig, new SocketConnectionFactoryImpl(clientConfig));
    @Cleanup ConnectionFactory connectionFactory = new SocketConnectionFactoryImpl(clientConfig);
    controllerWrapper.getControllerService().createScope(scope, 0L).get();
    controller.createStream(scope, streamName1, config).get();
    controller.createStream(scope, streamName2, config).get();
    controller.createStream(scope, streamName3, config).get();
    @Cleanup StreamManager streamManager = new StreamManagerImpl(controller, cp);
    @Cleanup KeyValueTableManager keyValueTableManager = new KeyValueTableManagerImpl(clientConfig);
    @Cleanup ReaderGroupManager readerGroupManager = new ReaderGroupManagerImpl(scope, clientConfig, connectionFactory);
    KeyValueTableConfiguration kvtConfig = KeyValueTableConfiguration.builder().partitionCount(2).primaryKeyLength(4).secondaryKeyLength(4).build();
    keyValueTableManager.createKeyValueTable(scope, kvtName1, kvtConfig);
    keyValueTableManager.createKeyValueTable(scope, kvtName2, kvtConfig);
    readerGroupManager.createReaderGroup(groupName1, ReaderGroupConfig.builder().stream(getScopedStreamName(scope, streamName1)).build());
    readerGroupManager.createReaderGroup(groupName2, ReaderGroupConfig.builder().stream(getScopedStreamName(scope, streamName2)).build());
    assertTrue(streamManager.deleteScope(scope, true));
}
Also used : ConnectionPool(io.pravega.client.connection.impl.ConnectionPool) KeyValueTableManager(io.pravega.client.admin.KeyValueTableManager) ReaderGroupManager(io.pravega.client.admin.ReaderGroupManager) KeyValueTableConfiguration(io.pravega.client.tables.KeyValueTableConfiguration) ConnectionPoolImpl(io.pravega.client.connection.impl.ConnectionPoolImpl) StreamManagerImpl(io.pravega.client.admin.impl.StreamManagerImpl) Controller(io.pravega.client.control.impl.Controller) SocketConnectionFactoryImpl(io.pravega.client.connection.impl.SocketConnectionFactoryImpl) Cleanup(lombok.Cleanup) ConnectionFactory(io.pravega.client.connection.impl.ConnectionFactory) KeyValueTableManagerImpl(io.pravega.client.admin.impl.KeyValueTableManagerImpl) StreamManager(io.pravega.client.admin.StreamManager) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) ClientConfig(io.pravega.client.ClientConfig) ReaderGroupManagerImpl(io.pravega.client.admin.impl.ReaderGroupManagerImpl) Test(org.junit.Test)

Aggregations

KeyValueTableConfiguration (io.pravega.client.tables.KeyValueTableConfiguration)20 Test (org.junit.Test)16 Controller (io.pravega.controller.stream.api.grpc.v1.Controller)8 CreateKeyValueTableStatus (io.pravega.controller.stream.api.grpc.v1.Controller.CreateKeyValueTableStatus)8 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)7 CreateScopeStatus (io.pravega.controller.stream.api.grpc.v1.Controller.CreateScopeStatus)7 DeleteKVTableStatus (io.pravega.controller.stream.api.grpc.v1.Controller.DeleteKVTableStatus)7 Exceptions (io.pravega.common.Exceptions)5 List (java.util.List)5 ClientConfig (io.pravega.client.ClientConfig)4 Controller (io.pravega.client.control.impl.Controller)4 ReaderGroupConfig (io.pravega.client.stream.ReaderGroupConfig)4 Futures (io.pravega.common.concurrent.Futures)4 UUID (java.util.UUID)4 CompletableFuture (java.util.concurrent.CompletableFuture)4 KeyValueTableManager (io.pravega.client.admin.KeyValueTableManager)3 StreamManager (io.pravega.client.admin.StreamManager)3 ConnectionFactory (io.pravega.client.connection.impl.ConnectionFactory)3 ConnectionPoolImpl (io.pravega.client.connection.impl.ConnectionPoolImpl)3 SocketConnectionFactoryImpl (io.pravega.client.connection.impl.SocketConnectionFactoryImpl)3