@Override public void asyncUpdateLedgerIds(String ledgerName, ManagedLedgerInfo mlInfo, Stat stat, final MetaStoreCallback<Void> callback) { ZKStat zkStat = (ZKStat) stat; if (log.isDebugEnabled()) { log.debug("[{}] Updating metadata version={} with content={}", ledgerName, zkStat.version, mlInfo); } byte[] serializedMlInfo = mlInfo.toByteArray(); // Binary format zk.setData(prefix + ledgerName, serializedMlInfo, zkStat.getVersion(), (rc, path, zkCtx, stat1) -> executor.executeOrdered(ledgerName, safeRun(() -> { if (log.isDebugEnabled()) { log.debug("[{}] UpdateLedgersIdsCallback.processResult rc={} newVersion={}", ledgerName, Code.get(rc), stat != null ? stat.getVersion() : "null"); } MetaStoreException status = null; if (rc == Code.BADVERSION.intValue()) { // Content has been modified on ZK since our last read status = new BadVersionException(KeeperException.create(Code.get(rc))); callback.operationFailed(status); } else if (rc != Code.OK.intValue()) { status = new MetaStoreException(KeeperException.create(Code.get(rc))); callback.operationFailed(status); } else { callback.operationComplete(null, new ZKStat(stat1)); } })), null); }
@Override public void asyncUpdateLedgerIds(String ledgerName, ManagedLedgerInfo mlInfo, Stat stat, final MetaStoreCallback<Void> callback) { ZKStat zkStat = (ZKStat) stat; if (log.isDebugEnabled()) { log.debug("[{}] Updating metadata version={} with content={}", ledgerName, zkStat.version, mlInfo); } byte[] serializedMlInfo = protobufFormat == ZNodeProtobufFormat.Text ? // mlInfo.toString().getBytes(Encoding) : // Text format mlInfo.toByteArray(); // Binary format zk.setData(prefix + ledgerName, serializedMlInfo, zkStat.getVersion(), (rc, path, zkCtx, stat1) -> executor.submit(safeRun(() -> { if (log.isDebugEnabled()) { log.debug("[{}] UpdateLedgersIdsCallback.processResult rc={} newVersion={}", ledgerName, Code.get(rc), stat != null ? stat.getVersion() : "null"); } MetaStoreException status = null; if (rc == Code.BADVERSION.intValue()) { // Content has been modified on ZK since our last read status = new BadVersionException(KeeperException.create(Code.get(rc))); callback.operationFailed(status); } else if (rc != Code.OK.intValue()) { status = new MetaStoreException(KeeperException.create(Code.get(rc))); callback.operationFailed(status); } else { callback.operationComplete(null, new ZKStat(stat1)); } })), null); }
@Override public void asyncUpdateLedgerIds(String ledgerName, ManagedLedgerInfo mlInfo, Stat stat, final MetaStoreCallback<Void> callback) { ZKStat zkStat = (ZKStat) stat; if (log.isDebugEnabled()) { log.debug("[{}] Updating metadata version={} with content={}", ledgerName, zkStat.version, mlInfo); } byte[] serializedMlInfo = mlInfo.toByteArray(); // Binary format zk.setData(prefix + ledgerName, serializedMlInfo, zkStat.getVersion(), (rc, path, zkCtx, stat1) -> executor.executeOrdered(ledgerName, safeRun(() -> { if (log.isDebugEnabled()) { log.debug("[{}] UpdateLedgersIdsCallback.processResult rc={} newVersion={}", ledgerName, Code.get(rc), stat != null ? stat.getVersion() : "null"); } MetaStoreException status = null; if (rc == Code.BADVERSION.intValue()) { // Content has been modified on ZK since our last read status = new BadVersionException(KeeperException.create(Code.get(rc))); callback.operationFailed(status); } else if (rc != Code.OK.intValue()) { status = new MetaStoreException(KeeperException.create(Code.get(rc))); callback.operationFailed(status); } else { callback.operationComplete(null, new ZKStat(stat1)); } })), null); }