Search in sources :

Example 1 with ContainerConfig

use of io.pravega.segmentstore.server.containers.ContainerConfig in project pravega by pravega.

the class ContainerCommand 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.
 */
@Override
public Context createContext() throws DurableDataLogException {
    val serviceConfig = getServiceConfig();
    val containerConfig = getCommandArgs().getState().getConfigBuilder().build().getConfig(ContainerConfig::builder);
    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, containerConfig, bkConfig, zkClient, factory, bkAdmin);
}
Also used : lombok.val(lombok.val) ContainerConfig(io.pravega.segmentstore.server.containers.ContainerConfig) 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)

Example 2 with ContainerConfig

use of io.pravega.segmentstore.server.containers.ContainerConfig in project pravega by pravega.

the class ServiceBuilder method createSegmentContainerFactory.

protected SegmentContainerFactory createSegmentContainerFactory() {
    ReadIndexFactory readIndexFactory = getSingleton(this.readIndexFactory, this::createReadIndexFactory);
    AttributeIndexFactory attributeIndexFactory = getSingleton(this.attributeIndexFactory, this::createAttributeIndexFactory);
    StorageFactory storageFactory = createStorageFactory();
    OperationLogFactory operationLogFactory = getSingleton(this.operationLogFactory, this::createOperationLogFactory);
    WriterFactory writerFactory = getSingleton(this.writerFactory, this::createWriterFactory);
    ContainerConfig containerConfig = this.serviceBuilderConfig.getConfig(ContainerConfig::builder);
    return new StreamSegmentContainerFactory(containerConfig, operationLogFactory, readIndexFactory, attributeIndexFactory, writerFactory, storageFactory, this::createContainerExtensions, this.coreExecutor);
}
Also used : ContainerConfig(io.pravega.segmentstore.server.containers.ContainerConfig) ReadIndexFactory(io.pravega.segmentstore.server.ReadIndexFactory) ContainerReadIndexFactory(io.pravega.segmentstore.server.reading.ContainerReadIndexFactory) InMemoryStorageFactory(io.pravega.segmentstore.storage.mocks.InMemoryStorageFactory) StorageFactory(io.pravega.segmentstore.storage.StorageFactory) StreamSegmentContainerFactory(io.pravega.segmentstore.server.containers.StreamSegmentContainerFactory) StorageWriterFactory(io.pravega.segmentstore.server.writer.StorageWriterFactory) WriterFactory(io.pravega.segmentstore.server.WriterFactory) AttributeIndexFactory(io.pravega.segmentstore.server.attributes.AttributeIndexFactory) OperationLogFactory(io.pravega.segmentstore.server.OperationLogFactory)

Example 3 with ContainerConfig

use of io.pravega.segmentstore.server.containers.ContainerConfig in project pravega by pravega.

the class ContainerCommand 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.
 */
@Override
protected Context createContext() throws DurableDataLogException {
    val serviceConfig = getServiceConfig();
    val containerConfig = getCommandArgs().getState().getConfigBuilder().build().getConfig(ContainerConfig::builder);
    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(factory.getBookKeeperClient());
    return new Context(serviceConfig, containerConfig, bkConfig, zkClient, factory, bkAdmin);
}
Also used : lombok.val(lombok.val) ContainerConfig(io.pravega.segmentstore.server.containers.ContainerConfig) 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)

Example 4 with ContainerConfig

use of io.pravega.segmentstore.server.containers.ContainerConfig in project pravega by pravega.

the class DurableDataLogRepairCommand method readDurableDataLogWithCustomCallback.

/**
 * Reads a {@link DurableDataLog} associated with a container id and runs the callback on each {@link Operation}
 * read from the log.
 *
 * @param callback Callback to be run upon each {@link Operation} read.
 * @param containerId Container id to read from.
 * @param durableDataLog {@link DurableDataLog} of the Container to be read.
 * @return Number of {@link Operation}s read.
 * @throws Exception If there is a problem reading the {@link DurableDataLog}.
 */
@VisibleForTesting
int readDurableDataLogWithCustomCallback(BiConsumer<Operation, List<DataFrameRecord.EntryInfo>> callback, int containerId, DurableDataLog durableDataLog) throws Exception {
    val logReaderCallbacks = new DebugRecoveryProcessor.OperationCallbacks(callback, // We are not interested on doing actual recovery, just reading the operations.
    op -> false, null, null);
    val containerConfig = getCommandArgs().getState().getConfigBuilder().build().getConfig(ContainerConfig::builder);
    val readIndexConfig = getCommandArgs().getState().getConfigBuilder().build().getConfig(ReadIndexConfig::builder);
    @Cleanup val rp = DebugRecoveryProcessor.create(containerId, durableDataLog, containerConfig, readIndexConfig, getCommandArgs().getState().getExecutor(), logReaderCallbacks);
    int operationsRead = rp.performRecovery();
    output("Number of operations read from DurableLog: " + operationsRead);
    return operationsRead;
}
Also used : lombok.val(lombok.val) ContainerConfig(io.pravega.segmentstore.server.containers.ContainerConfig) ReadIndexConfig(io.pravega.segmentstore.server.reading.ReadIndexConfig) Cleanup(lombok.Cleanup) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

ContainerConfig (io.pravega.segmentstore.server.containers.ContainerConfig)4 lombok.val (lombok.val)3 DurableDataLogException (io.pravega.segmentstore.storage.DurableDataLogException)2 BookKeeperConfig (io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperConfig)2 BookKeeperLogFactory (io.pravega.segmentstore.storage.impl.bookkeeper.BookKeeperLogFactory)2 BookKeeperAdmin (org.apache.bookkeeper.client.BookKeeperAdmin)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 OperationLogFactory (io.pravega.segmentstore.server.OperationLogFactory)1 ReadIndexFactory (io.pravega.segmentstore.server.ReadIndexFactory)1 WriterFactory (io.pravega.segmentstore.server.WriterFactory)1 AttributeIndexFactory (io.pravega.segmentstore.server.attributes.AttributeIndexFactory)1 StreamSegmentContainerFactory (io.pravega.segmentstore.server.containers.StreamSegmentContainerFactory)1 ContainerReadIndexFactory (io.pravega.segmentstore.server.reading.ContainerReadIndexFactory)1 ReadIndexConfig (io.pravega.segmentstore.server.reading.ReadIndexConfig)1 StorageWriterFactory (io.pravega.segmentstore.server.writer.StorageWriterFactory)1 StorageFactory (io.pravega.segmentstore.storage.StorageFactory)1 InMemoryStorageFactory (io.pravega.segmentstore.storage.mocks.InMemoryStorageFactory)1 Cleanup (lombok.Cleanup)1