Package org.rioproject.impl.system.measurable

Examples of org.rioproject.impl.system.measurable.MeasurableCapability


            throw new IllegalArgumentException("config is null");
       
        List<MeasurableCapability> measurables = new ArrayList<MeasurableCapability>();
        /* Create the Memory MeasurableCapability. This will measure memory
         * for the JVM */
        MeasurableCapability memory =  new Memory(config);
        if(memory.isEnabled())
            measurables.add(memory);

        /* If SIGAR is available, create a Memory MeasurableCapability for the
         * physical machine as well */
        boolean haveSigar = SigarHelper.sigarAvailable();
        if(haveSigar) {
            MeasurableCapability systemMemory = new SystemMemory(config);
            if(systemMemory.isEnabled())
                measurables.add(systemMemory);

        }

        /* Load memory pool management */
        try {
            MeasurableCapability[] pools =
                (MeasurableCapability[])config.getEntry(COMPONENT+".memory.pool",
                                                        "memoryPools",
                                                        MeasurableCapability[].class,
                                                        null,
                                                        config);
            if(pools!=null)
                measurables.addAll(Arrays.asList(pools));
        } catch(ConfigurationException e) {
            logger.warn("Loading CPU MeasurableCapability", e);
        }

        /* Create the CPU MeasurableCapability */
        MeasurableCapability cpu = new CPU(config);
        if(cpu.isEnabled())
            measurables.add(cpu);

        MeasurableCapability jvmCpu = new CPU(config, SystemWatchID.PROC_CPU, true);
        if(jvmCpu.isEnabled())
            measurables.add(jvmCpu);


        /*
         * Load the DiskSpace capability only if we have SIGAR or if SIGAR is
         * not available and not running on Windows
         */
        MeasurableCapability diskSpace = null;
        if(haveSigar) {
            diskSpace = getDiskSpace(config);
        } else if(!OperatingSystemType.isWindows()) {
            diskSpace = getDiskSpace(config);
        }
        if(diskSpace!=null && diskSpace.isEnabled())
            measurables.add(diskSpace);

        /*
         * Load any additional MeasurableCapability instances that have been
         * configured
 
View Full Code Here


                identifier = wds[0].getName();
            }
            SLAPolicyHandler handler = null;
            ServiceElement elem = context.getServiceElement();
            /* Check if the SLA matches a MeasurableCapability.  */
            MeasurableCapability mCap = getMeasurableCapability(identifier);
            if (mCap != null) {
                logger.trace("[{}] SLA [{}] correlates to a MeasurableCapability", elem.getName(), identifier);
                try {
                    /* Load the SLA PolicyHandler and set attributes */
                    handler = createSLAPolicyHandler(sla, null);

                    ThresholdManager tMgr = new BoundedThresholdManager(mCap.getId());
                    tMgr.setThresholdValues(sla);
                    handler.setThresholdManager(tMgr);
                    mCap.addSecondaryThresholdManager(tMgr);
                    thresholdManagerReg.put(tMgr, mCap);
                    logger.trace("[{}] SLA ID [{}], associated to MeasurableCapability={}, SLAPolicyHandler={}",
                                 elem.getName(), identifier, mCap.getClass().getName(), handler.getClass().getName());
                } catch (Exception e) {
                    logger.warn("Creating SLAPolicyHandler for system SLA [{}]", sla.getIdentifier(), e);
                }

            /* Check if the SLA matches the ThreadDeadlockMonitor. */
 
View Full Code Here

    private void removeSLAPolicyHandler(final SLAPolicyHandler slaPolicyHandler) {
        slaPolicyHandlers.remove(slaPolicyHandler);
        slaPolicyHandler.disconnect();
        context.getWatchRegistry().removeThresholdListener(slaPolicyHandler.getID(), slaPolicyHandler);
        ThresholdManager tMgr = slaPolicyHandler.getThresholdManager();
        MeasurableCapability mCap = thresholdManagerReg.remove(tMgr);
        if(mCap != null) {
            mCap.removeSecondaryThresholdManager(tMgr);
        }
    }
View Full Code Here

    /*
     * Load the DiskSpace measurable capability
     */
    private MeasurableCapability getDiskSpace(Configuration config) {
        MeasurableCapability diskSpace = null;
        try {
            diskSpace = (MeasurableCapability)config.getEntry(COMPONENT,
                                                              "disk",
                                                              MeasurableCapability.class,
                                                              new DiskSpace(config),
View Full Code Here

    }

    private MeasurableCapability[] loadMeasurables(final Configuration config) {
        List<MeasurableCapability> measurables = new ArrayList<MeasurableCapability>();
        /* Create the Memory MeasurableCapability */
        MeasurableCapability memory = new Memory(config);
        if(memory.isEnabled())
            measurables.add(memory);

        try{
            MeasurableCapability cpu = new CPU(config, SystemWatchID.PROC_CPU, true);
            if(cpu.isEnabled())
                measurables.add(cpu);
        } catch (RuntimeException e) {
            logger.warn("JVM CPU monitoring not supported");
        }
        return measurables.toArray(new MeasurableCapability[measurables.size()]);
View Full Code Here

        if(downloadRecords!=null) {
            for (DownloadRecord downloadRecord : downloadRecords) {
                int size = downloadRecord.getDownloadedSize();
                if (downloadRecord.unarchived())
                    size += downloadRecord.getExtractedSize();
                MeasurableCapability mCap = computeResource.getMeasurableCapability("DiskSpace");
                if (mCap != null)
                    costList.add(mCap.calculateResourceCost(new Integer(size).doubleValue(), duration));
                else {
                    if (logger.isDebugEnabled()) {
                        logger.warn("DiskSpace capability not found, cannot create ResourceCost");
                    }
                }
View Full Code Here

TOP

Related Classes of org.rioproject.impl.system.measurable.MeasurableCapability

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.