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);
}
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);
}
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);
}
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;
}
Aggregations