Search in sources :

Example 6 with KeyValueTableInfo

use of io.pravega.client.admin.KeyValueTableInfo in project pravega by pravega.

the class KeyValueTableFactoryImpl method forKeyValueTable.

@Override
public KeyValueTable forKeyValueTable(@NonNull String keyValueTableName, @NonNull KeyValueTableClientConfiguration clientConfiguration) {
    val kvt = new KeyValueTableInfo(this.scope, keyValueTableName);
    val provider = DelegationTokenProviderFactory.create(this.controller, kvt.getScope(), kvt.getKeyValueTableName(), AccessOperation.READ_WRITE);
    val tsf = new TableSegmentFactoryImpl(this.controller, this.connectionPool, clientConfiguration, provider);
    return new KeyValueTableImpl(kvt, tsf, this.controller, this.connectionPool.getInternalExecutor());
}
Also used : lombok.val(lombok.val) KeyValueTableInfo(io.pravega.client.admin.KeyValueTableInfo)

Example 7 with KeyValueTableInfo

use of io.pravega.client.admin.KeyValueTableInfo in project pravega by pravega.

the class LocalControllerTest method testListKeyValueTable.

@Test(timeout = 10000)
public void testListKeyValueTable() throws Exception {
    List<String> tablelist = new ArrayList<String>();
    tablelist.add("kvtable1");
    Pair<List<String>, String> listOfKVTables = new ImmutablePair<>(tablelist, "");
    when(this.mockControllerService.listKeyValueTables(anyString(), anyString(), anyInt(), anyLong())).thenReturn(CompletableFuture.completedFuture(listOfKVTables));
    KeyValueTableInfo info = this.testController.listKeyValueTables("scope").getNext().get();
    assertEquals("kvtable1", info.getKeyValueTableName());
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) KeyValueTableInfo(io.pravega.client.admin.KeyValueTableInfo) Test(org.junit.Test)

Example 8 with KeyValueTableInfo

use of io.pravega.client.admin.KeyValueTableInfo in project pravega by pravega.

the class DeleteScopeTask method deleteScopeContent.

