Package org.rioproject.system.measurable.memory

Examples of org.rioproject.system.measurable.memory.ProcessMemoryUtilization


            value = formatPercent(MeasuredValueHelper.getMeasuredValue(SystemWatchID.JVM_MEMORY, cru));
            //ProcessMemoryUtilization mem = cru.getProcessMemoryUtilization();
            //value = (mem==null?"?" : format(mem.getUsedHeap()));

        } else if(cName.equals(Constants.UTIL_HEAP_MEM_JVM)) {
            ProcessMemoryUtilization mem = cru.getProcessMemoryUtilization();
            //value = (mem==null?"?" : format(mem.getCommittedHeap())+" MB");
            value = (mem==null?"?" : format(mem.getUsedHeap()," MB"));

        } else if(cName.equals(Constants.UTIL_HEAP_MEM_AVAIL)) {
            ProcessMemoryUtilization mem = cru.getProcessMemoryUtilization();
            //value = (mem==null?"?" : format(mem.getCommittedHeap())+" MB");
            value = (mem==null?"?" : format(mem.getCommittedHeap(), " MB"));

        } else if(cName.equals(Constants.UTIL_REAL_MEM_PROC)) {
            ProcessMemoryUtilization mem = cru.getProcessMemoryUtilization();
            value = (mem==null?"?" : format(mem.getResident(), " MB"));
        }
        if(isAThresholdColumn(cName)) {
            return getThresholdLabel(cName, value, cru);
        }
        return (value);
View Full Code Here


        } else if (cName.equals(Constants.UTIL_PERCENT_HEAP_JVM)) {
            value = getMeasuredValue("Memory", cru);

        } else if (cName.equals(Constants.UTIL_HEAP_MEM_JVM)) {
            ProcessMemoryUtilization mem = cru.getProcessMemoryUtilization();
            value = (mem == null ? 0 : mem.getUsedHeap());

        } else if (cName.equals(Constants.UTIL_HEAP_MEM_AVAIL)) {
            ProcessMemoryUtilization mem = cru.getProcessMemoryUtilization();
            value = (mem == null ? 0 : mem.getCommittedHeap());

        } else if (cName.equals(Constants.UTIL_REAL_MEM_PROC)) {
            ProcessMemoryUtilization mem = cru.getProcessMemoryUtilization();
            value = (mem == null ? 0 : mem.getResident());
        }

        return value;
    }
View Full Code Here

    }

    public MeasuredResource getMeasuredResource() {
        //if (memBean == null)
        //    memBean = ManagementFactory.getMemoryMXBean();
        ProcessMemoryUtilization memoryUtilization;
        MemoryUsage heapUsage = null;
        MemoryUsage nonHeapUsage = null;
        double utilization = 0;

        if(memBean!=null) {
            heapUsage = memBean.getHeapMemoryUsage();
            nonHeapUsage = memBean.getNonHeapMemoryUsage();
            utilization = (double)heapUsage.getUsed()/(double)heapUsage.getMax();
        }
        if (sigar!=null) {
            try {
                double vSize = sigar.getProcessVirtualMemorySize(pid)/MB;
                double resident = sigar.getProcessResidentMemory(pid);
                double shared = sigar.getProcessSharedMemory(pid);
                vSize = (vSize>0?vSize/MB:vSize);
                resident = (resident>0?resident/MB:resident);
                shared = (shared>0?shared/MB:shared);
                if(logger.isTraceEnabled()) {
                    NumberFormat nf = NumberFormat.getInstance();
                    StringBuilder builder = new StringBuilder();
                    nf.setMaximumFractionDigits(2);
                    builder.append("\n");
                    builder.append("VSize              = ").append(nf.format(vSize)).append(" MB\n");
                    builder.append("Resident           = ").append(nf.format(resident)).append(" MB\n");
                    builder.append("Shared             = ").append(shared).append("\n");
                    builder.append("Heap Init          = ").append(nf.format(heapUsage.getInit()/MB)).append(" MB\n");
                    builder.append("Heap Used          = ").append(nf.format(heapUsage.getUsed()/MB)).append(" MB\n");
                    builder.append("Heap Max           = ").append(nf.format(heapUsage.getMax()/MB)).append(" MB\n");
                    builder.append("Heap Committed     = ").append(nf.format(heapUsage.getMax()/MB)).append(" MB\n");
                    builder.append("Non Heap Init      = ").append(nf.format(nonHeapUsage.getInit()/MB)).append(" MB\n");
                    builder.append("Non Heap Used      = ").append(nf.format(nonHeapUsage.getUsed()/MB)).append(" MB\n");
                    builder.append("Non Heap Max       = ").append(nf.format(nonHeapUsage.getMax()/MB)).append(" MB\n");
                    builder.append("Non Heap Committed = ").append(nf.format(nonHeapUsage.getMax()/MB)).append(" MB");
                    logger.trace(builder.toString());
                }
                if(heapUsage!=null) {
                    memoryUtilization = new ProcessMemoryUtilization(id,
                                                                     utilization,
                                                                     vSize,
                                                                     resident,
                                                                     shared,
                                                                     heapUsage.getInit()/MB,
                                                                     heapUsage.getUsed()/MB,
                                                                     heapUsage.getMax()/MB,
                                                                     heapUsage.getCommitted()/MB,
                                                                     nonHeapUsage.getInit()/MB,
                                                                     nonHeapUsage.getUsed()/MB,
                                                                     nonHeapUsage.getMax()/MB,
                                                                     nonHeapUsage.getCommitted()/MB,
                                                                     tVals);
                } else {
                    memoryUtilization = new ProcessMemoryUtilization(id, utilization, vSize, resident, shared, tVals);
                }

            } catch (Exception e) {
                logger.warn("SIGAR exception getting Process Memory", e);
                memoryUtilization = getJvmMemoryUtilization(utilization, heapUsage, nonHeapUsage);
View Full Code Here

    }

    private ProcessMemoryUtilization getJvmMemoryUtilization(double utilization,
                                                             MemoryUsage heapUsage,
                                                             MemoryUsage nonHeapUsage) {
        return new ProcessMemoryUtilization(id,
                                            utilization,
                                            getInit(heapUsage),
                                            getUsed(heapUsage),
                                            getMax(heapUsage),
                                            getCommitted(heapUsage),
View Full Code Here

     * @return The latest
     * {@link org.rioproject.system.measurable.memory.ProcessMemoryUtilization}
     * taken from the compute resource. If not available, return null.
     */
    public ProcessMemoryUtilization getProcessMemoryUtilization() {
        ProcessMemoryUtilization mem = null;
        for (MeasuredResource m : mRes) {
            if(m instanceof ProcessMemoryUtilization) {
                mem = (ProcessMemoryUtilization)m;
                break;
            }
View Full Code Here

TOP

Related Classes of org.rioproject.system.measurable.memory.ProcessMemoryUtilization

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.