本文整理匯總了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));
}
}
示例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));
}
示例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));
}
}
示例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"));
}
}
}
示例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);
}
}
示例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) );
}
示例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));
}
}
示例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])));
}
示例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));
}
示例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));
}
}
示例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));
}
}
示例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));
}
}
示例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));
}
示例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));
}
}
示例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));
}
}