Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/jvmstat/perfdata/PrologSanity/PrologSizeSanityCheck.java
38853 views
/*1* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 499082526* @run main/othervm -XX:+UsePerfData -XX:PerfDataMemorySize=64k PrologSizeSanityCheck27* @summary prolog size and overflow sanity checks28*/2930import sun.jvmstat.monitor.*;3132public class PrologSizeSanityCheck {3334private static final String sizeName = "sun.perfdata.size";35private static final String usedName = "sun.perfdata.used";36private static final String overflowName = "sun.perfdata.overflow";37private static final int K = 1024;3839public static void main(String args[]) throws Exception {4041VmIdentifier vmid = new VmIdentifier("0");42MonitoredHost localhost = MonitoredHost.getMonitoredHost("localhost");43MonitoredVm self = localhost.getMonitoredVm(vmid);4445IntegerMonitor prologSize = (IntegerMonitor)self.findByName(sizeName);46IntegerMonitor prologUsed = (IntegerMonitor)self.findByName(usedName);47IntegerMonitor prologOverflow =48(IntegerMonitor)self.findByName(overflowName);4950if (prologOverflow.intValue() != 0) {51throw new RuntimeException("jvmstat memory buffer overflow: "52+ sizeName + "=" + prologSize.intValue()53+ usedName + "=" + prologUsed.intValue()54+ overflowName + "=" + prologOverflow.intValue()55+ " : PerfDataMemorySize must be increased");56}5758if (prologUsed.intValue() + 3*K >= prologSize.intValue()) {59/*60* we want to leave at least 3K of space to allow for long61* string names in the various path oriented strings and for62* the command line argument and vm argument strings. 3K is63* somewhat of an arbitrary figure, but it is based on failure64* scenarios observed in SQE when jvmstat was originally65* introduced in 1.4.1.66*/67throw new RuntimeException(68"jvmstat memory buffer usage approaching size: "69+ sizeName + "=" + prologSize.intValue()70+ usedName + "=" + prologUsed.intValue()71+ " : consider increasing PerfDataMemorySize");72}73}74}757677