Search in sources :

Example 6 with ObjectClosedException

use of org.apache.bookkeeper.common.exceptions.ObjectClosedException in project bookkeeper by apache.

the class MVCCStoreFactoryImpl method newStore.

CompletableFuture<MVCCAsyncStore<byte[], byte[]>> newStore(long scId, long streamId, long rangeId) {
    synchronized (this) {
        if (closed) {
            return FutureUtils.exception(new ObjectClosedException("MVCCStoreFactory"));
        }
    }
    MVCCAsyncStore<byte[], byte[]> store = storeSupplier.get();
    File targetDir = chooseLocalStoreDir(streamId);
    // used for store ranges
    Path rangeStorePath = Paths.get(targetDir.getAbsolutePath(), "ranges", normalizedName(scId), normalizedName(streamId), normalizedName(rangeId));
    String storeName = String.format("%s/%s/%s", normalizedName(scId), normalizedName(streamId), normalizedName(rangeId));
    // build a spec
    StateStoreSpec spec = StateStoreSpec.builder().name(storeName).keyCoder(ByteArrayCoder.of()).valCoder(ByteArrayCoder.of()).localStateStoreDir(rangeStorePath.toFile()).stream(streamName(scId, streamId, rangeId)).writeIOScheduler(chooseWriteIOExecutor(streamId)).readIOScheduler(chooseReadIOExecutor(streamId)).checkpointStore(checkpointStore).checkpointDuration(Duration.ofMinutes(15)).checkpointIOScheduler(chooseCheckpointIOExecutor(streamId)).isReadonly(serveReadOnlyTable).build();
    return store.init(spec).thenApply(ignored -> {
        addStore(scId, streamId, rangeId, store);
        return store;
    });
}
Also used : Path(java.nio.file.Path) ObjectClosedException(org.apache.bookkeeper.common.exceptions.ObjectClosedException) StateStoreSpec(org.apache.bookkeeper.statelib.api.StateStoreSpec) File(java.io.File)

Aggregations

ObjectClosedException (org.apache.bookkeeper.common.exceptions.ObjectClosedException)6 StorageServerChannel (org.apache.bookkeeper.clients.impl.channel.StorageServerChannel)2 OneStorageContainerEndpointResponse (org.apache.bookkeeper.stream.proto.storage.OneStorageContainerEndpointResponse)2 StorageContainer (org.apache.bookkeeper.stream.storage.api.sc.StorageContainer)2 Test (org.junit.Test)2 File (java.io.File)1 Path (java.nio.file.Path)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 StorageContainerException (org.apache.bookkeeper.clients.exceptions.StorageContainerException)1 StateStoreSpec (org.apache.bookkeeper.statelib.api.StateStoreSpec)1 Endpoint (org.apache.bookkeeper.stream.proto.common.Endpoint)1 StorageContainerEndpoint (org.apache.bookkeeper.stream.proto.storage.StorageContainerEndpoint)1 StorageContainerFactory (org.apache.bookkeeper.stream.storage.api.sc.StorageContainerFactory)1 StorageException (org.apache.bookkeeper.stream.storage.exceptions.StorageException)1 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)1