Package net.floodlightcontroller.core

Examples of net.floodlightcontroller.core.RoleInfo


                (IFloodlightProviderService)getContext().getAttributes().
                    get(IFloodlightProviderService.class.getCanonicalName());

        String switchId = (String) getRequestAttributes().get("switchId");

        RoleInfo roleInfo;

        if (switchId.equalsIgnoreCase("all")) {
            HashMap<String,RoleInfo> model = new HashMap<String,RoleInfo>();
            for (IOFSwitch sw: floodlightProvider.getAllSwitchMap().values()) {
                switchId = sw.getStringId();
                roleInfo = new RoleInfo(sw.getHARole(), null);
                model.put(switchId, roleInfo);
            }
            return model;
        }

        Long dpid = HexString.toLong(switchId);
        IOFSwitch sw = floodlightProvider.getSwitch(dpid);
        if (sw == null)
            return null;
        roleInfo = new RoleInfo(sw.getHARole(), null);
        return roleInfo;
    }
View Full Code Here


            }

            this.role = role;
            this.roleChangeDescription = roleChangeDescription;
            this.connectedChannelHandlers = new HashSet<OFChannelHandler>();
            this.currentRoleInfo = new RoleInfo(this.role,
                                           this.roleChangeDescription,
                                           new Date());
        }
View Full Code Here

            this.role = role;
            this.roleChangeDescription = roleChangeDescription;

            // TODO: we currently notify switches synchronously from the REST
            // API handler. We could (should?) do this asynchronously.
            currentRoleInfo = new RoleInfo(this.role,
                                           this.roleChangeDescription,
                                           new Date());
            Controller.this.switchManager.setRole(this.role);
            for (OFChannelHandler h: connectedChannelHandlers)
                h.sendRoleRequest(this.role);
View Full Code Here

         * RoleInfo object is used by REST API users. We need to return
         * a defensive copy.
         * @return the current RoleInfo object
         */
        public synchronized RoleInfo getRoleInfo() {
            return new RoleInfo(currentRoleInfo);
        }
View Full Code Here

    }


    @Test
    public void testGetRoleInfoDefault() {
        RoleInfo info = controller.getRoleInfo();
        assertEquals(Role.MASTER.toString(), info.getRole());
        assertNotNull(info.getRoleChangeDescription());
        assertEquals(Role.MASTER, controller.getRole());
        // FIXME: RoleInfo's date. but the format is kinda broken
    }
View Full Code Here

     * receive a setRole request
     */
    @Test
    public void testSetRole() throws Exception {
        doSetUp(Role.SLAVE);
        RoleInfo info = controller.getRoleInfo();
        assertEquals(Role.SLAVE.toString(), info.getRole());
        assertEquals(Role.SLAVE, controller.getRole());


        OFChannelHandler h = createMock(OFChannelHandler.class);

        // Add the channel handler. The controller should call sendRoleRequest
        h.sendRoleRequest(Role.SLAVE);
        expectLastCall().once();
        replay(h);
        controller.addSwitchChannelAndSendInitialRole(h);
        verify(h);

        // Reassert the role.
        reset(h);
        h.sendRoleRequestIfNotPending(Role.SLAVE);
        replay(h);
        controller.reassertRole(h, Role.SLAVE);
        verify(h);

        // reassert a different role: no-op
        reset(h);
        replay(h);
        controller.reassertRole(h, Role.MASTER);
        verify(h);

        // Change role to MASTER
        reset(h);
        h.sendRoleRequest(Role.MASTER);
        expectLastCall().once();
        IHAListener listener = createMock(IHAListener.class);
        expect(listener.getName()).andReturn("foo").anyTimes();
        setupListenerOrdering(listener);
        listener.transitionToMaster();
        expectLastCall().once();
        replay(listener);
        replay(h);
        controller.addHAListener(listener);
        controller.setRole(Role.MASTER, "FooBar");
        controller.processUpdateQueueForTesting();
        verify(h);
        verify(listener);
        info = controller.getRoleInfo();
        assertEquals(Role.MASTER.toString(), info.getRole());
        assertEquals("FooBar", info.getRoleChangeDescription());
        assertEquals(Role.MASTER, controller.getRole());


    }
View Full Code Here

        // set role to equal. Should set to master internally
        controller.setRole(Role.EQUAL, "ToEqual");
        controller.processUpdateQueueForTesting();
        verify(listener);
        RoleInfo info = controller.getRoleInfo();
        assertEquals(Role.MASTER.toString(), info.getRole());
        assertEquals("ToEqual", info.getRoleChangeDescription());
        assertEquals(Role.MASTER, controller.getRole());


        verify(h); // no calls should have happened on h
    }
View Full Code Here

TOP

Related Classes of net.floodlightcontroller.core.RoleInfo

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.