public CompletableFuture<Void> deleteScopeContent(String scopeName, OperationContext context, long requestId) {
    Map<String, String> readerGroupMap = new HashMap<>();
    Iterator<Stream> iterator = listStreams(scopeName, context).asIterator();
    // Seal and delete streams and add entry to RGList
    while (iterator.hasNext()) {
        Stream stream = iterator.next();
        Timer timer = new Timer();
        if (stream.getStreamName().startsWith(READER_GROUP_STREAM_PREFIX)) {
            readerGroupMap.put(stream.getStreamName().substring(READER_GROUP_STREAM_PREFIX.length()), stream.getStreamName());
        }
        log.debug("Processing seal and delete stream for Stream {}", stream);
        Futures.getThrowingException(Futures.exceptionallyExpecting(streamMetadataTasks.sealStream(scopeName, stream.getStreamName(), requestId), e -> {
            Throwable unwrap = Exceptions.unwrap(e);
            // ignore failures if the stream doesn't exist or we are unable to seal it.
            return unwrap instanceof InvalidStreamException || unwrap instanceof ControllerFailureException;
        }, Controller.UpdateStreamStatus.Status.STREAM_NOT_FOUND).thenCompose(sealed -> {
            ControllerService.reportSealStreamMetrics(scopeName, stream.getStreamName(), sealed, timer.getElapsed());
            return CompletableFuture.completedFuture(null);
        }).thenCompose(x -> streamMetadataTasks.deleteStream(stream.getScope(), stream.getStreamName(), requestId).thenCompose(status -> {
            ControllerService.reportDeleteStreamMetrics(scopeName, stream.getStreamName(), status, timer.getElapsed());
            return CompletableFuture.completedFuture(null);
        })));
    }
    // Delete ReaderGroups
    for (Map.Entry<String, String> rgMapEntry : readerGroupMap.entrySet()) {
        log.debug("Processing delete ReaderGroup for {}", rgMapEntry.getKey());
        Timer timer = new Timer();
        Futures.getThrowingException(streamMetadataTasks.getReaderGroupConfig(scopeName, rgMapEntry.getKey(), requestId).thenCompose(conf -> streamMetadataTasks.deleteReaderGroup(scopeName, rgMapEntry.getKey(), conf.getConfig().getReaderGroupId(), requestId).thenCompose(status -> {
            ControllerService.reportDeleteReaderGroupMetrics(scopeName, rgMapEntry.getValue(), status, timer.getElapsed());
            return CompletableFuture.completedFuture(null);
        })));
    }
    // Delete KVTs
    Iterator<KeyValueTableInfo> kvtIterator = listKVTs(scopeName, requestId, context).asIterator();
    while (kvtIterator.hasNext()) {
        String kvt = kvtIterator.next().getKeyValueTableName();
        Timer timer = new Timer();
        log.debug("Processing delete kvt for {}", kvt);
        Futures.getThrowingException(kvtMetadataTasks.deleteKeyValueTable(scopeName, kvt, context.getRequestId()).thenCompose(status -> {
            ControllerService.reportDeleteKVTableMetrics(scopeName, kvt, status, timer.getElapsed());
            return CompletableFuture.completedFuture(null);
        }));
    }
    return streamMetadataStore.deleteScopeRecursive(scopeName, context, executor).thenApply(status -> {
        log.debug("Recursive Delete Scope returned with a status {}", status);
        return null;
    });
}
Also used : OperationContext(io.pravega.controller.store.stream.OperationContext) StreamImpl(io.pravega.client.stream.impl.StreamImpl) Exceptions(io.pravega.common.Exceptions) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Function(java.util.function.Function) TagLogger(io.pravega.common.tracing.TagLogger) KeyValueTableInfo(io.pravega.client.admin.KeyValueTableInfo) Stream(io.pravega.client.stream.Stream) Map(java.util.Map) ControllerFailureException(io.pravega.client.control.impl.ControllerFailureException) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) StreamMetadataTasks(io.pravega.controller.task.Stream.StreamMetadataTasks) Controller(io.pravega.controller.stream.api.grpc.v1.Controller) ControllerService(io.pravega.controller.server.ControllerService) Iterator(java.util.Iterator) Collection(java.util.Collection) DeleteScopeEvent(io.pravega.shared.controller.event.DeleteScopeEvent) AsyncIterator(io.pravega.common.util.AsyncIterator) UUID(java.util.UUID) Timer(io.pravega.common.Timer) TableMetadataTasks(io.pravega.controller.task.KeyValueTable.TableMetadataTasks) Collectors(java.util.stream.Collectors) KVTableMetadataStore(io.pravega.controller.store.kvtable.KVTableMetadataStore) READER_GROUP_STREAM_PREFIX(io.pravega.shared.NameUtils.READER_GROUP_STREAM_PREFIX) AbstractMap(java.util.AbstractMap) List(java.util.List) ContinuationTokenAsyncIterator(io.pravega.common.util.ContinuationTokenAsyncIterator) InvalidStreamException(io.pravega.client.stream.InvalidStreamException) Preconditions(com.google.common.base.Preconditions) StreamMetadataStore(io.pravega.controller.store.stream.StreamMetadataStore) Futures(io.pravega.common.concurrent.Futures) HashMap(java.util.HashMap) InvalidStreamException(io.pravega.client.stream.InvalidStreamException) KeyValueTableInfo(io.pravega.client.admin.KeyValueTableInfo) Timer(io.pravega.common.Timer) ControllerFailureException(io.pravega.client.control.impl.ControllerFailureException) Stream(io.pravega.client.stream.Stream) HashMap(java.util.HashMap) Map(java.util.Map) AbstractMap(java.util.AbstractMap)

Example 9 with KeyValueTableInfo

use of io.pravega.client.admin.KeyValueTableInfo in project pravega by pravega.

the class ControllerImpl method listKeyValueTables.

