use of com.twitter.distributedlog.impl.metadata.ZKLogMetadataForWriter in project distributedlog by twitter.
the class BKDistributedLogManager method asyncCreateWriteHandler.
Future<BKLogWriteHandler> asyncCreateWriteHandler(final boolean lockHandler) {
final ZooKeeper zk;
try {
zk = writerZKC.get();
} catch (InterruptedException e) {
LOG.error("Failed to initialize zookeeper client : ", e);
return Future.exception(new DLInterruptedException("Failed to initialize zookeeper client", e));
} catch (ZooKeeperClient.ZooKeeperConnectionException e) {
return Future.exception(FutureUtils.zkException(e, uri.getPath()));
}
boolean ownAllocator = null == ledgerAllocator;
// Fetching Log Metadata
Future<ZKLogMetadataForWriter> metadataFuture = ZKLogMetadataForWriter.of(uri, name, streamIdentifier, zk, writerZKC.getDefaultACL(), ownAllocator, conf.getCreateStreamIfNotExists() || ownAllocator);
return metadataFuture.flatMap(new AbstractFunction1<ZKLogMetadataForWriter, Future<BKLogWriteHandler>>() {
@Override
public Future<BKLogWriteHandler> apply(ZKLogMetadataForWriter logMetadata) {
Promise<BKLogWriteHandler> createPromise = new Promise<BKLogWriteHandler>();
createWriteHandler(logMetadata, lockHandler, createPromise);
return createPromise;
}
});
}
Aggregations