Examples of OperatingSystemMXBean


Examples of com.sun.management.OperatingSystemMXBean

    // 剩余内存
    long freeMemory = Runtime.getRuntime().freeMemory() / kb;
    // 最大可使用内存
    long maxMemory = Runtime.getRuntime().maxMemory() / kb;

    OperatingSystemMXBean osmxb = (OperatingSystemMXBean) ManagementFactory
        .getOperatingSystemMXBean();

    // 操作系统
    String osName = System.getProperty("os.name");
    // 总的物理内存
    long totalMemorySize = osmxb.getTotalPhysicalMemorySize() / kb;
    // 剩余的物理内存
    long freePhysicalMemorySize = osmxb.getFreePhysicalMemorySize() / kb;
    // 已使用的物理内存
    long usedMemory = (osmxb.getTotalPhysicalMemorySize() - osmxb
        .getFreePhysicalMemorySize()) / kb;

    // 获得线程总数
    ThreadGroup parentThread;
    for (parentThread = Thread.currentThread().getThreadGroup(); parentThread
View Full Code Here

Examples of com.sun.management.OperatingSystemMXBean

     * @since 1.15.0.4
     */
    public static long getSuggestedMaxJvmHeapSize() {
        try {
            Object bean = ManagementFactory.getOperatingSystemMXBean();
            OperatingSystemMXBean osMxBean = (OperatingSystemMXBean) bean;
            long systemMemoryBytes = osMxBean.getTotalPhysicalMemorySize();
            long systemMemoryMegabytes = systemMemoryBytes >> 20;
            long halfOfMemory = systemMemoryMegabytes / 2;
            long result = halfOfMemory;

            // Systems today may have a lot of memory - 4 or 6GB - and half
View Full Code Here

Examples of java.lang.management.OperatingSystemMXBean

    private static void runBenchmarkWithZipfDistribution1(final boolean useRWlock, final ILock lock, final String filename, final int threads, final int capacity, final int round, final double scanPercentage, final int scanLength, final ReplacementAlgorithm algo, final int pageSize, final long[] dist)
            throws IOException, InterruptedException, ServiceException {
        final ConcurrentPluggableCache<Long, byte[]> cache = new ConcurrentPluggableCache<Long, byte[]>(capacity, ConcurrentCollectionProvider.<ICacheEntry<Long, byte[]>> createConcurrentMapLong(capacity));
        cache.setReplacementPolicy(ReplacementPolicySelector.<Long, byte[]> provide(capacity, algo));

        OperatingSystemMXBean mx = ManagementFactory.getOperatingSystemMXBean();
        final com.sun.management.OperatingSystemMXBean sunmx = (com.sun.management.OperatingSystemMXBean) mx;
        long startCpuTime = sunmx.getProcessCpuTime();

        final double percent = scanPercentage / 100d;
        StopWatch watchdog = new StopWatch("nthreads: " + threads + ", capacity: " + capacity
View Full Code Here

Examples of java.lang.management.OperatingSystemMXBean

    private static void runBenchmarkWithZipfDistribution1(final boolean useRWlock, final ILock lock, final String filename, final int threads, final int capacity, final int round, final double scanPercentage, final int scanLength, final ReplacementAlgorithm algo, final int pageSize, final long[] dist)
            throws IOException, InterruptedException, ServiceException {
        final ConcurrentPluggableCache<Long, byte[]> cache = new ConcurrentPluggableCache<Long, byte[]>(capacity, ConcurrentCollectionProvider.<ICacheEntry<Long, byte[]>> createConcurrentMapLong(capacity));
        cache.setReplacementPolicy(ReplacementPolicySelector.<Long, byte[]> provide(capacity, algo));

        OperatingSystemMXBean mx = ManagementFactory.getOperatingSystemMXBean();
        final com.sun.management.OperatingSystemMXBean sunmx = (com.sun.management.OperatingSystemMXBean) mx;
        long startCpuTime = sunmx.getProcessCpuTime();

        final double percent = scanPercentage / 100d;
        StopWatch watchdog = new StopWatch("nthreads: " + threads + ", capacity: " + capacity
View Full Code Here

Examples of java.lang.management.OperatingSystemMXBean

    private static void runBenchmarkWithZipfDistribution1(final boolean useRWlock, final ILock lock, final String filename, final int threads, final int capacity, final int round, final double scanPercentage, final int scanLength, final ReplacementAlgorithm algo, final int pageSize, final long[] dist)
            throws IOException, InterruptedException, ServiceException {
        final ConcurrentPluggableCache<Long, byte[]> cache = new ConcurrentPluggableCache<Long, byte[]>(capacity, ConcurrentCollectionProvider.<ICacheEntry<Long, byte[]>> createConcurrentMapLong(capacity));
        cache.setReplacementPolicy(ReplacementPolicySelector.<Long, byte[]> provide(capacity, algo));

        OperatingSystemMXBean mx = ManagementFactory.getOperatingSystemMXBean();
        final com.sun.management.OperatingSystemMXBean sunmx = (com.sun.management.OperatingSystemMXBean) mx;
        long startCpuTime = sunmx.getProcessCpuTime();

        final double percent = scanPercentage / 100d;
        StopWatch watchdog = new StopWatch("nthreads: " + threads + ", capacity: " + capacity
View Full Code Here

Examples of java.lang.management.OperatingSystemMXBean

    }

    private static void initializeSunJdk() {
        boolean useSunMx = false;
        if(IS_SUN_VM) {
            OperatingSystemMXBean mx = ManagementFactory.getOperatingSystemMXBean();
            com.sun.management.OperatingSystemMXBean sunmx = (com.sun.management.OperatingSystemMXBean) mx;
            long testval = sunmx.getProcessCpuTime();
            if(testval != -1L) {
                useSunMx = true;
            }
View Full Code Here

Examples of java.lang.management.OperatingSystemMXBean

                LogFactory.getLog(SystemUtils.class).error("Failed to obtain CPU load via Hyperic Sigar", e);
                return -1d;
            }
            return cpuload.doubleValue();
        } else if(useSunJdk6) {
            OperatingSystemMXBean mx = ManagementFactory.getOperatingSystemMXBean();
            com.sun.management.OperatingSystemMXBean sunmx = (com.sun.management.OperatingSystemMXBean) mx;
            double d = sunmx.getSystemLoadAverage();
            if(d > 0) {
                return d / NPROCS;
            }
View Full Code Here

Examples of java.lang.management.OperatingSystemMXBean

    @Deprecated
    public static long getProcessCpuTime() {
        if(preferSigar) {
            throw new UnsupportedOperationException("SystemUtils#getProcessCpuTime() is not supported when using Hyperic Sigar");
        } else if(useSunJdk6) {
            OperatingSystemMXBean mx = ManagementFactory.getOperatingSystemMXBean();
            com.sun.management.OperatingSystemMXBean sunmx = (com.sun.management.OperatingSystemMXBean) mx;
            return sunmx.getProcessCpuTime();
        } else {
            return _getProcessCpuTime() * 1000000L; /* milli to nano (10^6) */
        }
View Full Code Here

Examples of java.lang.management.OperatingSystemMXBean

         String cname = oname.getCanonicalName();
         PlatformMBeanIDC mpidc = new PlatformMBeanIDC(server, oname, mbean);
         mbeans.put(cname, mpidc);
      }
      // OperatingSystemMXBean
      OperatingSystemMXBean osbean = ManagementFactory.getOperatingSystemMXBean();
      ObjectName osname = new ObjectName(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
      PlatformMBeanIDC osidc = new PlatformMBeanIDC(server, osname, osbean);
      mbeans.put(osname.getCanonicalName(), osidc);

      // RuntimeMXBean
View Full Code Here

Examples of java.lang.management.OperatingSystemMXBean

        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        report.setScreenDevices(ge.getScreenDevices().length);
    }

    private void logCPU(Report report) {
        OperatingSystemMXBean bean = ManagementFactory.getOperatingSystemMXBean();
        report.setNumberOfProcessors(bean.getAvailableProcessors());
        String unknown = "unknown";                                   // NOI18N
        String str = System.getProperty("os.name", unknown) + ", " + // NOI18N
                System.getProperty("os.version", unknown) + ", " + // NOI18N
                System.getProperty("os.arch", unknown);               // NOI18N
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.