Search in sources :

Example 1 with TopologySummary

use of org.apache.storm.generated.TopologySummary in project storm by apache.

the class StormCluster method killActiveTopologies.

public void killActiveTopologies() throws TException {
    List<TopologySummary> activeTopologies = getActive();
    for (TopologySummary activeTopology : activeTopologies) {
        killSilently(activeTopology.get_name());
    }
    AssertUtil.empty(getActive());
}
Also used : TopologySummary(org.apache.storm.generated.TopologySummary)

Example 2 with TopologySummary

use of org.apache.storm.generated.TopologySummary in project storm by apache.

the class TopoWrap method submitSuccessfully.

public void submitSuccessfully(ImmutableMap<String, Object> config) throws TException {
    submit(config);
    TopologySummary topologySummary = getSummary();
    Assert.assertEquals(topologySummary.get_status().toLowerCase(), "active", "Topology must be active.");
    id = topologySummary.get_id();
}
Also used : TopologySummary(org.apache.storm.generated.TopologySummary)

Example 3 with TopologySummary

use of org.apache.storm.generated.TopologySummary in project storm by apache.

the class Nimbus method getClusterInfoImpl.

private ClusterSummary getClusterInfoImpl() throws Exception {
    IStormClusterState state = stormClusterState;
    Map<String, SupervisorInfo> infos = state.allSupervisorInfo();
    List<SupervisorSummary> summaries = new ArrayList<>(infos.size());
    for (Entry<String, SupervisorInfo> entry : infos.entrySet()) {
        summaries.add(makeSupervisorSummary(entry.getKey(), entry.getValue()));
    }
    int uptime = this.uptime.upTime();
    Map<String, StormBase> bases = state.topologyBases();
    List<NimbusSummary> nimbuses = state.nimbuses();
    //update the isLeader field for each nimbus summary
    NimbusInfo leader = leaderElector.getLeader();
    for (NimbusSummary nimbusSummary : nimbuses) {
        nimbusSummary.set_uptime_secs(Time.deltaSecs(nimbusSummary.get_uptime_secs()));
        nimbusSummary.set_isLeader(leader.getHost().equals(nimbusSummary.get_host()) && leader.getPort() == nimbusSummary.get_port());
    }
    List<TopologySummary> topologySummaries = new ArrayList<>();
    for (Entry<String, StormBase> entry : bases.entrySet()) {
        StormBase base = entry.getValue();
        if (base == null) {
            continue;
        }
        String topoId = entry.getKey();
        Assignment assignment = state.assignmentInfo(topoId, null);
        int numTasks = 0;
        int numExecutors = 0;
        int numWorkers = 0;
        if (assignment != null && assignment.is_set_executor_node_port()) {
            for (List<Long> ids : assignment.get_executor_node_port().keySet()) {
                numTasks += StormCommon.executorIdToTasks(ids).size();
            }
            numExecutors = assignment.get_executor_node_port_size();
            numWorkers = new HashSet<>(assignment.get_executor_node_port().values()).size();
        }
        TopologySummary summary = new TopologySummary(topoId, base.get_name(), numTasks, numExecutors, numWorkers, Time.deltaSecs(base.get_launch_time_secs()), extractStatusStr(base));
        if (base.is_set_owner()) {
            summary.set_owner(base.get_owner());
        }
        String status = idToSchedStatus.get().get(topoId);
        if (status != null) {
            summary.set_sched_status(status);
        }
        TopologyResources resources = getResourcesForTopology(topoId, base);
        if (resources != null) {
            summary.set_requested_memonheap(resources.getRequestedMemOnHeap());
            summary.set_requested_memoffheap(resources.getRequestedMemOffHeap());
            summary.set_requested_cpu(resources.getRequestedCpu());
            summary.set_assigned_memonheap(resources.getAssignedMemOnHeap());
            summary.set_assigned_memoffheap(resources.getAssignedMemOffHeap());
            summary.set_assigned_cpu(resources.getAssignedCpu());
        }
        summary.set_replication_count(getBlobReplicationCount(ConfigUtils.masterStormCodeKey(topoId)));
        topologySummaries.add(summary);
    }
    ClusterSummary ret = new ClusterSummary(summaries, topologySummaries, nimbuses);
    ret.set_nimbus_uptime_secs(uptime);
    return ret;
}
Also used : ClusterSummary(org.apache.storm.generated.ClusterSummary) ArrayList(java.util.ArrayList) StormBase(org.apache.storm.generated.StormBase) SupervisorSummary(org.apache.storm.generated.SupervisorSummary) NimbusSummary(org.apache.storm.generated.NimbusSummary) SupervisorInfo(org.apache.storm.generated.SupervisorInfo) DataPoint(org.apache.storm.metric.api.DataPoint) NimbusInfo(org.apache.storm.nimbus.NimbusInfo) Assignment(org.apache.storm.generated.Assignment) SchedulerAssignment(org.apache.storm.scheduler.SchedulerAssignment) AtomicLong(java.util.concurrent.atomic.AtomicLong) TopologySummary(org.apache.storm.generated.TopologySummary) IStormClusterState(org.apache.storm.cluster.IStormClusterState) HashSet(java.util.HashSet)

