List<Cluster> clusterStatus = new ArrayList<Cluster>();
List<Stream> streamStatus = new ArrayList<Stream>();
try {
ZkClient zkClient = new ZkClient(statusArgs.zkConnectionString, statusArgs.timeout);
zkClient.setZkSerializer(new ZNRecordSerializer());
List<String> clusters = statusArgs.clusters;
if (clusters == null) {
// Load all subclusters
clusters = zkClient.getChildren("/s4/clusters");
}
Set<String> app = null;
Set<String> requiredAppCluster = new HashSet<String>();
if (statusArgs.apps != null) {
app = new HashSet<String>(statusArgs.apps);
}
for (String clusterName : clusters) {
try {
if (zkClient.exists("/s4/clusters/" + clusterName)) {
Cluster cluster = new Cluster(clusterName, zkClient);
if (app == null || app.contains(cluster.app.name)) {
clusterStatus.add(cluster);
requiredAppCluster.add(cluster.clusterName);
}
} else {
logger.error("/s4/clusters/" + clusterName + " doesn't exist");
}
} catch (Exception e) {
logger.error("Cannot get the status of " + clusterName, e);
}
}
List<String> streams = statusArgs.streams;
if (streams == null) {
// Load all streams published
streams = zkClient.getChildren("/s4/streams");
}
for (String streamName : streams) {
try {
if (zkClient.exists("/s4/streams/" + streamName)) {
Stream stream = new Stream(streamName, zkClient);
if (app == null) {
streamStatus.add(stream);
} else {
for (String cluster : requiredAppCluster) {