}
@Override
public void createLedger(final LedgerMetadata metadata, final GenericCallback<Long> ledgerCb) {
ZkUtils.createFullPathOptimistic(zk, idGenPath, new byte[0], Ids.OPEN_ACL_UNSAFE,
CreateMode.EPHEMERAL_SEQUENTIAL, new StringCallback() {
@Override
public void processResult(int rc, String path, Object ctx, final String idPathName) {
if (rc != KeeperException.Code.OK.intValue()) {
LOG.error("Could not generate new ledger id",
KeeperException.create(KeeperException.Code.get(rc), path));
ledgerCb.operationComplete(rc, null);
return;
}
/*
* Extract ledger id from gen path
*/
long ledgerId;
try {
ledgerId = getLedgerIdFromGenPath(idPathName);
} catch (IOException e) {
LOG.error("Could not extract ledger-id from id gen path:" + path, e);
ledgerCb.operationComplete(KeeperException.Code.SYSTEMERROR.intValue(), null);
return;
}
String ledgerPath = getLedgerPath(ledgerId);
final long lid = ledgerId;
StringCallback scb = new StringCallback() {
@Override
public void processResult(int rc, String path,
Object ctx, String name) {
if (rc != KeeperException.Code.OK.intValue()) {
LOG.error("Could not create node for ledger",