author | stefank |
Tue, 28 Nov 2017 21:43:45 +0100 | |
changeset 48157 | 7c4d43c26352 |
parent 47903 | 7f22774a5f42 |
child 49175 | 6a5decfc5574 |
permissions | -rw-r--r-- |
47903
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
1 |
/* |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
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 |
|
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
25 |
#ifndef OS_LINUX_VM_OSCONTAINER_LINUX_HPP |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
26 |
#define OS_LINUX_VM_OSCONTAINER_LINUX_HPP |
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(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
43 |
static char * container_type(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
44 |
|
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
45 |
static jlong memory_limit_in_bytes(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
46 |
static jlong memory_and_swap_limit_in_bytes(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
47 |
static jlong memory_soft_limit_in_bytes(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
48 |
static jlong memory_usage_in_bytes(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
49 |
static jlong memory_max_usage_in_bytes(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
50 |
|
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
51 |
static int active_processor_count(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
52 |
|
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
53 |
static char * cpu_cpuset_cpus(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
54 |
static char * cpu_cpuset_memory_nodes(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
55 |
|
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
56 |
static int cpu_quota(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
57 |
static int cpu_period(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
58 |
|
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
59 |
static int cpu_shares(); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
60 |
|
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 |
inline bool OSContainer::is_containerized() { |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
64 |
assert(_is_initialized, "OSContainer not initialized"); |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
65 |
return _is_containerized; |
7f22774a5f42
8146115: Improve docker container detection and resource configuration usage
bobv
parents:
diff
changeset
|
66 |
} |
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 |
#endif // OS_LINUX_VM_OSCONTAINER_LINUX_HPP |