2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
|
2
|
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 |
*
|
5506
|
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.
|
2
|
22 |
*/
|
|
23 |
|
|
24 |
/*
|
|
25 |
* @test
|
|
26 |
* @bug 4990825
|
|
27 |
* @summary prolog size and overflow sanity checks
|
|
28 |
*/
|
|
29 |
|
|
30 |
import sun.jvmstat.monitor.*;
|
|
31 |
|
|
32 |
public class PrologSizeSanityCheck {
|
|
33 |
|
|
34 |
private static final String sizeName = "sun.perfdata.size";
|
|
35 |
private static final String usedName = "sun.perfdata.used";
|
|
36 |
private static final String overflowName = "sun.perfdata.overflow";
|
|
37 |
private static final int K = 1024;
|
|
38 |
|
|
39 |
public static void main(String args[]) throws Exception {
|
|
40 |
|
|
41 |
VmIdentifier vmid = new VmIdentifier("0");
|
|
42 |
MonitoredHost localhost = MonitoredHost.getMonitoredHost("localhost");
|
|
43 |
MonitoredVm self = localhost.getMonitoredVm(vmid);
|
|
44 |
|
|
45 |
IntegerMonitor prologSize = (IntegerMonitor)self.findByName(sizeName);
|
|
46 |
IntegerMonitor prologUsed = (IntegerMonitor)self.findByName(usedName);
|
|
47 |
IntegerMonitor prologOverflow =
|
|
48 |
(IntegerMonitor)self.findByName(overflowName);
|
|
49 |
|
|
50 |
if (prologOverflow.intValue() != 0) {
|
|
51 |
throw new RuntimeException("jvmstat memory buffer overflow: "
|
|
52 |
+ sizeName + "=" + prologSize.intValue()
|
|
53 |
+ usedName + "=" + prologUsed.intValue()
|
|
54 |
+ overflowName + "=" + prologOverflow.intValue()
|
|
55 |
+ " : PerfDataMemorySize must be increased");
|
|
56 |
}
|
|
57 |
|
|
58 |
if (prologUsed.intValue() + 3*K >= prologSize.intValue()) {
|
|
59 |
/*
|
|
60 |
* we want to leave at least 3K of space to allow for long
|
|
61 |
* string names in the various path oriented strings and for
|
|
62 |
* the command line argument and vm argument strings. 3K is
|
|
63 |
* somewhat of an arbitrary figure, but it is based on failure
|
|
64 |
* scenarios observed in SQE when jvmstat was originally
|
|
65 |
* introduced in 1.4.1.
|
|
66 |
*/
|
|
67 |
throw new RuntimeException(
|
|
68 |
"jvmstat memory buffer usage approaching size: "
|
|
69 |
+ sizeName + "=" + prologSize.intValue()
|
|
70 |
+ usedName + "=" + prologUsed.intValue()
|
|
71 |
+ " : consider increasing PerfDataMemorySize");
|
|
72 |
}
|
|
73 |
}
|
|
74 |
}
|