Examples of ITopologyService


Examples of net.floodlightcontroller.topology.ITopologyService

import org.restlet.resource.ServerResource;

public class BroadcastDomainPortsResource extends ServerResource {
    @Get("json")
    public Set<NodePortTuple> retrieve() {
        ITopologyService topology =
                (ITopologyService)getContext().getAttributes().
                    get(ITopologyService.class.getCanonicalName());
       
        return topology.getBroadcastDomainPorts();
    }
View Full Code Here

Examples of net.floodlightcontroller.topology.ITopologyService

    @Get("json")
    public Map<String, List<String>> retrieve() {
        IFloodlightProviderService floodlightProvider =
                (IFloodlightProviderService)getContext().getAttributes().
                    get(IFloodlightProviderService.class.getCanonicalName());
        ITopologyService topology =
                (ITopologyService)getContext().getAttributes().
                    get(ITopologyService.class.getCanonicalName());

        Form form = getQuery();
        String queryType = form.getFirstValue("type", true);
        boolean openflowDomain = true;
        if (queryType != null && "l2".equals(queryType)) {
            openflowDomain = false;
        }

        Map<String, List<String>> switchClusterMap = new HashMap<String, List<String>>();
        for (Long dpid: floodlightProvider.getAllSwitchDpids()) {
            Long clusterDpid =
                    (openflowDomain
                     ? topology.getOpenflowDomainId(dpid)
                     :topology.getL2DomainId(dpid));
            List<String> switchesInCluster = switchClusterMap.get(HexString.toHexString(clusterDpid));
            if (switchesInCluster != null) {
                switchesInCluster.add(HexString.toHexString(dpid));
            } else {
                List<String> l = new ArrayList<String>();
View Full Code Here

Examples of net.floodlightcontroller.topology.ITopologyService

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

        ITopologyService topology=
                (ITopologyService)getContext().getAttributes().
                get(ITopologyService.class.getCanonicalName());

        if (floodlightProvider == null || topology == null)
            return result;

        Set<Long> switches = floodlightProvider.getAllSwitchDpids();
        if (switches == null) return result;

        for(long sw: switches) {
            Set<Short> ports = topology.getPorts(sw);
            if (ports == null) continue;
            for(short p: ports) {
                result.add(new NodePortTuple(sw, p));
            }
        }
View Full Code Here

Examples of net.floodlightcontroller.topology.ITopologyService

import org.restlet.resource.ServerResource;

public class BlockedPortsResource extends ServerResource {
    @Get("json")
    public Set<NodePortTuple> retrieve() {
        ITopologyService topology =
                (ITopologyService)getContext().getAttributes().
                    get(ITopologyService.class.getCanonicalName());
       
        return topology.getBlockedPorts();
    }
View Full Code Here

Examples of net.floodlightcontroller.topology.ITopologyService

import org.restlet.resource.ServerResource;

public class TunnelLinksResource extends ServerResource {
    @Get("json")
    public Set<NodePortTuple> retrieve() {
        ITopologyService topology =
                (ITopologyService)getContext().getAttributes().
                    get(ITopologyService.class.getCanonicalName());
       
        return topology.getTunnelPorts();
    }
View Full Code Here

Examples of net.floodlightcontroller.topology.ITopologyService

     * @return
     */
    private Map<Long, AttachmentPoint> getAPMap(List<AttachmentPoint> apList) {

        if (apList == null) return null;
        ITopologyService topology = deviceManager.topology;

        // Get the old attachment points and sort them.
        List<AttachmentPoint>oldAP = new ArrayList<AttachmentPoint>();
        if (apList != null) oldAP.addAll(apList);

        // Remove invalid attachment points before sorting.
        List<AttachmentPoint>tempAP =
                new ArrayList<AttachmentPoint>();
        for(AttachmentPoint ap: oldAP) {
            if (deviceManager.isValidAttachmentPoint(ap.getSw(), ap.getPort())){
                tempAP.add(ap);
            }
        }
        oldAP = tempAP;

        Collections.sort(oldAP, deviceManager.apComparator);

        // Map of attachment point by L2 domain Id.
        Map<Long, AttachmentPoint> apMap = new HashMap<Long, AttachmentPoint>();

        for(int i=0; i<oldAP.size(); ++i) {
            AttachmentPoint ap = oldAP.get(i);
            // if this is not a valid attachment point, continue
            if (!deviceManager.isValidAttachmentPoint(ap.getSw(),
                                                      ap.getPort()))
                continue;

            long id = topology.getL2DomainId(ap.getSw());
            apMap.put(id, ap);
        }

        if (apMap.isEmpty()) return null;
        return apMap;
View Full Code Here

Examples of net.floodlightcontroller.topology.ITopologyService

     * @param apMap
     * @return
     */
    List<AttachmentPoint> getDuplicateAttachmentPoints(List<AttachmentPoint>oldAPList,
                                                       Map<Long, AttachmentPoint>apMap) {
        ITopologyService topology = deviceManager.topology;
        List<AttachmentPoint> dupAPs = new ArrayList<AttachmentPoint>();
        long timeThreshold = System.currentTimeMillis() -
                AttachmentPoint.INACTIVITY_INTERVAL;

        if (oldAPList == null || apMap == null)
            return dupAPs;

        for(AttachmentPoint ap: oldAPList) {
            long id = topology.getL2DomainId(ap.getSw());
            AttachmentPoint trueAP = apMap.get(id);

            if (trueAP == null) continue;
            boolean c = (topology.isConsistent(trueAP.getSw(), trueAP.getPort(),
                                              ap.getSw(), ap.getPort()));
            boolean active = (ap.getActiveSince() > trueAP.getActiveSince());
            boolean last = ap.getLastSeen() > timeThreshold;
            if (!c && active && last) {
                dupAPs.add(ap);
View Full Code Here

Examples of net.floodlightcontroller.topology.ITopologyService

     * @param port
     * @param lastSeen
     * @return
     */
    protected boolean updateAttachmentPoint(long sw, short port, long lastSeen){
        ITopologyService topology = deviceManager.topology;
        List<AttachmentPoint> oldAPList;
        List<AttachmentPoint> apList;
        boolean oldAPFlag = false;

        if (!deviceManager.isValidAttachmentPoint(sw, port)) return false;
        AttachmentPoint newAP = new AttachmentPoint(sw, port, lastSeen);
        //Copy the oldAP and ap list.
        apList = new ArrayList<AttachmentPoint>();
        if (attachmentPoints != null) apList.addAll(attachmentPoints);
        oldAPList = new ArrayList<AttachmentPoint>();
        if (oldAPs != null) oldAPList.addAll(oldAPs);

        // if the sw, port is in old AP, remove it from there
        // and update the lastSeen in that object.
        if (oldAPList.contains(newAP)) {
            int index = oldAPList.indexOf(newAP);
            newAP = oldAPList.remove(index);
            newAP.setLastSeen(lastSeen);
            this.oldAPs = oldAPList;
            oldAPFlag = true;
        }

        // newAP now contains the new attachment point.

        // Get the APMap is null or empty.
        Map<Long, AttachmentPoint> apMap = getAPMap(apList);
        if (apMap == null || apMap.isEmpty()) {
            apList.add(newAP);
            attachmentPoints = apList;
            // there are no old attachment points - since the device exists, this
            // may be because the host really moved (so the old AP port went down);
            // or it may be because the switch restarted (so old APs were nullified).
            // For now we will treat both cases as host moved.
            return true;
        }

        long id = topology.getL2DomainId(sw);
        AttachmentPoint oldAP = apMap.get(id);

        if (oldAP == null) // No attachment on this L2 domain.
        {
            apList = new ArrayList<AttachmentPoint>();
            apList.addAll(apMap.values());
            apList.add(newAP);
            this.attachmentPoints = apList;
            return true; // new AP found on an L2 island.
        }

        // There is already a known attachment point on the same L2 island.
        // we need to compare oldAP and newAP.
        if (oldAP.equals(newAP)) {
            // nothing to do here. just the last seen has to be changed.
            if (newAP.lastSeen > oldAP.lastSeen) {
                oldAP.setLastSeen(newAP.lastSeen);
            }
            this.attachmentPoints =
                    new ArrayList<AttachmentPoint>(apMap.values());
            return false; // nothing to do here.
        }

        int x = deviceManager.apComparator.compare(oldAP, newAP);
        if (x < 0) {
            // newAP replaces oldAP.
            apMap.put(id, newAP);
            this.attachmentPoints =
                    new ArrayList<AttachmentPoint>(apMap.values());

            oldAPList = new ArrayList<AttachmentPoint>();
            if (oldAPs != null) oldAPList.addAll(oldAPs);
            oldAPList.add(oldAP);
            this.oldAPs = oldAPList;
            if (!topology.isInSameBroadcastDomain(oldAP.getSw(), oldAP.getPort(),
                                                  newAP.getSw(), newAP.getPort()))
                return true; // attachment point changed.
        } else  if (oldAPFlag) {
            // retain oldAP  as is.  Put the newAP in oldAPs for flagging
            // possible duplicates.
View Full Code Here

Examples of net.floodlightcontroller.topology.ITopologyService

        FloodlightModuleContext fmc = new FloodlightModuleContext();
        RestApiServer restApi = new RestApiServer();
        deviceService = new MockDeviceManager();
        FlowReconcileManager frm = new FlowReconcileManager();
        MockThreadPoolService tps = new MockThreadPoolService();
        ITopologyService topology = createMock(ITopologyService.class);
        vns = new VirtualNetworkFilter();
        DefaultEntityClassifier entityClassifier = new DefaultEntityClassifier();
        fmc.addService(IRestApiService.class, restApi);
        fmc.addService(IFloodlightProviderService.class, getMockFloodlightProvider());
        fmc.addService(IDeviceService.class, deviceService);
        fmc.addService(IFlowReconcileService.class, frm);
        fmc.addService(IThreadPoolService.class, tps);
        fmc.addService(IEntityClassifierService.class, entityClassifier);
        fmc.addService(ITopologyService.class, topology);
        fmc.addService(ISyncService.class, mockSyncService);
        tps.init(fmc);
        frm.init(fmc);
        deviceService.init(fmc);
        restApi.init(fmc);
        getMockFloodlightProvider().init(fmc);
        entityClassifier.init(fmc);
        tps.startUp(fmc);
        vns.init(fmc);
        frm.startUp(fmc);
        deviceService.startUp(fmc);
        restApi.startUp(fmc);
        getMockFloodlightProvider().startUp(fmc);
        vns.startUp(fmc);
        entityClassifier.startUp(fmc);

        topology.addListener(deviceService);
        expectLastCall().times(1);
        replay(topology);
        // Mock switches
        //fastWilcards mocked as this constant
        int fastWildcards =
View Full Code Here

Examples of net.floodlightcontroller.topology.ITopologyService

        MockFlexEntityClassifier flexClassifier =
                new MockFlexEntityClassifier();
        deviceManager.entityClassifier= flexClassifier;
        deviceManager.startUp(null);

        ITopologyService mockTopology = createMock(ITopologyService.class);
        deviceManager.topology = mockTopology;
        expect(mockTopology.isAttachmentPointPort(anyLong(),
                                                  anyShort())).
                                                  andReturn(true).anyTimes();
        expect(mockTopology.getL2DomainId(anyLong())).andReturn(1L).anyTimes();
        expect(mockTopology.isConsistent(EasyMock.anyLong(),
                                         EasyMock.anyShort(),
                                         EasyMock.anyLong(),
                                         EasyMock.anyShort()))
                                         .andReturn(false)
                                         .anyTimes();
        expect(mockTopology.isBroadcastDomainPort(EasyMock.anyLong(),
                                                  EasyMock.anyShort()))
                                                  .andReturn(false)
                                                  .anyTimes();
        replay(mockTopology);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.