1 /* 2 * Copyright (c) 2017, 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. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_RUNTIME_OSCONTAINER_HPP 26 #define SHARE_VM_RUNTIME_OSCONTAINER_HPP 27 28 #include "utilities/globalDefinitions.hpp" 29 #include "utilities/macros.hpp" 30 #include "memory/allocation.hpp" 31 32 class OSContainer: AllStatic { 33 34 private: 35 static bool _is_initialized; 36 static bool _is_containerized; 37 38 public: 39 static void init(); 40 static bool is_containerized(); 41 static char * get_container_type(); 42 43 static jlong memory_limit_in_bytes() { 44 return pd_memory_limit_in_bytes(); 45 } 46 47 static jlong memory_and_swap_limit_in_bytes() { 48 return pd_memory_and_swap_limit_in_bytes(); 49 } 50 51 static jlong memory_soft_limit_in_bytes() { 52 return pd_memory_soft_limit_in_bytes(); 53 } 54 55 static jlong memory_usage_in_bytes() { 56 return pd_memory_usage_in_bytes(); 57 } 58 59 static jlong memory_max_usage_in_bytes() { 60 return pd_memory_max_usage_in_bytes(); 61 } 62 63 static int active_processor_count() { 64 return pd_active_processor_count(); 65 } 66 67 static char * cpu_cpuset_cpus() { 68 return pd_cpu_cpuset_cpus(); 69 } 70 71 static char * cpu_cpuset_memory_nodes() { 72 return pd_cpu_cpuset_memory_nodes(); 73 } 74 75 static int cpu_quota() { 76 return pd_cpu_quota(); 77 } 78 79 static int cpu_period() { 80 return pd_cpu_period(); 81 } 82 83 static int cpu_shares() { 84 return pd_cpu_shares(); 85 } 86 87 // Platform specific functions 88 89 static bool pd_init(); 90 static char * pd_get_container_type(); 91 92 static jlong pd_memory_limit_in_bytes(); 93 static jlong pd_memory_and_swap_limit_in_bytes(); 94 static jlong pd_memory_soft_limit_in_bytes(); 95 static jlong pd_memory_usage_in_bytes(); 96 static jlong pd_memory_max_usage_in_bytes(); 97 98 static int pd_active_processor_count(); 99 100 static char * pd_cpu_cpuset_cpus(); 101 static char * pd_cpu_cpuset_memory_nodes(); 102 103 static int pd_cpu_quota(); 104 static int pd_cpu_period(); 105 106 static int pd_cpu_shares(); 107 108 #include OS_HEADER(osContainer) 109 110 }; 111 112 #endif // SHARE_VM_RUNTIME_OSCONTAINER_HPP