Package net.floodlightcontroller.devicemanager

Examples of net.floodlightcontroller.devicemanager.IDevice


        Entity entity2 = new Entity(2L, (short)2, 2, 1L, 2, new Date());
        Entity entity3 = new Entity(3L, (short)3, 3, 5L, 1, new Date());
        Entity entity4 = new Entity(4L, (short)4, 3, 5L, 2, new Date());
        Entity entity5 = new Entity(1L, (short)4, 3, 5L, 2, new Date());

        IDevice d1 = deviceManager.learnDeviceByEntity(entity1);
        IDevice d2 = deviceManager.learnDeviceByEntity(entity2);
        IDevice d3 = deviceManager.learnDeviceByEntity(entity3);
        IDevice d4 = deviceManager.learnDeviceByEntity(entity4);
        assertEquals(d1.getEntityClass(), d2.getEntityClass());
        assertEquals(d1.getEntityClass(), d3.getEntityClass());
        assertEquals(d1.getEntityClass(), d4.getEntityClass());

        IDevice d;

        Iterator<? extends IDevice> iter =
                deviceManager.queryClassDevices(d1.getEntityClass(), null,
                                                (short)1, 1, null, null);
        int count = 0;
        while (iter.hasNext()) {
            count += 1;
            d = iter.next();
            assertEquals(d1.getDeviceKey(), d.getDeviceKey());
        }
        assertEquals(1, count);

        iter = deviceManager.queryClassDevices(d1.getEntityClass(), null,
                                               (short)3, 3, null, null);
        count = 0;
        while (iter.hasNext()) {
            count += 1;
            d = iter.next();
            assertEquals(d3.getDeviceKey(), d.getDeviceKey());

        }
        assertEquals(1, count);

        iter = deviceManager.queryClassDevices(d1.getEntityClass(), null,
                                               (short)1, 3, null, null);
        count = 0;
        while (iter.hasNext()) {
            count += 1;
            iter.next();
        }
        assertEquals(0, count);

        IDevice d5 = deviceManager.learnDeviceByEntity(entity5);
        assertEquals(d1.getEntityClass(), d5.getEntityClass());
        iter = deviceManager.queryClassDevices(d1.getEntityClass(), null,
                                               (short)4, 3, null, null);
        count = 0;
        Set<Long> deviceKeysFromIterator = new HashSet<Long>();
        while (iter.hasNext()) {
            count += 1;
            d = iter.next();
            deviceKeysFromIterator.add(d.getDeviceKey());
        }
        Set<Long> expectedDeviceKeys = new HashSet<Long>();
        expectedDeviceKeys.add(d4.getDeviceKey());
        expectedDeviceKeys.add(d5.getDeviceKey());
        assertEquals(expectedDeviceKeys, deviceKeysFromIterator);
        assertEquals(2, count);
    }
View Full Code Here


        Entity entity4 = new Entity(4L, (short)2, 4, 2L, 2, new Date());

        Entity entity5 = new Entity(5L, (short)1, 5, 3L, 1, new Date());


        IDevice d1 = deviceManager.learnDeviceByEntity(entity1);
        IDevice d2 = deviceManager.learnDeviceByEntity(entity2);
        IDevice d3 = deviceManager.learnDeviceByEntity(entity3);
        IDevice d4 = deviceManager.learnDeviceByEntity(entity4);
        IDevice d5 = deviceManager.learnDeviceByEntity(entity5);

        // Make sure the entity classifier worked as expected
        assertEquals(MockEntityClassifierMac.testECMac1, d1.getEntityClass());
        assertEquals(MockEntityClassifierMac.testECMac1, d2.getEntityClass());
        assertEquals(MockEntityClassifierMac.testECMac2, d3.getEntityClass());
        assertEquals(MockEntityClassifierMac.testECMac2, d4.getEntityClass());
        assertEquals(DefaultEntityClassifier.entityClass,
                     d5.getEntityClass());

        // Look up the device using findDevice() which uses only the primary
        // index
        assertEquals(d1, deviceManager.findDevice(entity1.getMacAddress(),
                                                  entity1.getVlan(),
View Full Code Here

    private IDevice getSingleDeviceFromDeviceManager(long mac) {
        Iterator<? extends IDevice> diter =
                deviceManager.queryDevices(mac, null, null, null, null);
        assertTrue("Query didn't return a device", diter.hasNext());
        IDevice d = diter.next();
        assertFalse("Query returned more than one device", diter.hasNext());
        return d;
    }
View Full Code Here

        storeClient.put("FooBar", versionedDsr);

        deviceManager.getHAListener().transitionToMaster();

        // Query for the Device1. Make sure we have the two IPs we stored.
        IDevice d = getSingleDeviceFromDeviceManager(1L);
        assertDeviceIps(new Integer[] {3, 33}, d);
        assertArrayEquals(new Short[] { Ethernet.VLAN_UNTAGGED }, d.getVlanId());
        swp = new SwitchPort(4L, 5);
        assertArrayEquals(new SwitchPort[] { swp }, d.getAttachmentPoints());

        // Query for Device2. Make sure we only have the more recent AP
        // Query for the Device1. Make sure we have the two IPs we stored.
        d = getSingleDeviceFromDeviceManager(2L);
        assertArrayEquals(new Integer[0], d.getIPv4Addresses());
        assertArrayEquals(new Short[] { Ethernet.VLAN_UNTAGGED }, d.getVlanId());
        swp = new SwitchPort(4L, 5);
        assertArrayEquals(new SwitchPort[] { swp }, d.getAttachmentPoints());

        //----------------------------
        // add another entry device to the store. since device manager is
        // already master we won't read this device and it should be
        // removed from the store by the consolidate task
View Full Code Here

TOP

Related Classes of net.floodlightcontroller.devicemanager.IDevice

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.