Package org.rioproject.watch

Examples of org.rioproject.watch.ThresholdValues


    }

    @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

    }

    @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

            WatchInjector watchInjector = new WatchInjector(this, context);
            ThresholdWatch watch = (ThresholdWatch)watchInjector.inject(threadDeadlockDescriptor,
                                                                        threadDeadlockMonitor,
                                                                        getThreadDeadlockCalculable);
            watch.setThresholdValues(new ThresholdValues(0, 1));
            watch.addThresholdListener(new DeadlockedThreadPolicyHandler());
        } else {
            logger.info("Thread deadlock monitoring has been disabled. The " +
                        "configured thread deadlock check time was " +
                        "[{}]. To enable thread deadlock monitoring, the thread deadlock check " +
                        "time must be >= 1000 milliseconds.", threadDeadlockCheck);
        }
        try {
            serviceLimit = Config.getIntEntry(config, getConfigComponent(), "serviceLimit", 500, 0, Integer.MAX_VALUE);
        } catch(Exception e) {
            logger.warn("Exception getting serviceLimit, default to 500");
        }

        /* Get the ProxyPreparer for passed in OperationalStringManager
         * instances */
        operationalStringManagerPreparer = (ProxyPreparer)config.getEntry(getConfigComponent(),
                                                                          "operationalStringManagerPreparer",
                                                                          ProxyPreparer.class,
                                                                          new BasicProxyPreparer());
        /* Check for JMXConnection */
        addAttributes(JMXUtil.getJMXConnectionEntries());

        /* Add service UIs programmatically */
        addAttributes(getServiceUIs());

        /* Get the security policy to apply to loading services */
        String serviceSecurityPolicy = (String)config.getEntry(getConfigComponent(),
                                                               "serviceSecurityPolicy",
                                                               String.class,
                                                               null);
        if(serviceSecurityPolicy!=null)
            System.setProperty("rio.service.security.policy", serviceSecurityPolicy);

        /* Establish default operating environment */
        Environment.setupDefaultEnvironment();

        /* Setup persistent provisioning attributes */
        provisionEnabled = (Boolean) config.getEntry(getConfigComponent(), "provisionEnabled", Boolean.class, true);
        /*
         * The directory to provision external software to. This is the root
         * directory where software may be installed by ServiceBean instances which
         * require external software to be resident on compute resource the
         * Cybernode represents
         */
        String provisionRoot = Environment.setupProvisionRoot(provisionEnabled, config);
        if(provisionEnabled) {
            if(logger.isTraceEnabled())
                logger.trace("Software provisioning has been enabled, default provision root location is [{}]",
                             provisionRoot);
        }
        computeResource.setPersistentProvisioningRoot(provisionRoot);

        /* Setup the native library directory */
        String nativeLibDirectories = Environment.setupNativeLibraryDirectories(config);

        /* Ensure org.rioproject.system.native property is set. This will be used
         * by the org.rioproject.system.SystemCapabilities class */
        if(nativeLibDirectories!=null)
            System.setProperty(SystemCapabilities.NATIVE_LIBS, nativeLibDirectories);

        /* Initialize the ComputeResource */
        initializeComputeResource(computeResource);

        if(logger.isTraceEnabled()) {
            StringBuilder sb = new StringBuilder();
            sb.append("Service Limit : ").append(serviceLimit).append("\n");
            sb.append("System Capabilities\n");
            MeasurableCapability[] mCaps = computeResource.getMeasurableCapabilities();
            sb.append("MeasurableCapabilities : (").
               append(mCaps.length).
               append(")\n");
            for (MeasurableCapability mCap : mCaps) {
                sb.append("\t").append(mCap.getId()).append("\n");
                ThresholdValues tValues = mCap.getThresholdValues();
                sb.append("\t\tlow threshold  : ").append(tValues.getLowThreshold()).append("\n");
                sb.append("\t\thigh threshold : ").append(tValues.getHighThreshold()).append("\n");
                sb.append("\t\treport rate    : ").append(mCap.getPeriod()).append("\n");
                sb.append("\t\tsample size    : ");
                sb.append(mCap.getSampleSize()).append("\n");
            }
            PlatformCapability[] pCaps = computeResource.getPlatformCapabilities();
View Full Code Here

     *         identifier a null will be returned
     */
    public ThresholdValues getSystemThresholdValue(final String identifier) {
        if (identifier == null)
            throw new IllegalArgumentException("identifier is null");
        ThresholdValues tVals;
        synchronized (systemThresholds) {
            tVals = systemThresholds.get(identifier);
        }
        return tVals;
    }
View Full Code Here

         * Check each of the MeasuredResource objects
         */

        for (String systemThresholdID : systemThresholdIDs) {
            boolean supported = false;
            ThresholdValues systemThreshold = sla.getSystemRequirements().getSystemThresholdValue(systemThresholdID);
            if (systemThresholdID.equals(SystemRequirements.SYSTEM)) {
                double systemUtilization = systemThreshold.getHighThreshold();
                if (systemUtilization < resourceCapability.getUtilization()) {
                    String failureReason =
                        String.format("%s cannot meet system utilization requirement. Desired: %f, Actual: %f",
                                      getName(),
                                      systemUtilization,
                                      resourceCapability.getUtilization());
                    provisionRequest.addFailureReason(failureReason);
                    logger.debug(failureReason);
                    return (false);
                } else {
                    supported = true;
                    logger.debug("[System] utilization requirement met. Desired {}, Actual {}",
                                 systemUtilization, resourceCapability.getUtilization());
                }
            }
            /*
             * Iterate through all resource MeasuredResource objects and see if
             * any of them supports the current MeasuredResource. If none are
             * found, then we don't have a match
             */
            for (MeasuredResource mRes : measured) {
                if (mRes.getIdentifier().equals(systemThresholdID)) {
                    if (mRes.evaluate(systemThreshold)) {
                        supported = true;
                        logger.debug("{} meets [{}] utilization requirement. Desired Low: {}, High: {}, Actual: {}",getName(),
                                     getName(),
                                     systemThresholdID,
                                     systemThreshold.getLowThreshold(),
                                     systemThreshold.getHighThreshold(),
                                     mRes.getValue());
                        break;
                    } else {
                        String failureReason =
                            String.format("%s cannot meet [%s], utilization requirement. Desired Low: %f, High: %f, Actual: %f",
                                          getName(),
                                          systemThresholdID,
                                          systemThreshold.getLowThreshold(),
                                          systemThreshold.getHighThreshold(),
                                          mRes.getValue());
                        provisionRequest.addFailureReason(failureReason);
                        logger.debug(failureReason);
                    }
                }
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.