本文整理匯總了Java中org.apache.storm.tuple.Tuple.contains方法的典型用法代碼示例。如果您正苦於以下問題:Java Tuple.contains方法的具體用法?Java Tuple.contains怎麽用?Java Tuple.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.storm.tuple.Tuple
的用法示例。
在下文中一共展示了Tuple.contains方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: execute
import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
@Override
public void execute(Tuple input, BasicOutputCollector collector) {
if (input.contains(FIELD_SWITCH_ID)) {
String switchId = (String)input.getValueByField(FIELD_SWITCH_ID);
logger.debug("switchId=" + input.getValueByField(FIELD_SWITCH_ID));
if (isSwitchConfirmed(switchId)) {
collector.emit(new Values(switchId));
} else {
logger.warn("could not confirm switch with id " + switchId);
// TODO - any action here?
}
} else {
logger.error(FIELD_SWITCH_ID + " not found in tuple " + input);
}
}
示例2: execute
import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
@Override
public void execute(Tuple input, BasicOutputCollector collector) {
if (input.contains(FIELD_SWITCH_ID)) {
String switchId = (String)input.getValueByField(FIELD_SWITCH_ID);
logger.debug("switchId=" + input.getValueByField(FIELD_SWITCH_ID));
if (isSwitchCorrelated(switchId)) {
collector.emit(new Values(switchId));
} else {
logger.warn("could not correlate switch with id " + switchId);
// TODO - any action here?
}
} else {
logger.error(FIELD_SWITCH_ID + " not found in tuple " + input);
}
}
示例3: getTopic
import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
@Override
public String getTopic(Tuple tuple) {
if (tuple.contains(fieldName)) {
return tuple.getStringByField(fieldName);
} else {
LOG.warn("Field {} Not Found. Returning default topic {}", fieldName, defaultTopicName);
return defaultTopicName;
}
}
示例4: create
import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
/**
* Create an item. Queue id will be created based on
* <code>queueMode</code> argument, either as a protocol + hostname
* pair, protocol + IP address pair or protocol+domain pair.
*/
public static FetchItem create(URL u, Tuple t, String queueMode) {
String queueID;
String url = u.toExternalForm();
String key = null;
// reuse any key that might have been given
// be it the hostname, domain or IP
if (t.contains("key")) {
key = t.getStringByField("key");
}
if (StringUtils.isNotBlank(key)) {
queueID = key.toLowerCase(Locale.ROOT);
return new FetchItem(url, u, t, queueID);
}
if (FetchItemQueues.QUEUE_MODE_IP.equalsIgnoreCase(queueMode)) {
try {
final InetAddress addr = InetAddress.getByName(u.getHost());
key = addr.getHostAddress();
} catch (final UnknownHostException e) {
LOG.warn(
"Unable to resolve IP for {}, using hostname as key.",
u.getHost());
key = u.getHost();
}
} else if (FetchItemQueues.QUEUE_MODE_DOMAIN
.equalsIgnoreCase(queueMode)) {
key = PaidLevelDomain.getPLD(u.getHost());
if (key == null) {
LOG.warn(
"Unknown domain for url: {}, using hostname as key",
url);
key = u.getHost();
}
} else {
key = u.getHost();
}
if (key == null) {
LOG.warn("Unknown host for url: {}, using URL string as key",
url);
key = u.toExternalForm();
}
queueID = key.toLowerCase(Locale.ROOT);
return new FetchItem(url, u, t, queueID);
}
示例5: getKeyFromTuple
import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
@Override
public K getKeyFromTuple(Tuple tuple) {
//for backward compatibility, we return null when key is not present.
return tuple.contains(boltKeyField) ? (K) tuple.getValueByField(boltKeyField) : null;
}