Search in sources :

Example 1 with NimbusStat

use of backtype.storm.generated.NimbusStat in project jstorm by alibaba.

the class NimbusUtils method getNimbusSummary.

public static NimbusSummary getNimbusSummary(StormClusterState stormClusterState, List<SupervisorSummary> supervisorSummaries, NimbusData data) throws Exception {
    NimbusSummary ret = new NimbusSummary();
    String master = stormClusterState.get_leader_host();
    NimbusStat nimbusMaster = new NimbusStat();
    nimbusMaster.set_host(master);
    nimbusMaster.set_uptimeSecs(String.valueOf(data.uptime()));
    ret.set_nimbusMaster(nimbusMaster);
    List<NimbusStat> nimbusSlaveList = new ArrayList<NimbusStat>();
    ret.set_nimbusSlaves(nimbusSlaveList);
    Map<String, String> nimbusSlaveMap = Cluster.get_all_nimbus_slave(stormClusterState);
    if (nimbusSlaveMap != null) {
        for (Entry<String, String> entry : nimbusSlaveMap.entrySet()) {
            NimbusStat slave = new NimbusStat();
            slave.set_host(entry.getKey());
            slave.set_uptimeSecs(entry.getValue());
            nimbusSlaveList.add(slave);
        }
    }
    int totalPort = 0;
    int usedPort = 0;
    for (SupervisorSummary supervisor : supervisorSummaries) {
        totalPort += supervisor.get_numWorkers();
        usedPort += supervisor.get_numUsedWorkers();
    }
    ret.set_supervisorNum(supervisorSummaries.size());
    ret.set_totalPortNum(totalPort);
    ret.set_usedPortNum(usedPort);
    ret.set_freePortNum(totalPort - usedPort);
    ret.set_version(Utils.getVersion());
    return ret;
}
Also used : NimbusStat(backtype.storm.generated.NimbusStat) ArrayList(java.util.ArrayList) SupervisorSummary(backtype.storm.generated.SupervisorSummary) NimbusSummary(backtype.storm.generated.NimbusSummary)

Aggregations

NimbusStat (backtype.storm.generated.NimbusStat)1 NimbusSummary (backtype.storm.generated.NimbusSummary)1 SupervisorSummary (backtype.storm.generated.SupervisorSummary)1 ArrayList (java.util.ArrayList)1