Example 4 with TopologySummary

use of org.apache.storm.generated.TopologySummary in project storm by apache.

the class Nimbus method extractClusterMetrics.

private static List<DataPoint> extractClusterMetrics(ClusterSummary summ) {
    List<DataPoint> ret = new ArrayList<>();
    ret.add(new DataPoint("supervisors", summ.get_supervisors_size()));
    ret.add(new DataPoint("topologies", summ.get_topologies_size()));
    int totalSlots = 0;
    int usedSlots = 0;
    for (SupervisorSummary sup : summ.get_supervisors()) {
        usedSlots += sup.get_num_used_workers();
        totalSlots += sup.get_num_workers();
    }
    ret.add(new DataPoint("slotsTotal", totalSlots));
    ret.add(new DataPoint("slotsUsed", usedSlots));
    ret.add(new DataPoint("slotsFree", totalSlots - usedSlots));
    int totalExecutors = 0;
    int totalTasks = 0;
    for (TopologySummary topo : summ.get_topologies()) {
        totalExecutors += topo.get_num_executors();
        totalTasks += topo.get_num_tasks();
    }
    ret.add(new DataPoint("executorsTotal", totalExecutors));
    ret.add(new DataPoint("tasksTotal", totalTasks));
    return ret;
}
Also used : DataPoint(org.apache.storm.metric.api.DataPoint) ArrayList(java.util.ArrayList) SupervisorSummary(org.apache.storm.generated.SupervisorSummary) TopologySummary(org.apache.storm.generated.TopologySummary) DataPoint(org.apache.storm.metric.api.DataPoint)

Example 5 with TopologySummary

use of org.apache.storm.generated.TopologySummary in project storm by apache.

the class HdfsSpoutTopology method printMetrics.

static void printMetrics(Nimbus.Client client, String name) throws Exception {
    ClusterSummary summary = client.getClusterInfo();
    String id = null;
    for (TopologySummary ts : summary.get_topologies()) {
        if (name.equals(ts.get_name())) {
            id = ts.get_id();
        }
    }
    if (id == null) {
        throw new Exception("Could not find a topology named " + name);
    }
    TopologyInfo info = client.getTopologyInfo(id);
    int uptime = info.get_uptime_secs();
    long acked = 0;
    long failed = 0;
    double weightedAvgTotal = 0.0;
    for (ExecutorSummary exec : info.get_executors()) {
        if ("spout".equals(exec.get_component_id())) {
            SpoutStats stats = exec.get_stats().get_specific().get_spout();
            Map<String, Long> failedMap = stats.get_failed().get(":all-time");
            Map<String, Long> ackedMap = stats.get_acked().get(":all-time");
            Map<String, Double> avgLatMap = stats.get_complete_ms_avg().get(":all-time");
            for (String key : ackedMap.keySet()) {
                if (failedMap != null) {
                    Long tmp = failedMap.get(key);
                    if (tmp != null) {
                        failed += tmp;
                    }
                }
                long ackVal = ackedMap.get(key);
                double latVal = avgLatMap.get(key) * ackVal;
                acked += ackVal;
                weightedAvgTotal += latVal;
            }
        }
    }
    double avgLatency = weightedAvgTotal / acked;
    System.out.println("uptime: " + uptime + " acked: " + acked + " avgLatency: " + avgLatency + " acked/sec: " + (((double) acked) / uptime + " failed: " + failed));
}
Also used : ClusterSummary(org.apache.storm.generated.ClusterSummary) ExecutorSummary(org.apache.storm.generated.ExecutorSummary) TopologySummary(org.apache.storm.generated.TopologySummary) SpoutStats(org.apache.storm.generated.SpoutStats) TopologyInfo(org.apache.storm.generated.TopologyInfo)

Aggregations

TopologySummary (org.apache.storm.generated.TopologySummary)6 ClusterSummary (org.apache.storm.generated.ClusterSummary)3 ArrayList (java.util.ArrayList)2 SupervisorSummary (org.apache.storm.generated.SupervisorSummary)2 TopologyInfo (org.apache.storm.generated.TopologyInfo)2 DataPoint (org.apache.storm.metric.api.DataPoint)2 HashSet (java.util.HashSet)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 IStormClusterState (org.apache.storm.cluster.IStormClusterState)1 Assignment (org.apache.storm.generated.Assignment)1 ExecutorSummary (org.apache.storm.generated.ExecutorSummary)1 NimbusSummary (org.apache.storm.generated.NimbusSummary)1 SpoutStats (org.apache.storm.generated.SpoutStats)1 StormBase (org.apache.storm.generated.StormBase)1 SupervisorInfo (org.apache.storm.generated.SupervisorInfo)1 NimbusInfo (org.apache.storm.nimbus.NimbusInfo)1 SchedulerAssignment (org.apache.storm.scheduler.SchedulerAssignment)1