< prev index next >

src/jdk.management/unix/classes/com/sun/management/internal/OperatingSystemImpl.java

Print this page
@  rev 57586 : Review changes
|
~
   1 /*
   2  * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 153                             double cpuLoad = getSingleCpuLoad0(cpu);
 154                             if (cpuLoad < 0) {
 155                                 return -1;
 156                             }
 157                             systemLoad += cpuLoad;
 158                         }
 159                         return systemLoad / cpuSet.length;
 160                     }
 161                     return -1;
 162                 }
 163             }
 164         }
 165         return getCpuLoad0();
 166     }
 167 
 168     public double getProcessCpuLoad() {
 169         return getProcessCpuLoad0();
 170     }
 171 
 172     private boolean isCpuSetSameAsHostCpuSet() {
 173         if (containerMetrics != null) {
 174             return containerMetrics.getCpuSetCpus().length == getHostConfiguredCpuCount0();
 175         }
 176         return false;
 177     }
 178 
 179     /* native methods */
 180     private native long getCommittedVirtualMemorySize0();
 181     private native long getFreeMemorySize0();
 182     private native long getFreeSwapSpaceSize0();
 183     private native long getMaxFileDescriptorCount0();
 184     private native long getOpenFileDescriptorCount0();
 185     private native long getProcessCpuTime0();
 186     private native double getProcessCpuLoad0();
 187     private native double getCpuLoad0();
 188     private native long getTotalMemorySize0();
 189     private native long getTotalSwapSpaceSize0();
 190     private native double getSingleCpuLoad0(int cpuNum);
 191     private native int getHostConfiguredCpuCount0();
 192 
 193     static {
   1 /*
   2  * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 153                             double cpuLoad = getSingleCpuLoad0(cpu);
 154                             if (cpuLoad < 0) {
 155                                 return -1;
 156                             }
 157                             systemLoad += cpuLoad;
 158                         }
 159                         return systemLoad / cpuSet.length;
 160                     }
 161                     return -1;
 162                 }
 163             }
 164         }
 165         return getCpuLoad0();
 166     }
 167 
 168     public double getProcessCpuLoad() {
 169         return getProcessCpuLoad0();
 170     }
 171 
 172     private boolean isCpuSetSameAsHostCpuSet() {
 173         if (containerMetrics != null && containerMetrics.getCpuSetCpus() != null) {
 174             return containerMetrics.getCpuSetCpus().length == getHostConfiguredCpuCount0();
 175         }
 176         return false;
 177     }
 178 
 179     /* native methods */
 180     private native long getCommittedVirtualMemorySize0();
 181     private native long getFreeMemorySize0();
 182     private native long getFreeSwapSpaceSize0();
 183     private native long getMaxFileDescriptorCount0();
 184     private native long getOpenFileDescriptorCount0();
 185     private native long getProcessCpuTime0();
 186     private native double getProcessCpuLoad0();
 187     private native double getCpuLoad0();
 188     private native long getTotalMemorySize0();
 189     private native long getTotalSwapSpaceSize0();
 190     private native double getSingleCpuLoad0(int cpuNum);
 191     private native int getHostConfiguredCpuCount0();
 192 
 193     static {
< prev index next >