Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.base/linux/classes/jdk/internal/platform/CgroupMetrics.java
40948 views
1
/*
2
* Copyright (c) 2020, Red Hat Inc.
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
23
* questions.
24
*/
25
26
package jdk.internal.platform;
27
28
import java.util.Objects;
29
30
public class CgroupMetrics implements Metrics {
31
32
private final CgroupSubsystem subsystem;
33
34
CgroupMetrics(CgroupSubsystem subsystem) {
35
this.subsystem = Objects.requireNonNull(subsystem);
36
}
37
38
@Override
39
public String getProvider() {
40
return subsystem.getProvider();
41
}
42
43
@Override
44
public long getCpuUsage() {
45
return subsystem.getCpuUsage();
46
}
47
48
@Override
49
public long[] getPerCpuUsage() {
50
return subsystem.getPerCpuUsage();
51
}
52
53
@Override
54
public long getCpuUserUsage() {
55
return subsystem.getCpuUserUsage();
56
}
57
58
@Override
59
public long getCpuSystemUsage() {
60
return subsystem.getCpuSystemUsage();
61
}
62
63
@Override
64
public long getCpuPeriod() {
65
return subsystem.getCpuPeriod();
66
}
67
68
@Override
69
public long getCpuQuota() {
70
return subsystem.getCpuQuota();
71
}
72
73
@Override
74
public long getCpuShares() {
75
return subsystem.getCpuShares();
76
}
77
78
@Override
79
public long getCpuNumPeriods() {
80
return subsystem.getCpuNumPeriods();
81
}
82
83
@Override
84
public long getCpuNumThrottled() {
85
return subsystem.getCpuNumThrottled();
86
}
87
88
@Override
89
public long getCpuThrottledTime() {
90
return subsystem.getCpuThrottledTime();
91
}
92
93
@Override
94
public long getEffectiveCpuCount() {
95
return subsystem.getEffectiveCpuCount();
96
}
97
98
@Override
99
public int[] getCpuSetCpus() {
100
return subsystem.getCpuSetCpus();
101
}
102
103
@Override
104
public int[] getEffectiveCpuSetCpus() {
105
return subsystem.getEffectiveCpuSetCpus();
106
}
107
108
@Override
109
public int[] getCpuSetMems() {
110
return subsystem.getCpuSetMems();
111
}
112
113
@Override
114
public int[] getEffectiveCpuSetMems() {
115
return subsystem.getEffectiveCpuSetMems();
116
}
117
118
public long getMemoryFailCount() {
119
return subsystem.getMemoryFailCount();
120
}
121
122
@Override
123
public long getMemoryLimit() {
124
return subsystem.getMemoryLimit();
125
}
126
127
@Override
128
public long getMemoryUsage() {
129
return subsystem.getMemoryUsage();
130
}
131
132
@Override
133
public long getTcpMemoryUsage() {
134
return subsystem.getTcpMemoryUsage();
135
}
136
137
@Override
138
public long getMemoryAndSwapLimit() {
139
return subsystem.getMemoryAndSwapLimit();
140
}
141
142
@Override
143
public long getMemoryAndSwapUsage() {
144
return subsystem.getMemoryAndSwapUsage();
145
}
146
147
@Override
148
public long getMemorySoftLimit() {
149
return subsystem.getMemorySoftLimit();
150
}
151
152
@Override
153
public long getBlkIOServiceCount() {
154
return subsystem.getBlkIOServiceCount();
155
}
156
157
@Override
158
public long getBlkIOServiced() {
159
return subsystem.getBlkIOServiced();
160
}
161
162
public static Metrics getInstance() {
163
if (!isUseContainerSupport()) {
164
// Return null on -XX:-UseContainerSupport
165
return null;
166
}
167
return CgroupSubsystemFactory.create();
168
}
169
170
private static native boolean isUseContainerSupport();
171
172
}
173
174