Package org.rioproject.watch

Examples of org.rioproject.watch.ThresholdValues


            lowerTh = -1;
        }
        if (upper) {
            upperTh = 1;
        }
        ThresholdValues thValues = new ThresholdValues(lowerTh, upperTh);
        watch.setThresholdValues(thValues);
        String suffix = "," + thValues.getLowThreshold()
                        + "," + thValues.getHighThreshold() + ")";

        // The idea is to test the most important situations
        watch.addWatchRecord(new Calculable(id, 0));                // 0
        checkLog(log, "");
        watch.addWatchRecord(new Calculable(id, -1));               // -1
View Full Code Here


public class BoundedThresholdManagerTest {

    @Test
    public void testThresholdCrossedAscending() throws Exception {
        BoundedThresholdManager thresholdManager = new BoundedThresholdManager("foo");
        ThresholdValues thresholdValues = new ThresholdValues(0, 5);
        thresholdManager.setThresholdValues(thresholdValues);
        MyThresholdListener listener = new MyThresholdListener();
        thresholdManager.addThresholdListener(listener);
        for(Calculable calculable : makeCalculables(20)) {
            thresholdManager.checkThreshold(calculable);
View Full Code Here

    }

    @Test
    public void testThresholdCrossedDescending() throws Exception {
        BoundedThresholdManager thresholdManager = new BoundedThresholdManager("foo");
        ThresholdValues thresholdValues = new ThresholdValues(30, 50);
        thresholdManager.setThresholdValues(thresholdValues);
        MyThresholdListener listener = new MyThresholdListener();
        thresholdManager.addThresholdListener(listener);
        List<Calculable> calculables = makeCalculables(50);
        Collections.reverse(calculables);
View Full Code Here

    }

    @Test
    public void testThresholdCrossedAscendingWithStep() throws Exception {
        BoundedThresholdManager thresholdManager = new BoundedThresholdManager("foo");
        ThresholdValues thresholdValues = new ThresholdValues(0, 5, 2);
        thresholdManager.setThresholdValues(thresholdValues);
        MyThresholdListener listener = new MyThresholdListener();
        thresholdManager.addThresholdListener(listener);
        /*
         * With a step of 2, the high threshold notifications will begin at 6. So:
View Full Code Here

    }

    @Test
    public void testThresholdCrossedDescendingWithStep() throws Exception {
        BoundedThresholdManager thresholdManager = new BoundedThresholdManager("foo");
        ThresholdValues thresholdValues = new ThresholdValues(30, 50, 2);
        thresholdManager.setThresholdValues(thresholdValues);
        MyThresholdListener listener = new MyThresholdListener();
        thresholdManager.addThresholdListener(listener);
        /*
         * With a step of 2, the low threshold notifications will begin at 29. So:
View Full Code Here

    }

    @Test
    public void testThresholdCrossedMixedBagWithStep() throws Exception {
        BoundedThresholdManager thresholdManager = new BoundedThresholdManager("foo");
        ThresholdValues thresholdValues = new ThresholdValues(30, 50, 2.2);
        thresholdManager.setThresholdValues(thresholdValues);
        MyThresholdListener listener = new MyThresholdListener();
        thresholdManager.addThresholdListener(listener);

        List<Calculable> calculables = new LinkedList<Calculable>();
View Full Code Here

    }

    @Test
    public void testThresholdCrossedMixedBagOfPercentsWithStep() throws Exception {
        BoundedThresholdManager thresholdManager = new BoundedThresholdManager("foo");
        ThresholdValues thresholdValues = new ThresholdValues(.30, .50, .1);
        thresholdManager.setThresholdValues(thresholdValues);
        MyThresholdListener listener = new MyThresholdListener();
        thresholdManager.addThresholdListener(listener);

        List<Calculable> calculables = new LinkedList<Calculable>();
View Full Code Here

    }

    @Test
    public void createAndVerifyMemoryWithLowerThresholdBeingCrossed() {
        Memory mem = new Memory(EmptyConfiguration.INSTANCE);
        ThresholdValues tVals = new ThresholdValues(0.30, 0.90);
        mem.setThresholdValues(tVals);
        SimpleThresholdListener l = new SimpleThresholdListener();
        mem.start();
        mem.checkValue();
        double utilization = mem.getUtilization();
View Full Code Here

    }

    @Test
    public void createAndVerifyMemoryWithUpperThresholdBeingCrossed() {
        Memory mem = new Memory(EmptyConfiguration.INSTANCE);
        ThresholdValues tVals = new ThresholdValues(0.00, 0.05);
        mem.setThresholdValues(tVals);
        SimpleThresholdListener l = new SimpleThresholdListener();
        mem.start();
        mem.checkValue();
        double utilization = mem.getUtilization();
View Full Code Here

    }

    @Test
    public void createAndVerifyMemoryClass() {
        String poolName = "Perm Gen";
        MemoryPool mem = new MemoryPool(poolName, EmptyConfiguration.INSTANCE, new ThresholdValues(0.0, 0.80));
        SimpleThresholdListener l = new SimpleThresholdListener();
        mem.start();
        mem.checkValue();
        double utilization = mem.getUtilization();
        Assert.assertTrue("Utilization should be > 0, got: " + utilization, utilization > 0);
View Full Code Here

TOP

Related Classes of org.rioproject.watch.ThresholdValues

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.