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


Java Tuple.contains方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:telstra,項目名稱:open-kilda,代碼行數:17,代碼來源:ConfirmationBolt.java

示例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);
    }
}
 
開發者ID:telstra,項目名稱:open-kilda,代碼行數:17,代碼來源:CorrelationBolt.java

示例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;
    }
}
 
開發者ID:telstra,項目名稱:open-kilda,代碼行數:10,代碼來源:FieldNameTopicSelector.java

示例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);
}
 
開發者ID:eorliac,項目名稱:patent-crawler,代碼行數:56,代碼來源:FetcherBolt.java

示例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;
}
 
開發者ID:telstra,項目名稱:open-kilda,代碼行數:6,代碼來源:FieldNameBasedTupleToKafkaMapper.java


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