* ����topology����Ϣ��topologyid��topologyname����������worker��������ʱ���״̬
* @return ClusterSummary
*/
@Override
public ClusterSummary getClusterInfo() throws TException {
StormClusterState stormClusterState = data.getStormClusterState();
//����ѷ���Ķ˿ںͶ˿������е�����
Map<String, Set<Integer>> assigned = NimbusUtils
.assigned_Slots(stormClusterState);
//�������supervisor����Ϣ
Map<String, SupervisorInfo> supervisorInfos = NimbusUtils
.allSupervisorInfo(stormClusterState, null);
//���supervisorSummaries
List<SupervisorSummary> supervisorSummaries = new ArrayList<SupervisorSummary>();
if (supervisorInfos == null) {
supervisorInfos = new HashMap<String, SupervisorInfo>();
}
Set<Entry<String, SupervisorInfo>> sinfoEntry = supervisorInfos.entrySet();
for (Iterator<Entry<String, SupervisorInfo>> it = sinfoEntry.iterator(); it.hasNext();) {
Entry<String, SupervisorInfo> entry = it.next();
String supervisorId = entry.getKey();
SupervisorInfo info = entry.getValue();
List<Integer> ports = info.getWorkPorts();
int num_used_workers = 0;
int num_workers = 0;
if (assigned != null && assigned.get(supervisorId) != null){
num_used_workers = assigned.get(supervisorId).size();
}
if (ports != null){
num_workers = ports.size();
}
supervisorSummaries.add(new SupervisorSummary(info.getHostName(),
info.getUptimeSecs(),num_workers , num_used_workers));
}
//���nimbus������ʱ��
int uptime = data.uptime();
//�������״̬Ϊactive��topology
Map<String, StormBase> bases = Common.topology_bases(stormClusterState);
if (bases == null) {
bases = new HashMap<String, StormBase>();
}
//������м�Ⱥ����Ϣ
List<TopologySummary> topologySummaries = new ArrayList<TopologySummary>();
Set<Entry<String, StormBase>> basesEntry = bases.entrySet();
for (Iterator<Entry<String, StormBase>> it = basesEntry.iterator(); it.hasNext();) {
Entry<String, StormBase> entry = it.next();
String stormId = entry.getKey();
StormBase base = entry.getValue();
Assignment assignment = stormClusterState.assignment_info(stormId,null);
if (assignment != null) {
HashSet<NodePort> workers = new HashSet<NodePort>();
Collection<NodePort> entryColl = assignment.getTaskToNodeport().values();
workers.addAll(entryColl);
topologySummaries.add(new TopologySummary(stormId, base.getStormName(), assignment.getTaskToNodeport().size(),