Search in sources :

Example 6 with BookKeeperConfig

use of io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperConfig in project pravega by pravega.

the class S3IntegrationTest method createBuilder.

// endregion
// region StreamSegmentStoreTestBase Implementation
@Override
protected ServiceBuilder createBuilder(ServiceBuilderConfig.Builder configBuilder, int instanceId, boolean useChunkedSegmentStorage) {
    Preconditions.checkState(useChunkedSegmentStorage);
    ServiceBuilderConfig builderConfig = getBuilderConfig(configBuilder, instanceId);
    return ServiceBuilder.newInMemoryBuilder(builderConfig).withStorageFactory(setup -> new LocalS3SimpleStorageFactory(setup.getConfig(S3StorageConfig::builder), setup.getStorageExecutor())).withDataLogFactory(setup -> new BookKeeperLogFactory(setup.getConfig(BookKeeperConfig::builder), getBookkeeper().getZkClient(), setup.getCoreExecutor()));
}
Also used : S3Mock(io.pravega.storage.s3.S3Mock) Storage(io.pravega.segmentstore.storage.Storage) Getter(lombok.Getter) UUID(java.util.UUID) ChunkedSegmentStorageConfig(io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorageConfig) S3StorageConfig(io.pravega.storage.s3.S3StorageConfig) ServiceBuilderConfig(io.pravega.segmentstore.server.store.ServiceBuilderConfig) BookKeeperConfig(io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperConfig) S3ChunkStorage(io.pravega.storage.s3.S3ChunkStorage) SimpleStorageFactory(io.pravega.segmentstore.storage.SimpleStorageFactory) ServiceBuilder(io.pravega.segmentstore.server.store.ServiceBuilder) S3ClientMock(io.pravega.storage.s3.S3ClientMock) ChunkMetadataStore(io.pravega.segmentstore.storage.metadata.ChunkMetadataStore) After(org.junit.After) Duration(java.time.Duration) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Preconditions(com.google.common.base.Preconditions) URI(java.net.URI) BookKeeperLogFactory(io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperLogFactory) ChunkedSegmentStorage(io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorage) Before(org.junit.Before) BookKeeperConfig(io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperConfig) ServiceBuilderConfig(io.pravega.segmentstore.server.store.ServiceBuilderConfig) BookKeeperLogFactory(io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperLogFactory)

Example 7 with BookKeeperConfig

use of io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperConfig in project pravega by pravega.

the class DurableLogRecoveryCommand method execute.

@Override
public void execute() throws Exception {
    @Cleanup Storage storage = this.storageFactory.createStorageAdapter();
    @Cleanup val zkClient = createZKClient();
    val bkConfig = getCommandArgs().getState().getConfigBuilder().include(BookKeeperConfig.builder().with(BookKeeperConfig.ZK_ADDRESS, getServiceConfig().getZkURL())).build().getConfig(BookKeeperConfig::builder);
    @Cleanup val dataLogFactory = new BookKeeperLogFactory(bkConfig, zkClient, executorService);
    output("Container Count = %d", this.containerCount);
    dataLogFactory.initialize();
    output("Started ZK Client at %s.", getServiceConfig().getZkURL());
    storage.initialize(CONTAINER_EPOCH);
    output("Loaded %s Storage.", getServiceConfig().getStorageImplementation());
    output("Starting recovery...");
    // create back up of metadata segments
    Map<Integer, String> backUpMetadataSegments = ContainerRecoveryUtils.createBackUpMetadataSegments(storage, this.containerCount, executorService, TIMEOUT).get(TIMEOUT.toMillis(), TimeUnit.MILLISECONDS);
    @Cleanup Context context = createContext(executorService);
    // create debug segment container instances using new new dataLog and old storage.
    Map<Integer, DebugStreamSegmentContainer> debugStreamSegmentContainerMap = startDebugSegmentContainers(context, dataLogFactory);
    output("Containers started. Recovering all segments...");
    ContainerRecoveryUtils.recoverAllSegments(storage, debugStreamSegmentContainerMap, executorService, TIMEOUT);
    output("All segments recovered.");
    // Update core attributes from the backUp Metadata segments
    output("Updating core attributes for segments registered.");
    ContainerRecoveryUtils.updateCoreAttributes(backUpMetadataSegments, debugStreamSegmentContainerMap, executorService, TIMEOUT);
    // Flush new metadata segment to the storage
    flushToStorage(debugStreamSegmentContainerMap);
    // Waits for metadata segments to be flushed to LTS and then stops the debug segment containers
    stopDebugSegmentContainers(debugStreamSegmentContainerMap);
    output("Segments have been recovered.");
    output("Recovery Done!");
}
Also used : lombok.val(lombok.val) Storage(io.pravega.segmentstore.storage.Storage) CacheStorage(io.pravega.segmentstore.storage.cache.CacheStorage) BookKeeperConfig(io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperConfig) DebugStreamSegmentContainer(io.pravega.segmentstore.server.containers.DebugStreamSegmentContainer) Cleanup(lombok.Cleanup) BookKeeperLogFactory(io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperLogFactory)