@Override
public AsyncIterator<KeyValueTableInfo> listKeyValueTables(String scopeName) {
    Exceptions.checkNotClosed(closed.get(), this);
    long traceId = LoggerHelpers.traceEnter(log, "listKeyValueTables", scopeName);
    long requestId = requestIdGenerator.get();
    try {
        final Function<ContinuationToken, CompletableFuture<Map.Entry<ContinuationToken, Collection<KeyValueTableInfo>>>> function = token -> this.retryConfig.runAsync(() -> {
            RPCAsyncCallback<KVTablesInScopeResponse> callback = new RPCAsyncCallback<>(requestId, "listKeyValueTables", scopeName);
            ScopeInfo scopeInfo = ScopeInfo.newBuilder().setScope(scopeName).build();
            new ControllerClientTagger(client, timeoutMillis).withTag(requestId, LIST_KEY_VALUE_TABLES, scopeName).listKeyValueTables(KVTablesInScopeRequest.newBuilder().setScope(scopeInfo).setContinuationToken(token).build(), callback);
            return callback.getFuture().thenApplyAsync(x -> {
                switch(x.getStatus()) {
                    case SCOPE_NOT_FOUND:
                        log.warn(requestId, "Scope not found: {}", scopeName);
                        throw new NoSuchScopeException();
                    case FAILURE:
                        log.warn(requestId, "Internal Server Error while trying to list streams in scope: {}", scopeName);
                        throw new RuntimeException("Failure while trying to list streams");
                    case SUCCESS:
                    // compatibility reasons
                    default:
                        List<KeyValueTableInfo> kvtList = x.getKvtablesList().stream().map(y -> new KeyValueTableInfo(y.getScope(), y.getKvtName())).collect(Collectors.toList());
                        return new AbstractMap.SimpleEntry<>(x.getContinuationToken(), kvtList);
                }
            }, this.executor);
        }, this.executor);
        return new ContinuationTokenAsyncIterator<>(function, ContinuationToken.newBuilder().build());
    } finally {
        LoggerHelpers.traceLeave(log, "listKeyValueTables", traceId);
    }
}
Also used : StreamCut(io.pravega.client.stream.StreamCut) StreamConfig(io.pravega.controller.stream.api.grpc.v1.Controller.StreamConfig) NegotiationType(io.grpc.netty.shaded.io.grpc.netty.NegotiationType) MoreCallCredentials(io.grpc.auth.MoreCallCredentials) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) 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) StreamSegments(io.pravega.client.stream.impl.StreamSegments) NoSuchScopeException(io.pravega.client.stream.NoSuchScopeException) TRUNCATE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.TRUNCATE_STREAM) AccessOperation(io.pravega.shared.security.auth.AccessOperation) Map(java.util.Map) SubscriberStreamCut(io.pravega.controller.stream.api.grpc.v1.Controller.SubscriberStreamCut) LIST_SCOPES(io.pravega.shared.controller.tracing.RPCTracingTags.LIST_SCOPES) 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) ReaderGroupConfig(io.pravega.client.stream.ReaderGroupConfig) 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) REMOVE_WRITER(io.pravega.shared.controller.tracing.RPCTracingTags.REMOVE_WRITER) 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) SslContextBuilder(io.grpc.netty.shaded.io.netty.handler.ssl.SslContextBuilder) RequestTracker(io.pravega.common.tracing.RequestTracker) ScopesResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ScopesResponse) SSLException(javax.net.ssl.SSLException) KVTablesInScopeRequest(io.pravega.controller.stream.api.grpc.v1.Controller.KVTablesInScopeRequest) GET_STREAM_CONFIGURATION(io.pravega.shared.controller.tracing.RPCTracingTags.GET_STREAM_CONFIGURATION) Futures(io.pravega.common.concurrent.Futures) KeyValueTableSegments(io.pravega.client.tables.impl.KeyValueTableSegments) SegmentId(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentId) StreamCutRangeResponse(io.pravega.controller.stream.api.grpc.v1.Controller.StreamCutRangeResponse) 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) GrpcSslContexts(io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts) Exceptions(io.pravega.common.Exceptions) ScopeInfo(io.pravega.controller.stream.api.grpc.v1.Controller.ScopeInfo) StreamsInScopeWithTagRequest(io.pravega.controller.stream.api.grpc.v1.Controller.StreamsInScopeWithTagRequest) ModelHelper.encode(io.pravega.client.control.impl.ModelHelper.encode) GET_KEY_VALUE_TABLE_CONFIGURATION(io.pravega.shared.controller.tracing.RPCTracingTags.GET_KEY_VALUE_TABLE_CONFIGURATION) Supplier(java.util.function.Supplier) UpdateSubscriberStatus(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateSubscriberStatus) PingFailedException(io.pravega.client.stream.PingFailedException) Strings(com.google.common.base.Strings) Code(io.grpc.Status.Code) 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) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) GET_SUCCESSORS_FROM_CUT(io.pravega.shared.controller.tracing.RPCTracingTags.GET_SUCCESSORS_FROM_CUT) ControllerServiceGrpc(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc) START_SCALE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.START_SCALE_STREAM) StreamSegmentsWithPredecessors(io.pravega.client.stream.impl.StreamSegmentsWithPredecessors) ExistsResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ExistsResponse) RemoveWriterResponse(io.pravega.controller.stream.api.grpc.v1.Controller.RemoveWriterResponse) Callbacks(io.pravega.common.function.Callbacks) AsyncIterator(io.pravega.common.util.AsyncIterator) SegmentRange(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentRange) WriterPosition(io.pravega.client.stream.impl.WriterPosition) File(java.io.File) StatusRuntimeException(io.grpc.StatusRuntimeException) CREATE_TRANSACTION(io.pravega.shared.controller.tracing.RPCTracingTags.CREATE_TRANSACTION) RPCTracingHelpers(io.pravega.shared.controller.tracing.RPCTracingHelpers) LIST_STREAMS_IN_SCOPE_FOR_TAG(io.pravega.shared.controller.tracing.RPCTracingTags.LIST_STREAMS_IN_SCOPE_FOR_TAG) TreeMap(java.util.TreeMap) TxnStatus(io.pravega.controller.stream.api.grpc.v1.Controller.TxnStatus) Preconditions(com.google.common.base.Preconditions) DeleteReaderGroupStatus(io.pravega.controller.stream.api.grpc.v1.Controller.DeleteReaderGroupStatus) SegmentsAtTime(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentsAtTime) TxnFailedException(io.pravega.client.stream.TxnFailedException) 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) ManagedChannel(io.grpc.ManagedChannel) Retry(io.pravega.common.util.Retry) LoggerFactory(org.slf4j.LoggerFactory) KeyValueTableConfiguration(io.pravega.client.tables.KeyValueTableConfiguration) ReaderGroupNotFoundException(io.pravega.client.stream.ReaderGroupNotFoundException) StreamsInScopeResponse(io.pravega.controller.stream.api.grpc.v1.Controller.StreamsInScopeResponse) ContinuationToken(io.pravega.controller.stream.api.grpc.v1.Controller.ContinuationToken) GetSegmentsRequest(io.pravega.controller.stream.api.grpc.v1.Controller.GetSegmentsRequest) StreamObserver(io.grpc.stub.StreamObserver) TagLogger(io.pravega.common.tracing.TagLogger) ControllerServiceStub(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceStub) CREATE_KEY_VALUE_TABLE(io.pravega.shared.controller.tracing.RPCTracingTags.CREATE_KEY_VALUE_TABLE) KeyValueTableInfo(io.pravega.client.admin.KeyValueTableInfo) Stream(io.pravega.client.stream.Stream) KVTablesInScopeResponse(io.pravega.controller.stream.api.grpc.v1.Controller.KVTablesInScopeResponse) PravegaNodeUri(io.pravega.shared.protocol.netty.PravegaNodeUri) SubscribersResponse(io.pravega.controller.stream.api.grpc.v1.Controller.SubscribersResponse) Transaction(io.pravega.client.stream.Transaction) DELETE_KEY_VALUE_TABLE(io.pravega.shared.controller.tracing.RPCTracingTags.DELETE_KEY_VALUE_TABLE) TxnSegments(io.pravega.client.stream.impl.TxnSegments) RetryAndThrowConditionally(io.pravega.common.util.Retry.RetryAndThrowConditionally) 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) CHECK_STREAM_EXISTS(io.pravega.shared.controller.tracing.RPCTracingTags.CHECK_STREAM_EXISTS) CREATE_SCOPE(io.pravega.shared.controller.tracing.RPCTracingTags.CREATE_SCOPE) Collection(java.util.Collection) 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) NavigableMap(java.util.NavigableMap) 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) SegmentWithRange(io.pravega.client.stream.impl.SegmentWithRange) List(java.util.List) ABORT_TRANSACTION(io.pravega.shared.controller.tracing.RPCTracingTags.ABORT_TRANSACTION) CreateTxnResponse(io.pravega.controller.stream.api.grpc.v1.Controller.CreateTxnResponse) GET_URI(io.pravega.shared.controller.tracing.RPCTracingTags.GET_URI) GetEpochSegmentsRequest(io.pravega.controller.stream.api.grpc.v1.Controller.GetEpochSegmentsRequest) DELETE_READER_GROUP(io.pravega.shared.controller.tracing.RPCTracingTags.DELETE_READER_GROUP) TimestampFromWriter(io.pravega.controller.stream.api.grpc.v1.Controller.TimestampFromWriter) 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) Segment(io.pravega.client.segment.impl.Segment) CreateScopeStatus(io.pravega.controller.stream.api.grpc.v1.Controller.CreateScopeStatus) StreamImpl(io.pravega.client.stream.impl.StreamImpl) ScaleStatusRequest(io.pravega.controller.stream.api.grpc.v1.Controller.ScaleStatusRequest) KeyValueTableConfigResponse(io.pravega.controller.stream.api.grpc.v1.Controller.KeyValueTableConfigResponse) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) 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) HashMap(java.util.HashMap) 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) ScopesRequest(io.pravega.controller.stream.api.grpc.v1.Controller.ScopesRequest) 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) NettyChannelBuilder(io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder) 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) SCALE_STREAM(io.pravega.shared.controller.tracing.RPCTracingTags.SCALE_STREAM) LoggerHelpers(io.pravega.common.LoggerHelpers) UpdateReaderGroupResponse(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateReaderGroupResponse) NameUtils(io.pravega.shared.NameUtils) TimestampResponse(io.pravega.controller.stream.api.grpc.v1.Controller.TimestampResponse) StreamsInScopeRequest(io.pravega.controller.stream.api.grpc.v1.Controller.StreamsInScopeRequest) RemoveWriterRequest(io.pravega.controller.stream.api.grpc.v1.Controller.RemoveWriterRequest) GET_READER_GROUP_CONFIG(io.pravega.shared.controller.tracing.RPCTracingTags.GET_READER_GROUP_CONFIG) StreamSegmentSuccessors(io.pravega.client.stream.impl.StreamSegmentSuccessors) TimeUnit(java.util.concurrent.TimeUnit) ManagedChannelBuilder(io.grpc.ManagedChannelBuilder) AbstractMap(java.util.AbstractMap) UpdateStreamStatus(io.pravega.controller.stream.api.grpc.v1.Controller.UpdateStreamStatus) ContinuationTokenAsyncIterator(io.pravega.common.util.ContinuationTokenAsyncIterator) InvalidStreamException(io.pravega.client.stream.InvalidStreamException) Credentials(io.pravega.shared.security.auth.Credentials) VisibleForTesting(com.google.common.annotations.VisibleForTesting) RandomFactory(io.pravega.common.hash.RandomFactory) TxnRequest(io.pravega.controller.stream.api.grpc.v1.Controller.TxnRequest) ReaderGroupConfigResponse(io.pravega.controller.stream.api.grpc.v1.Controller.ReaderGroupConfigResponse) SegmentValidityResponse(io.pravega.controller.stream.api.grpc.v1.Controller.SegmentValidityResponse) Collections(java.util.Collections) ContinuationToken(io.pravega.controller.stream.api.grpc.v1.Controller.ContinuationToken) ScopeInfo(io.pravega.controller.stream.api.grpc.v1.Controller.ScopeInfo) NoSuchScopeException(io.pravega.client.stream.NoSuchScopeException) KeyValueTableInfo(io.pravega.client.admin.KeyValueTableInfo) KVTablesInScopeResponse(io.pravega.controller.stream.api.grpc.v1.Controller.KVTablesInScopeResponse) CompletableFuture(java.util.concurrent.CompletableFuture) StatusRuntimeException(io.grpc.StatusRuntimeException) ContinuationTokenAsyncIterator(io.pravega.common.util.ContinuationTokenAsyncIterator) Collection(java.util.Collection) Map(java.util.Map) TreeMap(java.util.TreeMap) NavigableMap(java.util.NavigableMap) HashMap(java.util.HashMap) AbstractMap(java.util.AbstractMap)

