本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFVersion.compareTo方法的典型用法代码示例。如果您正苦于以下问题:Java OFVersion.compareTo方法的具体用法?Java OFVersion.compareTo怎么用?Java OFVersion.compareTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.projectfloodlight.openflow.protocol.OFVersion
的用法示例。
在下文中一共展示了OFVersion.compareTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeInitialFactory
import org.projectfloodlight.openflow.protocol.OFVersion; //导入方法依赖的package包/类
/**
* Find the max version supplied in the supported
* versions list and use it as the default, which
* will subsequently be used in our hello message
* header's version field.
*
* The factory can be later "downgraded" to a lower
* version depending on what's computed during the
* version-negotiation part of the handshake.
*
* Assumption: The Set of OFVersion ofVersions
* variable has been set already and is NOT EMPTY.
*
* @return the highest-version OFFactory we support
*/
private OFFactory computeInitialFactory(Set<OFVersion> ofVersions) {
/* This should NEVER happen. Double-checking. */
if (ofVersions == null || ofVersions.isEmpty()) {
throw new IllegalStateException("OpenFlow version list should never be null or empty at this point. Make sure it's set in the OFSwitchManager.");
}
OFVersion highest = null;
for (OFVersion v : ofVersions) {
if (highest == null) {
highest = v;
} else if (v.compareTo(highest) > 0) {
highest = v;
}
}
/*
* This assumes highest != null, which
* it won't be if the list of versions
* is not empty.
*/
return OFFactories.getFactory(highest);
}
示例2: processOFHello
import org.projectfloodlight.openflow.protocol.OFVersion; //导入方法依赖的package包/类
@Override
void processOFHello(OFHello m) throws IOException {
OFVersion version = m.getVersion();
/* Choose the lower of the two supported versions. */
if (version.compareTo(factory.getVersion()) < 0) {
factory = OFFactories.getFactory(version);
} /* else The controller's version is < or = the switch's, so keep original controller factory. */
OFMessageDecoder decoder = pipeline.get(OFMessageDecoder.class);
decoder.setVersion(version);
setState(new WaitFeaturesReplyState());
}