楼主: ReneeBK
843 4

[Github]Apache Storm Applications [推广有奖]

  • 1关注
  • 62粉丝

VIP

已卖:4895份资源

学术权威

14%

还不是VIP/贵宾

-

TA的文库  其他...

R资源总汇

Panel Data Analysis

Experimental Design

威望
1
论坛币
49629 个
通用积分
55.4465
学术水平
370 点
热心指数
273 点
信用等级
335 点
经验
57805 点
帖子
4005
精华
21
在线时间
582 小时
注册时间
2005-5-8
最后登录
2023-11-26

楼主
ReneeBK 发表于 2017-8-22 00:38:26 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
Apache Storm Applications

A collection of real-time applications built with Apache Storm.

Table of Contents
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Applications Application GitHub cation apache

本帖被以下文库推荐

沙发
ReneeBK 发表于 2017-8-22 00:39:18
  1. package storm.applications.bolt;

  2. import backtype.storm.tuple.Tuple;
  3. import backtype.storm.tuple.Values;
  4. import org.slf4j.Logger;
  5. import org.slf4j.LoggerFactory;
  6. import storm.applications.model.cdr.CallDetailRecord;
  7. import static storm.applications.constants.VoIPSTREAMConstants.*;

  8. /**
  9. *
  10. * @author Maycon Viana Bordin <mayconbordin@gmail.com>
  11. */
  12. public class ACDBolt extends AbstractScoreBolt {
  13.     private static final Logger LOG = LoggerFactory.getLogger(ACDBolt.class);
  14.    
  15.     private double avg;

  16.     public ACDBolt() {
  17.         super("acd");
  18.     }

  19.     @Override
  20.     public void execute(Tuple input) {
  21.         Source src = parseComponentId(input.getSourceComponent());
  22.         
  23.         if (src == Source.GACD) {
  24.             avg = input.getDoubleByField(Field.AVERAGE);
  25.         } else {
  26.             CallDetailRecord cdr = (CallDetailRecord) input.getValueByField(Field.RECORD);
  27.             String number  = input.getString(0);
  28.             long timestamp = input.getLong(1);
  29.             double rate    = input.getDouble(2);

  30.             String key = String.format("%s:%d", number, timestamp);

  31.             if (map.containsKey(key)) {
  32.                 Entry e = map.get(key);
  33.                 e.set(src, rate);

  34.                 if (e.isFull()) {
  35.                     // calculate the score for the ratio
  36.                     double ratio = (e.get(Source.CT24)/e.get(Source.ECR24))/avg;
  37.                     double score = score(thresholdMin, thresholdMax, ratio);
  38.                     
  39.                     LOG.debug(String.format("T1=%f; T2=%f; CT24=%f; ECR24=%f; AvgCallDur=%f; Ratio=%f; Score=%f",
  40.                         thresholdMin, thresholdMax, e.get(Source.CT24), e.get(Source.ECR24), avg, ratio, score));

  41.                     collector.emit(new Values(number, timestamp, score, cdr));
  42.                     map.remove(key);
  43.                 } else {
  44.                     LOG.warn(String.format("Inconsistent entry: source=%s; %s",
  45.                             input.getSourceComponent(), e.toString()));
  46.                 }
  47.             } else {
  48.                 Entry e = new Entry(cdr);
  49.                 e.set(src, rate);
  50.                 map.put(key, e);
  51.             }
  52.         }
  53.     }
  54.    
  55.     @Override
  56.     protected Source[] getFields() {
  57.         return new Source[]{Source.CT24, Source.ECR24};
  58.     }
  59. }
复制代码

藤椅
MouJack007 发表于 2017-8-22 07:36:49
谢谢楼主分享!

板凳
MouJack007 发表于 2017-8-22 07:37:05

报纸
西门高 发表于 2017-8-22 18:53:57
谢谢分享

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-6 02:46