Example 8 with BookKeeperConfig

use of io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperConfig in project pravega by pravega.

the class BookKeeperCommand method createContext.

/**
 * Creates a new Context to be used by the BookKeeper command.
 *
 * @return A new Context.
 * @throws DurableDataLogException If the BookKeeperLogFactory could not be initialized.
 */
@VisibleForTesting
public Context createContext() throws DurableDataLogException {
    val serviceConfig = getServiceConfig();
    val bkConfig = getCommandArgs().getState().getConfigBuilder().include(BookKeeperConfig.builder().with(BookKeeperConfig.ZK_ADDRESS, serviceConfig.getZkURL())).build().getConfig(BookKeeperConfig::builder);
    val zkClient = createZKClient();
    val factory = new BookKeeperLogFactory(bkConfig, zkClient, getCommandArgs().getState().getExecutor());
    try {
        factory.initialize();
    } catch (DurableDataLogException ex) {
        zkClient.close();
        throw ex;
    }
    val bkAdmin = new BookKeeperAdmin((BookKeeper) factory.getBookKeeperClient());
    return new Context(serviceConfig, bkConfig, zkClient, factory, bkAdmin);
}
Also used : lombok.val(lombok.val) DurableDataLogException(io.pravega.segmentstore.storage.DurableDataLogException) BookKeeperConfig(io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperConfig) BookKeeperLogFactory(io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperLogFactory) BookKeeperAdmin(org.apache.bookkeeper.client.BookKeeperAdmin) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 9 with BookKeeperConfig

use of io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperConfig in project pravega by pravega.

the class SegmentStoreAdapter method attachDataLogFactory.

private ServiceBuilder attachDataLogFactory(ServiceBuilder builder) {
    if (this.config.getBookieCount() > 0) {
        // We were instructed to start at least one Bookie.
        this.zkClient = CuratorFrameworkFactory.builder().connectString("localhost:" + this.config.getZkPort()).namespace("pravega").retryPolicy(new ExponentialBackoffRetry(1000, 5)).sessionTimeoutMs(5000).connectionTimeoutMs(5000).build();
        this.zkClient.start();
        return builder.withDataLogFactory(setup -> {
            BookKeeperConfig bkConfig = setup.getConfig(BookKeeperConfig::builder);
            return new BookKeeperLogFactory(bkConfig, this.zkClient, setup.getCoreExecutor());
        });
    } else {
        // No Bookies -> InMemory Tier1.
        return builder.withDataLogFactory(setup -> new InMemoryDurableDataLogFactory(setup.getCoreExecutor()));
    }
}
Also used : BookKeeperConfig(io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperConfig) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) InMemoryDurableDataLogFactory(io.pravega.segmentstore.storage.mocks.InMemoryDurableDataLogFactory) BookKeeperLogFactory(io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperLogFactory)

Aggregations

BookKeeperConfig (io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperConfig)9 BookKeeperLogFactory (io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperLogFactory)9 lombok.val (lombok.val)6 DurableDataLogException (io.pravega.segmentstore.storage.DurableDataLogException)5 BookKeeperAdmin (org.apache.bookkeeper.client.BookKeeperAdmin)4 Cleanup (lombok.Cleanup)3 ContainerConfig (io.pravega.segmentstore.server.containers.ContainerConfig)2 DurableDataLog (io.pravega.segmentstore.storage.DurableDataLog)2 Storage (io.pravega.segmentstore.storage.Storage)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions (com.google.common.base.Preconditions)1 DebugStreamSegmentContainer (io.pravega.segmentstore.server.containers.DebugStreamSegmentContainer)1 ServiceBuilder (io.pravega.segmentstore.server.store.ServiceBuilder)1 ServiceBuilderConfig (io.pravega.segmentstore.server.store.ServiceBuilderConfig)1 DataLogInitializationException (io.pravega.segmentstore.storage.DataLogInitializationException)1 DebugDurableDataLogWrapper (io.pravega.segmentstore.storage.DebugDurableDataLogWrapper)1 DurableDataLogFactory (io.pravega.segmentstore.storage.DurableDataLogFactory)1 SimpleStorageFactory (io.pravega.segmentstore.storage.SimpleStorageFactory)1 CacheStorage (io.pravega.segmentstore.storage.cache.CacheStorage)1