當前位置: 首頁>>代碼示例>>Java>>正文


Java TridentCollector.emit方法代碼示例

本文整理匯總了Java中storm.trident.operation.TridentCollector.emit方法的典型用法代碼示例。如果您正苦於以下問題:Java TridentCollector.emit方法的具體用法?Java TridentCollector.emit怎麽用?Java TridentCollector.emit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在storm.trident.operation.TridentCollector的用法示例。


在下文中一共展示了TridentCollector.emit方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import storm.trident.operation.TridentCollector; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple tuple, Map<String, Object> result, TridentCollector collector) {
    if (result == null) {
        Map<String, Object> empty = new HashMap<>();
        collector.emit(new Values(empty));
    } else {
        result.remove("client_rssi");
        result.remove("client_rssi_num");
        result.remove("client_snr");
        result.remove("client_snr_num");
        result.remove("dot11_status");
        result.remove("wireless_id");

        collector.emit(new Values(result));
    }
}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:17,代碼來源:RiakEventsLocationMseQuery.java

示例2: execute

import storm.trident.operation.TridentCollector; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
    String currentValue;
    int newHashModValue;
    String newValue;
    int currentTry;

    currentTry = 0;
    currentValue = tuple.getString(0);
    newHashModValue = (currentValue.hashCode() % this.numPartitions) + 1;
    newHashModValue = newHashModValue % this.numPartitions;  // rotate back to 0 if necessary

    do {
        newValue = UUID.randomUUID().toString();

        if (currentTry++ >= maxTry) {
            throw new RuntimeException("Couldn't find a value for hash/mod " + newHashModValue +
                    " in " + maxTry + " attempts. Current value is " + newValue +
                    " Number of partitions: " + this.numPartitions);
        }

    } while ((newValue.hashCode() % this.numPartitions) != newHashModValue);

    collector.emit(new Values(newValue));
}
 
開發者ID:uzh,項目名稱:storm-scheduler,代碼行數:26,代碼來源:IncreaseHashByOneFunction.java

示例3: execute

import storm.trident.operation.TridentCollector; //導入方法依賴的package包/類
/**
 * <p>This function converts a JSON events to JAVA Map.</p>
 */
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
    String jsonEvent = tuple.getString(0);
    if (jsonEvent != null && jsonEvent.length() > 0) {
        Map<String, Object> event = null;
        try {
            event = _mapper.readValue(jsonEvent, Map.class);
            _metric.incrEvent();
        } catch (IOException | NullPointerException ex) {
            Logger.getLogger(MapperFunction.class.getName()).log(Level.SEVERE, "Failed converting a JSON tuple to a Map class [ " + _metricName + " ] \n"
                    + " JSON tuple: " + jsonEvent, ex);
        }
        if (event != null)
            collector.emit(new Values(event));
    }
}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:20,代碼來源:MapperFunction.java

示例4: execute

import storm.trident.operation.TridentCollector; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
    Map<String , Object> mseData = (Map<String, Object>) tuple.get(0);
    List<Map<String, Object>> notifications = (List<Map<String, Object>>) mseData.get("notifications");

    for (Map<String, Object> notification : notifications){
        if(notification.get("notificationType").equals("association")){
            logger.fine("Mse10 event this event is a association, emitting: [" + notification.size() + ", " + "null]");
            collector.emit(new Values(notification, null));
        }else if(notification.get("notificationType").equals("locationupdate")){
            logger.fine("Mse10 event this event is a locationupdate, emitting: [null" + ", " + notification.size() + "]");
            collector.emit(new Values(null, notification));
        }else{
            Logger.getLogger(SplitMSE10Data.class.getName()).log(Level.WARNING, "MSE version 10 notificationType is unknown: " + notification.get("notificationType"));
        }
    }
}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:18,代碼來源:SplitMSE10Data.java

示例5: emitBatch

import storm.trident.operation.TridentCollector; //導入方法依賴的package包/類
@Override
public void emitBatch(long batchId, TridentCollector collector) {
    List<List<Object>> batch = this.batches.get(batchId);
    if(batch == null){
        batch = new ArrayList<List<Object>>();
        if(index>=outputs.length && cycle) {
            index = 0;
        }
        for(int i=0; index < outputs.length && i < maxBatchSize; index++, i++) {
            batch.add(outputs[index]);
        }
        this.batches.put(batchId, batch);
    }
    for(List<Object> list : batch){
        collector.emit(list);
    }
}
 
開發者ID:kkllwww007,項目名稱:jstrom,代碼行數:18,代碼來源:FixedBatchSpout.java

示例6: execute

import storm.trident.operation.TridentCollector; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple tridentTuple, TridentCollector tridentCollector) {
    String kafkaInput = tridentTuple.getString(0);

    String url;
    Integer depth;

    String[] tokens = kafkaInput.split(" ");
    if(tokens.length == 2){
        url = tokens[0];
        depth = Integer.parseInt(tokens[1]);
    } else if (tokens.length == 1){
        url = tokens[0];
        depth = new Integer(0);
    } else {
        return;
    }
    tridentCollector.emit(new Values(url, depth) );
}
 
