当前位置: 首页>>代码示例>>Java>>正文


Java Enumeration.hashCode方法代码示例

本文整理汇总了Java中java.util.Enumeration.hashCode方法的典型用法代码示例。如果您正苦于以下问题:Java Enumeration.hashCode方法的具体用法?Java Enumeration.hashCode怎么用?Java Enumeration.hashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Enumeration的用法示例。


在下文中一共展示了Enumeration.hashCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setControllerTLV

import java.util.Enumeration; //导入方法依赖的package包/类
protected void setControllerTLV() {
	// Setting the controllerTLVValue based on current nano time,
	// controller's IP address, and the network interface object hash
	// the corresponding IP address.

	final int prime = 7867;

	byte[] controllerTLVValue = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }; // 8
	// byte
	// value.
	ByteBuffer bb = ByteBuffer.allocate(10);

	long result = System.nanoTime();
	try{
		// Use some data specific to the machine this controller is
		// running on. In this case: the list of network interfaces
		Enumeration<NetworkInterface> ifaces =
				NetworkInterface.getNetworkInterfaces();
		if (ifaces != null) {
			result = result * prime + ifaces.hashCode();
		}
	} catch (SocketException e) {
		log.warn("Could not get list of interfaces of local machine to " +
				"encode in TLV: {}", e.toString());
	}
	// set the first 4 bits to 0.
	result = result & (0x0fffffffffffffffL);

	bb.putLong(result);

	bb.rewind();
	bb.get(controllerTLVValue, 0, 8);

	this.controllerTLV = new LLDPTLV().setType((byte) 0x0c)
			.setLength((short) controllerTLVValue.length)
			.setValue(controllerTLVValue);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:38,代码来源:LinkDiscoveryManager.java

示例2: setControllerTLV

import java.util.Enumeration; //导入方法依赖的package包/类
@LogMessageDoc(level="WARN",
		message="Could not get list of interfaces of local machine to " +
				"encode in TLV: {detail-msg}",
				explanation="Outgoing LLDP packets encode a unique hash to " +
						"identify the local machine. The list of network " +
						"interfaces is used as input and the controller failed " +
						"to query this list",
						recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG)
protected void setControllerTLV() {
	// Setting the controllerTLVValue based on current nano time,
	// controller's IP address, and the network interface object hash
	// the corresponding IP address.

	final int prime = 7867;

	byte[] controllerTLVValue = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }; // 8
	// byte
	// value.
	ByteBuffer bb = ByteBuffer.allocate(10);

	long result = System.nanoTime();
	try{
		// Use some data specific to the machine this controller is
		// running on. In this case: the list of network interfaces
		Enumeration<NetworkInterface> ifaces =
				NetworkInterface.getNetworkInterfaces();
		if (ifaces != null) {
			result = result * prime + ifaces.hashCode();
		}
	} catch (SocketException e) {
		log.warn("Could not get list of interfaces of local machine to " +
				"encode in TLV: {}", e.toString());
	}
	// set the first 4 bits to 0.
	result = result & (0x0fffffffffffffffL);

	bb.putLong(result);

	bb.rewind();
	bb.get(controllerTLVValue, 0, 8);

	this.controllerTLV = new LLDPTLV().setType((byte) 0x0c)
			.setLength((short) controllerTLVValue.length)
			.setValue(controllerTLVValue);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:46,代码来源:LinkDiscoveryManager.java


注:本文中的java.util.Enumeration.hashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。