Package net.floodlightcontroller.devicemanager

Examples of net.floodlightcontroller.devicemanager.SwitchPort


        d = deviceManager.learnDeviceByEntity(entity1a);
        d = deviceManager.learnDeviceByEntity(entity2);
        d = deviceManager.learnDeviceByEntity(entity3);

        // all entities are active, so entity3 should win
        assertArrayEquals(new SwitchPort[] { new SwitchPort(10L, 1) },
                          d.getAttachmentPoints());

        assertArrayEquals(new SwitchPort[] { new SwitchPort(10L, 1),},
                              d.getAttachmentPoints(true));

        c.add(Calendar.MILLISECOND, Entity.ACTIVITY_TIMEOUT/4);
        entity1.setLastSeenTimestamp(c.getTime());
        d = deviceManager.learnDeviceByEntity(entity1);

        // all are still active; entity3 should still win
        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1) },
                          d.getAttachmentPoints());
        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1),
                                             new SwitchPort(5L, 1,
                                                            ErrorStatus.DUPLICATE_DEVICE),
                                                            new SwitchPort(10L, 1,
                                                                           ErrorStatus.DUPLICATE_DEVICE) },
                                                                           d.getAttachmentPoints(true));

        c.add(Calendar.MILLISECOND, Entity.ACTIVITY_TIMEOUT+2000);
        entity1.setLastSeenTimestamp(c.getTime());
        d = deviceManager.learnDeviceByEntity(entity1);

        assertEquals(entity1.getActiveSince(), entity1.getLastSeenTimestamp());
        // entity1 should now be the only active entity
        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1) },
                          d.getAttachmentPoints());
        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1) },
                          d.getAttachmentPoints(true));
    }
View Full Code Here


        deviceManager.learnDeviceByEntity(entity2);
        deviceManager.learnDeviceByEntity(entity3);
        IDevice d = deviceManager.learnDeviceByEntity(entity4);

        // all entities are active, so entities 2,4 should win
        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 2),
                                             new SwitchPort(5L, 2) },
                                             d.getAttachmentPoints());
        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 2),
                                             new SwitchPort(5L, 2)},
                                             d.getAttachmentPoints(true));

        c.add(Calendar.MILLISECOND, 1);
        entity1.setLastSeenTimestamp(c.getTime());
        d = deviceManager.learnDeviceByEntity(entity1);

        // all entities are active, so entities 2,4 should win
        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1),
                                             new SwitchPort(5L, 2) },
                                             d.getAttachmentPoints());
        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1),
                                             new SwitchPort(5L, 2),
                                             new SwitchPort(1L, 2, ErrorStatus.DUPLICATE_DEVICE)},
                                             d.getAttachmentPoints(true));

        c.add(Calendar.MILLISECOND, Entity.ACTIVITY_TIMEOUT+1);
        entity1.setLastSeenTimestamp(c.getTime());
        d = deviceManager.learnDeviceByEntity(entity1);

        // entities 3,4 are still in conflict, but 1 should be resolved
        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1),
                                             new SwitchPort(5L, 2) },
                                             d.getAttachmentPoints());
        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1),
                                             new SwitchPort(5L, 2)},
                                             d.getAttachmentPoints(true));

        entity3.setLastSeenTimestamp(c.getTime());
        d = deviceManager.learnDeviceByEntity(entity3);

        // no conflicts, 1 and 3 will win
        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1),
                                             new SwitchPort(5L, 1) },
                                             d.getAttachmentPoints());
        assertArrayEquals(new SwitchPort[] { new SwitchPort(1L, 1),
                                             new SwitchPort(5L, 1) },
                                             d.getAttachmentPoints(true));

    }
View Full Code Here

            Entity[] entities = new Entity[] { entity1, entity2,
                                               entity3, entity4
                                             };
            Device d = new Device(null,1L, null, null, null,
                                  Arrays.asList(entities), null);
            SwitchPort swp1x1 = new SwitchPort(1L, 1);
            SwitchPort swp1x2 = new SwitchPort(1L, 2);
            SwitchPort swp2x1 = new SwitchPort(2L, 1);
            SwitchPort swp10x1 = new SwitchPort(10L, 1);
            assertArrayEquals(new Short[] { -1, 1},
                              d.getSwitchPortVlanIds(swp10x1));
            assertArrayEquals(new Short[] { 3, 42},
                              d.getSwitchPortVlanIds(swp1x1));
            assertArrayEquals(new Short[0],
View Full Code Here

        assertEquals("Sanity check failed. Device doesn't have the expected " +
                     "entity class. Something with the test setup is strange",
                     EnumSet.of(DeviceField.MAC, DeviceField.VLAN,
                                DeviceField.SWITCH, DeviceField.PORT),
                     d2.getEntityClass().getKeyFields());
        SwitchPort swp = new SwitchPort(11L, 1, null);
        assertEquals("TestEntityClass::00:00:00:00:00:02::[23]::[" +
                     swp.toString() + "]::",
                     dsr2.getKey());
    }
View Full Code Here

        Device d2 = deviceManager.allocateDevice(2L, e2a,
                                                 DefaultEntityClassifier.entityClass);
        d2 = deviceManager.allocateDevice(d2, e2b, -1);
        d2.updateAttachmentPoint(4L, (short)5,
                                 e2b.getLastSeenTimestamp().getTime());
        SwitchPort swp = new SwitchPort(4L, 5);
        SwitchPort[] aps = d2.getAttachmentPoints();
        // sanity check
        assertArrayEquals("Sanity check: should only have AP(4L,5)",
                          new SwitchPort[] {swp}, aps);
        dsr = new DeviceSyncRepresentation(d2);
        storeClient.put(dsr.getKey(), dsr);

        // Add a tombstone entry to the store to make sure we don't trip a
        // NPE
        dsr = null;
        Versioned<DeviceSyncRepresentation> versionedDsr =
                storeClient.get("FooBar");
        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
View Full Code Here

TOP

Related Classes of net.floodlightcontroller.devicemanager.SwitchPort

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.