author | ccheung |
Fri, 28 Jun 2019 09:49:10 -0700 | |
changeset 55524 | b279ae9843b8 |
parent 54577 | 1c242c2d037f |
child 58087 | 03964761a23c |
child 58678 | 9cf78a70fa4f |
permissions | -rw-r--r-- |
47903
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49175
diff
changeset
|
2 |
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. |
47903
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
4 |
* |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
8 |
* |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
13 |
* accompanied this code). |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
14 |
* |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
18 |
* |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
21 |
* questions. |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
22 |
* |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
23 |
*/ |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
24 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49175
diff
changeset
|
25 |
#ifndef OS_LINUX_OSCONTAINER_LINUX_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49175
diff
changeset
|
26 |
#define OS_LINUX_OSCONTAINER_LINUX_HPP |
47903
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
27 |
|
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
28 |
#include "utilities/globalDefinitions.hpp" |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
29 |
#include "utilities/macros.hpp" |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
30 |
#include "memory/allocation.hpp" |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
31 |
|
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
32 |
#define OSCONTAINER_ERROR (-2) |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
33 |
|
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
34 |
class OSContainer: AllStatic { |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
35 |
|
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
36 |
private: |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
37 |
static bool _is_initialized; |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
38 |
static bool _is_containerized; |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
39 |
|
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
40 |
public: |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
41 |
static void init(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
42 |
static inline bool is_containerized(); |
49175
6a5decfc5574
8197408: Bad pointer comparison and small cleanup in os_linux.cpp
rehn
parents:
47903
diff
changeset
|
43 |
static const char * container_type(); |
47903
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
44 |
|
54577
1c242c2d037f
8217338: [Containers] Improve systemd slice memory limit support
sgehwolf
parents:
53244
diff
changeset
|
45 |
static jlong uses_mem_hierarchy(); |
47903
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
46 |
static jlong memory_limit_in_bytes(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
47 |
static jlong memory_and_swap_limit_in_bytes(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
48 |
static jlong memory_soft_limit_in_bytes(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
49 |
static jlong memory_usage_in_bytes(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
50 |
static jlong memory_max_usage_in_bytes(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
51 |
|
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
52 |
static int active_processor_count(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
53 |
|
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
54 |
static char * cpu_cpuset_cpus(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
55 |
static char * cpu_cpuset_memory_nodes(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
56 |
|
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
57 |
static int cpu_quota(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
58 |
static int cpu_period(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
59 |
|
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
60 |
static int cpu_shares(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
61 |
|
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
62 |
}; |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
63 |
|
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
64 |
inline bool OSContainer::is_containerized() { |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
65 |
assert(_is_initialized, "OSContainer not initialized"); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
66 |
return _is_containerized; |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
67 |
} |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
68 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
49175
diff
changeset
|
69 |
#endif // OS_LINUX_OSCONTAINER_LINUX_HPP |