Package net.floodlightcontroller.counter

Examples of net.floodlightcontroller.counter.SimpleCounter


       
        expect(r1.reconcileFlows((ArrayList<OFMatchReconcile>)anyObject())).
                  andThrow(new RuntimeException("This is NOT an error! " +
                            "We are testing exception catching."));
       
        SimpleCounter cnt = (SimpleCounter)SimpleCounter.createCounter(
                            new Date(),
                            CounterType.LONG);
        cnt.increment();
        expect(counterStore.getCounter(
                flowReconcileMgr.controllerPktInCounterName))
                .andReturn(cnt)
                .anyTimes();
       
View Full Code Here


        internalTestGetPktInRate(CounterType.DOUBLE);
    }
   
    protected void internalTestGetPktInRate(CounterType type) {
        Date currentTime = new Date();
        SimpleCounter newCnt = (SimpleCounter)SimpleCounter.createCounter(
                                currentTime, type);
        newCnt.increment(currentTime, 1);
   
        // Set the lastCounter time in the future of the current time
        Date lastCounterTime = new Date(currentTime.getTime() + 1000);
        flowReconcileMgr.lastPacketInCounter =
                (SimpleCounter)SimpleCounter.createCounter(
                    lastCounterTime, type);
        flowReconcileMgr.lastPacketInCounter.increment(lastCounterTime, 1);
   
        assertEquals(FlowReconcileManager.MAX_SYSTEM_LOAD_PER_SECOND,
                flowReconcileMgr.getPktInRate(newCnt, new Date()));
   
        // Verify the rate == 0 time difference is zero.
        lastCounterTime = new Date(currentTime.getTime() - 1000);
        flowReconcileMgr.lastPacketInCounter.increment(lastCounterTime, 1);
        assertEquals(0, flowReconcileMgr.getPktInRate(newCnt, lastCounterTime));
   
        /** verify the computation is correct.
         *  new = 2000, old = 1000, Tdiff = 1 second.
         *  rate should be 1000/second
         */
        newCnt = (SimpleCounter)SimpleCounter.createCounter(
                currentTime, type);
        newCnt.increment(currentTime, 2000);
   
        lastCounterTime = new Date(currentTime.getTime() - 1000);
        flowReconcileMgr.lastPacketInCounter =
                (SimpleCounter)SimpleCounter.createCounter(
                    lastCounterTime, type);
        flowReconcileMgr.lastPacketInCounter.increment(lastCounterTime, 1000);
        assertEquals(1000, flowReconcileMgr.getPktInRate(newCnt, currentTime));
   
        /** verify the computation is correct.
         *  new = 2,000,000, old = 1,000,000, Tdiff = 2 second.
         *  rate should be 1000/second
         */
        newCnt = (SimpleCounter)SimpleCounter.createCounter(
                currentTime, type);
        newCnt.increment(currentTime, 2000000);
   
        lastCounterTime = new Date(currentTime.getTime() - 2000);
        flowReconcileMgr.lastPacketInCounter =
                (SimpleCounter)SimpleCounter.createCounter(
                    lastCounterTime, type);
View Full Code Here

        verify(counterStore);
   
        /** Verify the initial state, when lastPacketInCounter is null */
        reset(counterStore);
        Date currentTime = new Date();
        SimpleCounter newCnt = (SimpleCounter)SimpleCounter.createCounter(
                        currentTime, CounterType.LONG);
   
        expect(counterStore.getCounter(
            flowReconcileMgr.controllerPktInCounterName))
        .andReturn(newCnt)
        .times(1);
        long initPktInCount = 1000;
        newCnt.increment(currentTime, initPktInCount);
   
        replay(counterStore);
        assertEquals(minFlows, flowReconcileMgr.getCurrentCapacity());
        verify(counterStore);
   
        /** Now the lastPacketInCounter has been set.
         *  lastCounter = 1,000 and newCounter = 3,000, t = 1 second
         *  packetInRate = 2,000/sec.
         *  capacity should be 10k - 2k = 8k
         */
        reset(counterStore);
        newCnt = (SimpleCounter)SimpleCounter.createCounter(
                    currentTime, CounterType.LONG);
        currentTime = new Date(currentTime.getTime() + 200);
        long nextPktInCount = 3000;
        newCnt.increment(currentTime, nextPktInCount);
   
        expect(counterStore.getCounter(
                flowReconcileMgr.controllerPktInCounterName))
        .andReturn(newCnt)
        .times(1);
View Full Code Here

                }
                return Command.STOP;
            }
        }).times(1);
       
        SimpleCounter cnt = (SimpleCounter)SimpleCounter.createCounter(
                            new Date(),
                            CounterType.LONG);
        cnt.increment();
        expect(counterStore.getCounter(
                flowReconcileMgr.controllerPktInCounterName))
                .andReturn(cnt)
                .anyTimes();
       
View Full Code Here

        // Disable the reconcile thread so that the queue won't be emptied.
        flowQueueTest(false);
   
        // Enable the reconcile thread. The queue should be empty.
        Date currentTime = new Date();
        SimpleCounter newCnt = (SimpleCounter)SimpleCounter.createCounter(
                    currentTime, CounterType.LONG);
   
        expect(counterStore.getCounter(
                    flowReconcileMgr.controllerPktInCounterName))
        .andReturn(newCnt)
        .anyTimes();
        long initPktInCount = 10000;
        newCnt.increment(currentTime, initPktInCount);
   
        IFlowReconcileListener r1 =
                EasyMock.createNiceMock(IFlowReconcileListener.class);
       
        expect(r1.getName()).andReturn("r1").anyTimes();
View Full Code Here

TOP

Related Classes of net.floodlightcontroller.counter.SimpleCounter

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.