Search in sources :

Example 1 with NimbusSummary

use of backtype.storm.generated.NimbusSummary 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)

Example 2 with NimbusSummary

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

the class ServiceHandler method getClusterInfo.

/**
     * get cluster's summary, it will contain SupervisorSummary and TopologySummary
     *
     * @return ClusterSummary
     */
@Override
public ClusterSummary getClusterInfo() throws TException {
    long start = System.nanoTime();
    try {
        StormClusterState stormClusterState = data.getStormClusterState();
        Map<String, Assignment> assignments = new HashMap<String, Assignment>();
        // get TopologySummary
        List<TopologySummary> topologySummaries = NimbusUtils.getTopologySummary(stormClusterState, assignments);
        // all supervisors
        Map<String, SupervisorInfo> supervisorInfos = Cluster.get_all_SupervisorInfo(stormClusterState, null);
        // generate SupervisorSummaries
        List<SupervisorSummary> supervisorSummaries = NimbusUtils.mkSupervisorSummaries(supervisorInfos, assignments);
        NimbusSummary nimbusSummary = NimbusUtils.getNimbusSummary(stormClusterState, supervisorSummaries, data);
        return new ClusterSummary(nimbusSummary, supervisorSummaries, topologySummaries);
    } catch (TException e) {
        LOG.info("Failed to get ClusterSummary ", e);
        throw e;
    } catch (Exception e) {
        LOG.info("Failed to get ClusterSummary ", e);
        throw new TException(e);
    } finally {
        long end = System.nanoTime();
        SimpleJStormMetric.updateNimbusHistogram("getClusterInfo", (end - start) / TimeUtils.NS_PER_US);
    }
}
Also used : TException(org.apache.thrift.TException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ClusterSummary(backtype.storm.generated.ClusterSummary) SupervisorSummary(backtype.storm.generated.SupervisorSummary) NimbusSummary(backtype.storm.generated.NimbusSummary) SupervisorInfo(com.alibaba.jstorm.daemon.supervisor.SupervisorInfo) InvalidParameterException(java.security.InvalidParameterException) FailedAssignTopologyException(com.alibaba.jstorm.utils.FailedAssignTopologyException) KeyNotFoundException(backtype.storm.generated.KeyNotFoundException) TException(org.apache.thrift.TException) IOException(java.io.IOException) AlreadyAliveException(backtype.storm.generated.AlreadyAliveException) TopologyAssignException(backtype.storm.generated.TopologyAssignException) FileNotFoundException(java.io.FileNotFoundException) NotAliveException(backtype.storm.generated.NotAliveException) InvalidTopologyException(backtype.storm.generated.InvalidTopologyException) KeyAlreadyExistsException(backtype.storm.generated.KeyAlreadyExistsException) Assignment(com.alibaba.jstorm.schedule.Assignment) StormClusterState(com.alibaba.jstorm.cluster.StormClusterState) TopologySummary(backtype.storm.generated.TopologySummary)

Aggregations

NimbusSummary (backtype.storm.generated.NimbusSummary)2 SupervisorSummary (backtype.storm.generated.SupervisorSummary)2 AlreadyAliveException (backtype.storm.generated.AlreadyAliveException)1 ClusterSummary (backtype.storm.generated.ClusterSummary)1 InvalidTopologyException (backtype.storm.generated.InvalidTopologyException)1 KeyAlreadyExistsException (backtype.storm.generated.KeyAlreadyExistsException)1 KeyNotFoundException (backtype.storm.generated.KeyNotFoundException)1 NimbusStat (backtype.storm.generated.NimbusStat)1 NotAliveException (backtype.storm.generated.NotAliveException)1 TopologyAssignException (backtype.storm.generated.TopologyAssignException)1 TopologySummary (backtype.storm.generated.TopologySummary)1 StormClusterState (com.alibaba.jstorm.cluster.StormClusterState)1 SupervisorInfo (com.alibaba.jstorm.daemon.supervisor.SupervisorInfo)1 Assignment (com.alibaba.jstorm.schedule.Assignment)1 FailedAssignTopologyException (com.alibaba.jstorm.utils.FailedAssignTopologyException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InvalidParameterException (java.security.InvalidParameterException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1