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