Example 10 with KeyValueTableInfo

use of io.pravega.client.admin.KeyValueTableInfo in project pravega by pravega.

the class MockStreamManager method deleteScope.

/**
 * A new API is created hence this is going to be deprecated.
 *
 * @deprecated As of Pravega release 0.11, replaced by {@link #deleteScopeRecursive(String)}.
 */
@Override
@Deprecated
public boolean deleteScope(String scopeName, boolean forceDelete) {
    if (forceDelete) {
        List<String> readerGroupList = new ArrayList<>();
        Iterator<Stream> iterator = controller.listStreams(scopeName).asIterator();
        while (iterator.hasNext()) {
            Stream stream = iterator.next();
            if (stream.getStreamName().startsWith(READER_GROUP_STREAM_PREFIX)) {
                readerGroupList.add(stream.getStreamName().substring(READER_GROUP_STREAM_PREFIX.length()));
            }
            Futures.getAndHandleExceptions(controller.sealStream(scope, stream.getStreamName()), RuntimeException::new);
            Futures.getAndHandleExceptions(controller.deleteStream(scope, stream.getStreamName()), RuntimeException::new);
        }
        Iterator<KeyValueTableInfo> kvtIterator = controller.listKeyValueTables(scopeName).asIterator();
        while (iterator.hasNext()) {
            KeyValueTableInfo kvt = kvtIterator.next();
            Futures.getAndHandleExceptions(controller.deleteKeyValueTable(scopeName, kvt.getKeyValueTableName()), RuntimeException::new);
        }
        for (String rg : readerGroupList) {
            ReaderGroupConfig rgc = getAndHandleExceptions(controller.getReaderGroupConfig(scopeName, rg), RuntimeException::new);
            Futures.getAndHandleExceptions(controller.deleteReaderGroup(scopeName, rg, rgc.getReaderGroupId()), RuntimeException::new);
        }
    }
    return Futures.getAndHandleExceptions(controller.deleteScope(scope), RuntimeException::new);
}
Also used : ReaderGroupConfig(io.pravega.client.stream.ReaderGroupConfig) ArrayList(java.util.ArrayList) Stream(io.pravega.client.stream.Stream) KeyValueTableInfo(io.pravega.client.admin.KeyValueTableInfo)

Aggregations

KeyValueTableInfo (io.pravega.client.admin.KeyValueTableInfo)10 Stream (io.pravega.client.stream.Stream)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 InvalidStreamException (io.pravega.client.stream.InvalidStreamException)4 Exceptions (io.pravega.common.Exceptions)4 Futures (io.pravega.common.concurrent.Futures)4 AsyncIterator (io.pravega.common.util.AsyncIterator)4 HashMap (java.util.HashMap)4 CompletableFuture (java.util.concurrent.CompletableFuture)4 Test (org.junit.Test)4 Preconditions (com.google.common.base.Preconditions)3 ControllerFailureException (io.pravega.client.control.impl.ControllerFailureException)3 Cleanup (lombok.Cleanup)3 lombok.val (lombok.val)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 ClientConfig (io.pravega.client.ClientConfig)2 StreamInfo (io.pravega.client.admin.StreamInfo)2 StreamManager (io.pravega.client.admin.StreamManager)2 ConnectionPoolImpl (io.pravega.client.connection.impl.ConnectionPoolImpl)2