Package org.rioproject.watch

Examples of org.rioproject.watch.ThresholdValues


public class MemInfoMonitorTest {
    @Test
    public void testParsing() {
        MemInfoMonitor memInfoMonitor = new MemInfoMonitor();
        memInfoMonitor.setID("System Memory");
        memInfoMonitor.setThresholdValues(new ThresholdValues(0, 1.0));
        memInfoMonitor.setMemInfoFile("src/test/resources/meminfo");
        SystemMemoryUtilization memoryUtilization = memInfoMonitor.getMeasuredResource();
        Assert.assertNotNull(memoryUtilization);
        System.out.println("Free:   "+memoryUtilization.getFree()+" MB");
        System.out.println("Active: "+memoryUtilization.getUsed()+" MB");
View Full Code Here


         *   type:              BREACHED, CLEARED, 0, 12345
         */

        final Object[] sources = new Object[] { new Object(), null};
        final Calculable[] calculables = new Calculable[] {new Calculable(), null};
        final ThresholdValues[] tvs = new ThresholdValues[] { new ThresholdValues(), null};
        final ThresholdType[] types = new ThresholdType[] {
                ThresholdType.BREACHED, ThresholdType.CLEARED};

        Object[][] combinations = ArrayUtils.combinations(new Object[][] {
                sources, calculables, tvs, types});
        for (Object[] combination : combinations) {
            Object source = combination[0];
            Calculable calculable = (Calculable) combination[1];
            ThresholdValues tv = (ThresholdValues) combination[2];
            ThresholdType type = (ThresholdType) combination[3];

            if (source == null) {
                try {
                    new ThresholdEvent(source, calculable, tv, type);
View Full Code Here

         */

        ThresholdEvent event = new ThresholdEvent(new Object());
        Assert.assertSame(null, event.getThresholdValues());

        ThresholdValues thv = new ThresholdValues();
        event.setThresholdValues(thv);
        Assert.assertSame(thv, event.getThresholdValues());
    }
View Full Code Here

         *   thresholdValues: valid object, null
         */

        ThresholdEvent event = new ThresholdEvent(new Object());

        ThresholdValues thv = new ThresholdValues();
        event.setThresholdValues(thv);
        Assert.assertSame(thv, event.getThresholdValues());

        event.setThresholdValues(null);
        Assert.assertSame(null, event.getThresholdValues());
View Full Code Here

        super(id, componentName, config);
        if(!isEnabled())
            return;
        setView(VIEW);
        try {          
            ThresholdValues tVals = (ThresholdValues)config.getEntry(getComponentName(),
                                                                     "thresholdValues",
                                                                     ThresholdValues.class,
                                                                     new ThresholdValues(0.0, 1.0));
            logger.trace("{} threshold values: {}", getId(), tVals.toString());
            setThresholdValues(tVals);
           
            ResourceCostModel rCostModel = (ResourceCostModel)config.getEntry(getComponentName(),
                                                                              "resourceCost",
                                                                              ResourceCostModel.class,
View Full Code Here

    protected String getID() {
        return id;
    }

    public void checkThreshold(Calculable calculable) {
        ThresholdValues thresholdValues = getThresholdValues();
        double value = calculable.getValue();
        if(thresholdCrossed) {
            if(direction == BREACHED_UPPER) {
                if(value < thresholdValues.getHighThreshold()) {
                    thresholdCrossed = false;
                    direction = CLEARED;
                    /* the next 2 lines produce a cleared event*/
                    thresholdValues.incThresholdClearedCount();
                    notifyListeners(calculable, ThresholdType.CLEARED);
                    checkLowThresholdBreach(calculable);
                } else {
                    checkHighThresholdBreach(calculable);
                }
            } else if(direction == BREACHED_LOWER) {
                if(value > thresholdValues.getLowThreshold()) {
                    thresholdCrossed = false;
                    direction = CLEARED;
                    thresholdValues.incThresholdClearedCount();
                    notifyListeners(calculable, ThresholdType.CLEARED);
                    checkHighThresholdBreach(calculable);
                } else {                   
                    checkLowThresholdBreach(calculable);
                }
View Full Code Here

        super(SystemWatchID.DISK_SPACE, COMPONENT, config);
        if(!isEnabled())
            return;
        setView(VIEW);
        try {
            ThresholdValues tVals =
                (ThresholdValues)config.getEntry(COMPONENT,
                                                 "thresholdValues",
                                                 ThresholdValues.class,
                                                 new ThresholdValues(0.0, 1.0));           
            setThresholdValues(tVals);
            ResourceCostModel rCostModel =
                (ResourceCostModel)config.getEntry(COMPONENT,
                                                   "resourceCost",
                                                   ResourceCostModel.class,
View Full Code Here

     * @param type The type of threshold, breached or cleared
     */
    protected void notifyListeners(Calculable calculable, ThresholdType type) {
        ThresholdListener[] tListeners = getThresholdListeners();
        logger.trace("{} Notify ThresholdListeners, number to notify: {}", getID(), tListeners.length);
        ThresholdValues thresholds = null;
        try {
            thresholds = (ThresholdValues)thresholdValues.clone();
        } catch (CloneNotSupportedException e) {
            //
        }
View Full Code Here

    }

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

    }

    @Test
    public void createAndVerifyCPUWithUpperThresholdBeingCrossedWithSigar() {
        CPU cpu = new CPU(EmptyConfiguration.INSTANCE);
        ThresholdValues tVals = new ThresholdValues(0.00, 0.05);
        cpu.setThresholdValues(tVals);
        SimpleThresholdListener l = new SimpleThresholdListener();
        cpu.start();
        cpu.checkValue();
        double utilization = cpu.getUtilization();
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.