Search in sources :

Example 1 with ThroughputType

use of com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputType in project otter by alibaba.

the class StatsRemoteServiceImpl method flushThroughputStat.

private void flushThroughputStat() {
    synchronized (throughputStats) {
        Collection<Map<ThroughputType, ThroughputStat>> stats = throughputStats.values();
        for (Map<ThroughputType, ThroughputStat> stat : stats) {
            for (ThroughputStat data : stat.values()) {
                throughputStatService.createOrUpdateThroughput(data);
            }
        }
        throughputStats.clear();
    }
}
Also used : ThroughputType(com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputType) ThroughputStat(com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with ThroughputType

use of com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputType in project otter by alibaba.

the class StatsRemoteServiceImpl method onThroughputStat.

public void onThroughputStat(ThroughputStatEvent event) {
    Assert.notNull(event);
    Assert.notNull(event.getStats());
    if (statUnit <= 0) {
        for (ThroughputStat stat : event.getStats()) {
            throughputStatService.createOrUpdateThroughput(stat);
        }
    } else {
        synchronized (throughputStats) {
            for (ThroughputStat stat : event.getStats()) {
                Map<ThroughputType, ThroughputStat> data = throughputStats.get(stat.getPipelineId());
                ThroughputStat old = data.get(stat.getType());
                if (old != null) {
                    //执行合并
                    old.setNumber(stat.getNumber() + old.getNumber());
                    old.setSize(stat.getSize() + old.getSize());
                    if (stat.getEndTime().after(old.getEndTime())) {
                        old.setEndTime(stat.getEndTime());
                    }
                    if (stat.getStartTime().before(old.getStartTime())) {
                        old.setStartTime(stat.getStartTime());
                    }
                } else {
                    data.put(stat.getType(), stat);
                }
            }
        }
    }
}
Also used : ThroughputType(com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputType) ThroughputStat(com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat)

Aggregations

ThroughputStat (com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat)2 ThroughputType (com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputType)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1