開發者ID:skalmadka,項目名稱:web-crawler,代碼行數:20,代碼來源:SplitKafkaInput.java

示例7: execute

import storm.trident.operation.TridentCollector; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple tuple, Map<String, Object> result, TridentCollector collector) {
    if (result == null) {
        Map<String, Object> empty = new HashMap<>();
        collector.emit(new Values(empty));
    } else {
        collector.emit(new Values(result));
    }
}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:10,代碼來源:RiakQuery.java

示例8: execute

import storm.trident.operation.TridentCollector; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple tuple,
      TridentCollector collector) {

  String tick = tuple.getString(0);
  String[] parts = tick.split(",");
  System.out.println("TickParser: price=" + Double.valueOf(parts[4]));
  collector.emit(new Values(Double.valueOf(parts[4])));
}
 
開發者ID:amitchmca,項目名稱:hadooparchitecturebook,代碼行數:10,代碼來源:TickParser.java

示例9: execute

import storm.trident.operation.TridentCollector; //導入方法依賴的package包/類
/**
 * <p>This function converts a JAVA Map to JSON events.</p>
 */
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
    String eventJSON = "";
    try {
        eventJSON = _mapper.writeValueAsString((Map<String, Object>) tuple.getValue(0));
    } catch (IOException ex) {
        Logger.getLogger(MapToJSONFunction.class.getName()).log(Level.SEVERE, null, ex);
    }

    collector.emit(new Values(eventJSON));
}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:15,代碼來源:MapToJSONFunction.java

示例10: execute

import storm.trident.operation.TridentCollector; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple tuple, Map<String, Object> result, TridentCollector collector) {
    if (result == null) {
        Map<String, Object> empty = new HashMap<>();
        //empty.put("quality", 100);
        collector.emit(new Values(empty));
    } else {
        result.put("dot11_status", "ASSOCIATED");
        collector.emit(new Values(result));
    }
}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:12,代碼來源:RiakLocationQuery.java

示例11: execute

import storm.trident.operation.TridentCollector; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
    Map<String, Object> map = (Map<String, Object>) tuple.get(0);

    if (map != null) {
        Map<String, Object> data = new HashMap<>();
        data.putAll(map);
        data.remove("client_mac");

        Map<String, Object> druid = new HashMap<>();
        druid.put("bytes", 0);
        druid.put("pkts", 0);
        druid.put("timestamp", System.currentTimeMillis() / 1000);
        druid.putAll(map);
        druid.put("type", "nmsp-info");

        Object vlan = map.get("vlan_id");

        if (vlan != null) {
            druid.put("src_vlan", vlan);
            data.put("src_vlan", vlan);
            data.remove("vlan_id");
            druid.remove("vlan_id");
        }

        // logger.severe("Processed NMSP data info, emitting  [" + map.get("client_mac") + ", " + data.size() + ", " + druid.size() + "]");

        collector.emit(new Values(map.get("client_mac"), data, druid));
    }
}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:31,代碼來源:GetNMSPInfoData.java

示例12: execute

import storm.trident.operation.TridentCollector; //導入方法依賴的package包/類
/**
 * <p>This function check if the event contains the timestamp. If the event does not contain it creates it from the current time.</p>
 */
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
    Map<String, Object> event = (Map<String, Object>) tuple.getValue(0);
    if(!event.containsKey("timestamp")){
        event.put("timestamp", System.currentTimeMillis()/1000);
        collector.emit(new Values(event));
    }else{
        collector.emit(new Values(event));
    }

}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:15,代碼來源:CheckTimestampFunction.java

示例13: execute

import storm.trident.operation.TridentCollector; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
    Map<String, Object> event = (Map<String, Object>) tuple.getValue(0);
    Map<String, Object> vendorMap = new HashMap<>();
    String clientMac = (String) event.get("client_mac");

    if (clientMac != null) {
        String oui = buildOui(clientMac);
        if (_ouiMap.get(oui) != null)
            vendorMap.put("client_mac_vendor", _ouiMap.get(oui));
    }

    collector.emit(new Values(vendorMap));
}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:15,代碼來源:MacVendorFunction.java

示例14: execute

import storm.trident.operation.TridentCollector; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple tuple, Map<String, Object> result, TridentCollector collector) {
    if (result == null) {
        Map<String, Object> empty = new HashMap<>();
        empty.put("dot11_status", "PROBING");
        collector.emit(new Values(empty));
    } else {
        collector.emit(new Values(result));
    }
}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:11,代碼來源:MemcachedLocationV10Query.java

示例15: execute

import storm.trident.operation.TridentCollector; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple tuple, Map<String, Object> result, TridentCollector collector) {
    if (result == null) {
        Map<String, Object> empty = new HashMap<>();
        empty.put("client_rssi", "unknown");
        empty.put("client_rssi_num", 0);
        empty.put("client_snr", "unknown");
        empty.put("client_snr_num", 0);
        collector.emit(new Values(empty));
    } else {
        collector.emit(new Values(result));
    }
}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:14,代碼來源:MemcachedTrapQuery.java


注:本文中的storm.trident.operation.TridentCollector.emit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。