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


Java IDevice类代码示例

本文整理汇总了Java中net.floodlightcontroller.devicemanager.IDevice的典型用法代码示例。如果您正苦于以下问题:Java IDevice类的具体用法?Java IDevice怎么用?Java IDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getDeviceEntities

import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
@Get("json")
public Iterator<Entity[]> getDeviceEntities() {
    final Iterator<? extends IDevice> devices = super.getDevices();
    return new Iterator<Entity[]>() {

        @Override
        public boolean hasNext() {
            return devices.hasNext();
        }

        @Override
        public Entity[] next() {
            Device d = (Device)devices.next();
            return d.getEntities();
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:23,代码来源:DeviceEntityResource.java

示例2: generateDeviceEvent

import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
private void generateDeviceEvent(IDevice device, String reason) {
	List<IPv4Address> ipv4Addresses =
			new ArrayList<IPv4Address>(Arrays.asList(device.getIPv4Addresses()));
	List<IPv6Address> ipv6Addresses =
			new ArrayList<IPv6Address>(Arrays.asList(device.getIPv6Addresses()));
	List<SwitchPort> oldAps =
			new ArrayList<SwitchPort>(Arrays.asList(device.getOldAP()));
	List<SwitchPort> currentAps =
			new ArrayList<SwitchPort>(Arrays.asList(device.getAttachmentPoints()));
	List<VlanVid> vlanIds =
			new ArrayList<VlanVid>(Arrays.asList(device.getVlanId()));

	debugEventCategory.newEventNoFlush(new DeviceEvent(device.getMACAddress(),
			ipv4Addresses,
			ipv6Addresses,
			oldAps,
			currentAps,
			vlanIds, reason));
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:20,代码来源:DeviceManagerImpl.java

示例3: deviceAdded

import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
@Override
public void deviceAdded(IDevice device) {
	SwitchPort[] switchPort = device.getAttachmentPoints(); 
	if (switchPort.length == 0) {
                       //Device manager does not yet know an attachment point for a device (Bug Fix) 
                       return;
               }
	IPv4Address[] ips = device.getIPv4Addresses();
	if (ips.length == 0) {
		// A new no-ip device added
		return;
	}

	String dpid = HexString.toHexString(switchPort[0].getSwitchDPID()
			.getLong());
	String ip = IPv4.fromIPv4Address(ips[0].getInt());
	logger.debug("AP(dpid:{},ip:{}) is added", dpid, ip);

	AP ap = new AP(ip, dpid);
	apManager.addAP(ap);
	processAPAdded(ap);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:23,代码来源:ACL.java

示例4: deviceIPV4AddrChanged

import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
@Override
public void deviceIPV4AddrChanged(IDevice device) {

	SwitchPort[] switchPort = device.getAttachmentPoints();
	IPv4Address[] ips = device.getIPv4Addresses();

	String dpid = HexString.toHexString(switchPort[0].getSwitchDPID()
			.getLong());
	String ip = null;
	// some device may first appear with no IP address(default set to
	// 0.0.0.0), ignore it
	for (IPv4Address i : ips) {
		if (i.getInt() != 0) {
			ip = IPv4.fromIPv4Address(i.getInt());
			break;
		}
	}

	logger.debug("AP(dpid:{},ip:{}) is added", dpid, ip);
	AP ap = new AP(ip, dpid);
	apManager.addAP(ap);
	processAPAdded(ap);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:24,代码来源:ACL.java

示例5: testLastSeen

import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
@Test
public void testLastSeen() throws Exception {
	Calendar c = Calendar.getInstance();
	Date d1 = c.getTime();
	Entity entity1 = new Entity(MacAddress.of(1L), VlanVid.ZERO /* untagged*/, IPv4Address.NONE, IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO, d1);
	c.add(Calendar.SECOND, 1);
	Entity entity2 = new Entity(MacAddress.of(1L), VlanVid.ZERO /* untagged*/, IPv4Address.of(1), IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO, c.getTime());

	IDevice d = deviceManager.learnDeviceByEntity(entity2);
	assertEquals(c.getTime(), d.getLastSeen());
	d = deviceManager.learnDeviceByEntity(entity1);
	assertEquals(c.getTime(), d.getLastSeen());

	deviceManager.startUp(null);
	d = deviceManager.learnDeviceByEntity(entity1);
	assertEquals(d1, d.getLastSeen());
	d = deviceManager.learnDeviceByEntity(entity2);
	assertEquals(c.getTime(), d.getLastSeen());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:20,代码来源:DeviceManagerImplTest.java

示例6: verifyDevice

import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
/**
 * Verify that the given device exactly matches the given fields. E.g.,
 * if ip is not null we expect the device to have exactly one IP address.
 * swId and port are the attachment point port.
 * Vlan and ip are optional all other fields must be specified.
 * @return
 */
private static void verifyDevice(IDevice d, MacAddress mac, VlanVid vlan, IPv4Address ipv4,
		IPv6Address ipv6, DatapathId swId, OFPort port) {
	assertNotNull(d);
	if (!mac.equals(MacAddress.NONE)) {
		assertEquals(mac, d.getMACAddress());
	}
	if (vlan != null) {
		assertArrayEquals(new VlanVid[] { vlan }, d.getVlanId());
	}
	if (!ipv4.equals(IPv4Address.NONE)) {
		assertArrayEquals(new IPv4Address[] { ipv4 }, d.getIPv4Addresses());
	}
	if (!ipv6.equals(IPv6Address.NONE)) {
		assertArrayEquals(new IPv6Address[] { ipv6 }, d.getIPv6Addresses());
	}
	if (!swId.equals(DatapathId.NONE) && !port.equals(OFPort.ZERO)) {
		SwitchPort expectedAp = new SwitchPort(swId, port);
		assertArrayEquals(new SwitchPort[] { expectedAp }, d.getAttachmentPoints());
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:28,代码来源:DeviceManagerImplTest.java

示例7: learnEntity

import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
/**
 * Learn a device using the given characteristics.
 * @param macAddress the MAC
 * @param vlan the VLAN (can be VlanVid.ZERO for untagged)
 * @param ipv4Address the IPv4 (can be IPv4Address.NONE)
 * @param ipv6Address the IPv6 (can be IPv6Address.NONE)
 * @param switchDPID the attachment point switch DPID (can be DatapathId.NONE)
 * @param switchPort the attachment point switch port (can be OFPort.ZERO)
 * @param processUpdates if false, will not send updates.  Note that this
 * method is not thread safe if this is false
 * @return the device, either new or not
 */
public IDevice learnEntity(MacAddress macAddress, VlanVid vlan,
		IPv4Address ipv4Address, IPv6Address ipv6Address, DatapathId switchDPID,
		OFPort switchPort,
		boolean processUpdates) {
	List<IDeviceListener> listeners = deviceListeners.getOrderedListeners();
	if (!processUpdates) {
		deviceListeners.clearListeners();
	}
	
	/* Entity will enforce all but VLAN be non-null */
	IDevice res =  learnDeviceByEntity(new Entity(macAddress, 
			vlan, ipv4Address, ipv6Address, switchDPID, switchPort, new Date()));
	// Restore listeners
	if (listeners != null) {
		for (IDeviceListener listener : listeners) {
			deviceListeners.addListener("device", listener);
		}
	}
	return res;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:33,代码来源:MockDeviceManager.java

示例8: findDevice

import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
@Override
public IDevice findDevice(MacAddress macAddress, VlanVid vlan,
		IPv4Address ipv4Address, DatapathId switchDPID,
		OFPort switchPort)
				throws IllegalArgumentException {
	if (vlan != null && vlan.getVlan() <= 0)
		vlan = null;
	if (ipv4Address != null && ipv4Address.getInt() == 0)
		ipv4Address = null;
	Entity e = new Entity(macAddress, vlan, ipv4Address, switchDPID,
			switchPort, null);
	if (!allKeyFieldsPresent(e, entityClassifier.getKeyFields())) {
		throw new IllegalArgumentException("Not all key fields specified."
				+ " Required fields: " + entityClassifier.getKeyFields());
	}
	return findDeviceByEntity(e);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:18,代码来源:DeviceManagerImpl.java

示例9: findClassDevice

import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
@Override
public IDevice findClassDevice(IEntityClass entityClass, MacAddress macAddress,
		VlanVid vlan, IPv4Address ipv4Address)
				throws IllegalArgumentException {
	if (vlan != null && vlan.getVlan() <= 0)
		vlan = null;
	if (ipv4Address != null && ipv4Address.getInt() == 0)
		ipv4Address = null;
	Entity e = new Entity(macAddress, vlan, ipv4Address,
			null, null, null);
	if (entityClass == null ||
			!allKeyFieldsPresent(e, entityClass.getKeyFields())) {
		throw new IllegalArgumentException("Not all key fields and/or "
				+ " no source device specified. Required fields: " +
				entityClassifier.getKeyFields());
	}
	return findDestByEntity(entityClass, e);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:19,代码来源:DeviceManagerImpl.java

示例10: generateDeviceEvent

import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
private void generateDeviceEvent(IDevice device, String reason) {
	List<IPv4Address> ipv4Addresses =
			new ArrayList<IPv4Address>(Arrays.asList(device.getIPv4Addresses()));
	List<SwitchPort> oldAps =
			new ArrayList<SwitchPort>(Arrays.asList(device.getOldAP()));
	List<SwitchPort> currentAps =
			new ArrayList<SwitchPort>(Arrays.asList(device.getAttachmentPoints()));
	List<VlanVid> vlanIds =
			new ArrayList<VlanVid>(Arrays.asList(device.getVlanId()));

	debugEventCategory.newEventNoFlush(new DeviceEvent(device.getMACAddress(),
			ipv4Addresses,
			oldAps,
			currentAps,
			vlanIds, reason));
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:17,代码来源:DeviceManagerImpl.java

示例11: deviceAdded

import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
/**
 * listen for new device
 */
@Override
public void deviceAdded(IDevice device) {
	SwitchPort[] switchPort = device.getAttachmentPoints();
	IPv4Address[] ips = device.getIPv4Addresses();
	if(ips.length == 0){
		// A new no-ip device added
		return;
	}
	String dpid = HexString.toHexString(switchPort[0].getSwitchDPID().getLong());
	String ip = IPv4.fromIPv4Address(ips[0].getInt());
	logger.info("New AP added. [dpid:" + dpid + " ip:" + ip + "]");

	AP ap = new AP(ip,dpid);
	apManager.addAP(ap);
	processAPAdded(ap);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:20,代码来源:ACL.java

示例12: deviceIPV4AddrChanged

import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
@Override
public void deviceIPV4AddrChanged(IDevice device) {
	
	SwitchPort[] switchPort = device.getAttachmentPoints();
	IPv4Address[] ips = device.getIPv4Addresses();
	
	String dpid = HexString.toHexString(switchPort[0].getSwitchDPID().getLong());
	String ip = null;
	
	// some device may first appear with no IP address(default set to 0.0.0.0), ignore it
	for(IPv4Address i : ips){
		if(i.getInt() != 0){
			ip = IPv4.fromIPv4Address(i.getInt());
			break;
		}
	}
	
	logger.info("New AP added. [dpid:" + dpid + " ip:" + ip + "]");
	AP ap = new AP(ip, dpid);
	apManager.addAP(ap);
	processAPAdded(ap);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:23,代码来源:ACL.java

示例13: testLastSeen

import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
@Test
public void testLastSeen() throws Exception {
	Calendar c = Calendar.getInstance();
	Date d1 = c.getTime();
	Entity entity1 = new Entity(MacAddress.of(1L), null, null, null, null, d1);
	c.add(Calendar.SECOND, 1);
	Entity entity2 = new Entity(MacAddress.of(1L), null, IPv4Address.of(1), null, null, c.getTime());

	IDevice d = deviceManager.learnDeviceByEntity(entity2);
	assertEquals(c.getTime(), d.getLastSeen());
	d = deviceManager.learnDeviceByEntity(entity1);
	assertEquals(c.getTime(), d.getLastSeen());

	deviceManager.startUp(null);
	d = deviceManager.learnDeviceByEntity(entity1);
	assertEquals(d1, d.getLastSeen());
	d = deviceManager.learnDeviceByEntity(entity2);
	assertEquals(c.getTime(), d.getLastSeen());
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:20,代码来源:DeviceManagerImplTest.java

示例14: verifyDevice

import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
/**
 * Verify that the given device exactly matches the given fields. E.g.,
 * if ip is not null we expect the device to have exactly one IP address.
 * swId and port are the attachment point port.
 * Vlan and ip are optional all other fields must be specified.
 * @return
 */
private static void verifyDevice(IDevice d, long mac, Short vlan, Integer ip,
		long swId, int port) {
	assertNotNull(d);
	assertEquals(MacAddress.of(mac), d.getMACAddress());
	if (vlan == null)
		assertArrayEquals(new VlanVid[] { VlanVid.ofVlan(-1) }, d.getVlanId());
	else
		assertArrayEquals(new VlanVid[] { VlanVid.ofVlan(vlan) }, d.getVlanId());

	if (ip == null)
		assertArrayEquals(new IPv4Address[] { IPv4Address.of(0) }, d.getIPv4Addresses());
	else
		assertArrayEquals(new IPv4Address[] { IPv4Address.of(ip) }, d.getIPv4Addresses());

	SwitchPort expectedAp = new SwitchPort(DatapathId.of(swId), OFPort.of(port));
	assertArrayEquals(new SwitchPort[] { expectedAp },
			d.getAttachmentPoints());
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:26,代码来源:DeviceManagerImplTest.java

示例15: getDeviceFromIP

import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
private IDevice getDeviceFromIP(int ip){
	IDevice device = null;
	
	 for (IDevice d : deviceService.getAllDevices()) {
            for (int j = 0; j < d.getIPv4Addresses().length; j++) {
                    if (device == null && 
                    		(ip == d.getIPv4Addresses()[j].getInt())){
                    	device = d;
                    }
            }
	 }
	return device;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:14,代码来源:FP_FloodlightRTE.java


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