zk.getChildren(topicSubscribersPath, false, new SafeAsyncZKCallback.ChildrenCallback() {
@Override
public void safeProcessResult(int rc, String path, final Object ctx, final List<String> children) {
if (rc != Code.OK.intValue() && rc != Code.NONODE.intValue()) {
KeeperException e = ZkUtils.logErrorAndCreateZKException("Could not read subscribers for topic "
+ topic.toStringUtf8(), path, rc);
cb.operationFailed(ctx, new PubSubException.ServiceDownException(e));
return;
}
final Map<ByteString, InMemorySubscriptionState> topicSubs = new ConcurrentHashMap<ByteString, InMemorySubscriptionState>();
if (rc == Code.NONODE.intValue() || children.size() == 0) {
if (logger.isDebugEnabled()) {
logger.debug("No subscriptions found while acquiring topic: " + topic.toStringUtf8());
}
cb.operationFinished(ctx, topicSubs);
return;
}
final AtomicBoolean failed = new AtomicBoolean();
final AtomicInteger count = new AtomicInteger();
for (final String child : children) {
final ByteString subscriberId = ByteString.copyFromUtf8(child);
final String childPath = path + "/" + child;
zk.getData(childPath, false, new SafeAsyncZKCallback.DataCallback() {
@Override
public void safeProcessResult(int rc, String path, Object ctx, byte[] data, Stat stat) {
if (rc != Code.OK.intValue()) {
KeeperException e = ZkUtils.logErrorAndCreateZKException(
"Could not read subscription data for topic: " + topic.toStringUtf8()
+ ", subscriberId: " + subscriberId.toStringUtf8(), path, rc);
reportFailure(new PubSubException.ServiceDownException(e));
return;
}