Package org.rioproject.watch

Examples of org.rioproject.watch.ThresholdValues


                            StringBuilder buff = new StringBuilder();
                            for (String id : ids) {
                                if (buff.length() > 0) {
                                    buff.append(", ");
                                }
                                ThresholdValues tVal = s.getSystemThresholdValue(id);
                                String val = String.format("ID: %s, High: %s, Low: %s",
                                                           id,
                                                           tVal.getHighThreshold(),
                                                           tVal.getLowThreshold());
                                sysRequirements.add(val);
                                buff.append("[").append(val).append("]");
                            }
                            for (SystemComponent systemComponent : systemComponents) {
                                if (buff.length() > 0) {
View Full Code Here


        double systemThreshold = (Double)config.getEntry(QOS_COMPONENT,
                                                         "systemThreshold",
                                                         double.class,
                                                         defaultSystemThreshold);
        sla.getSystemRequirements().addSystemThreshold(SystemRequirements.SYSTEM,
                                                       new ThresholdValues(0.0, systemThreshold));

        ServiceElement sElem = new ServiceElement(ServiceElement.ProvisionType.EXTERNAL,
                                                  sbConfig,
                                                  sla,
                                                  new ClassBundle[]{exportBundle});
View Full Code Here

        if(!isEnabled())
            return;
        setView(VIEW);
        logger.trace("Creating [{}]", id);
        try {
            ThresholdValues defaultThresholdVals;
            int numCPUs = Runtime.getRuntime().availableProcessors();
            defaultThresholdVals = new ThresholdValues(0.0, numCPUs);
            ThresholdValues tVals =
                (ThresholdValues)config.getEntry(configComponent,
                                                 "thresholdValues",
                                                 ThresholdValues.class,
                                                 defaultThresholdVals);
            setThresholdValues(tVals);
View Full Code Here

    }

    @Test
    public void createAndVerifyDiskSpaceWithLowerThresholdBeingCrossed() {
        DiskSpace diskSpace = new DiskSpace(EmptyConfiguration.INSTANCE);
        ThresholdValues tVals = new ThresholdValues(0.30, 0.90);
        diskSpace.setThresholdValues(tVals);
        SimpleThresholdListener l = new SimpleThresholdListener();
        diskSpace.start();
        double utilization = diskSpace.getUtilization();
        Assert.assertTrue("Utilization should be > 0", utilization>0);
View Full Code Here

    }

    @Test
    public void createAndVerifyDiskSpaceWithUpperThresholdBeingCrossed() {
        DiskSpace diskSpace = new DiskSpace(EmptyConfiguration.INSTANCE);
        ThresholdValues tVals = new ThresholdValues(0.00, 0.05);
        diskSpace.setThresholdValues(tVals);
        SimpleThresholdListener l = new SimpleThresholdListener();
        diskSpace.start();
        double utilization = diskSpace.getUtilization();
        Assert.assertTrue("Utilization should be > 0", utilization>0);
View Full Code Here

    }

    @Test
    public void createAndVerifyDiskSpaceWithLowerThresholdBeingCrossed() {
        DiskSpace diskSpace = new DiskSpace(EmptyConfiguration.INSTANCE);
        ThresholdValues tVals = new ThresholdValues(0.30, 0.90);
        diskSpace.setThresholdValues(tVals);
        SimpleThresholdListener l = new SimpleThresholdListener();
        diskSpace.start();
        if(!System.getProperty("os.name").startsWith("Windows")) {
            double utilization = diskSpace.getUtilization();
View Full Code Here

    }

    @Test
    public void createAndVerifyDiskSpaceWithUpperThresholdBeingCrossed() {
        DiskSpace diskSpace = new DiskSpace(EmptyConfiguration.INSTANCE);
        ThresholdValues tVals = new ThresholdValues(0.00, 0.05);
        diskSpace.setThresholdValues(tVals);
        SimpleThresholdListener l = new SimpleThresholdListener();
        diskSpace.start();
        if(!System.getProperty("os.name").startsWith("Windows")) {
            double utilization = diskSpace.getUtilization();
View Full Code Here

     */
    @Test
    public void testAddRemoveThresholdListener() throws Exception {
        String id = "watch1";
        ThresholdWatch watch = (ThresholdWatch) construct1(id);
        watch.setThresholdValues(new ThresholdValues(0, 1));

        // Test adding multiple listeners, with several checkpoints
        final int[] checkpoints = new int[]{0, 1, 10, 100};
        List<LoggingThresholdListener> lnrs = new ArrayList<LoggingThresholdListener>();
        List<StringBuffer> logs = new ArrayList<StringBuffer>();
View Full Code Here

     */
    @Test
    public void testAddThresholdListenerAfterEvent() throws Exception {
        String id = "watch";
        ThresholdWatch watch = (ThresholdWatch) construct1(id);
        watch.setThresholdValues(new ThresholdValues(0, 1));
        StringBuffer log = new StringBuffer();
        LoggingThresholdListener lnr = new LoggingThresholdListener(id, log);
        watch.addWatchRecord(new Calculable(id, 0.5));
        watch.addWatchRecord(new Calculable(id, -0.1));
        watch.addWatchRecord(new Calculable(id, 1.1));
View Full Code Here

    public void testGetSetThresholdValues() throws Exception {

        // Getting default value
        String id = "watch";
        ThresholdWatch watch = (ThresholdWatch) construct1(id);
        ThresholdValues values = watch.getThresholdValues();
        Assert.assertTrue(Double.isNaN(values.getLowThreshold()));
        Assert.assertTrue(Double.isNaN(values.getHighThreshold()));

        // "set" followed by "get"
        ThresholdValues newValues = new ThresholdValues(7.13, 13.7);
        watch.setThresholdValues(newValues);
        values = watch.getThresholdValues();
        Assert.assertEquals(newValues.getLowThreshold(),
                            values.getLowThreshold(), 0);
        Assert.assertEquals(newValues.getHighThreshold(),
                            values.getHighThreshold(), 0);
        // Check that the watch holds the same object (at the time
        // of writing this test it does)
        Assert.assertSame(newValues, values);
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.