786N/A/*
2362N/A * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
786N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
786N/A *
786N/A * This code is free software; you can redistribute it and/or modify it
786N/A * under the terms of the GNU General Public License version 2 only, as
786N/A * published by the Free Software Foundation.
786N/A *
786N/A * This code is distributed in the hope that it will be useful, but WITHOUT
786N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
786N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
786N/A * version 2 for more details (a copy is included in the LICENSE file that
786N/A * accompanied this code).
786N/A *
786N/A * You should have received a copy of the GNU General Public License version
786N/A * 2 along with this work; if not, write to the Free Software Foundation,
786N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
786N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
786N/A */
786N/A
786N/Aimport java.net.URISyntaxException;
786N/Aimport java.util.Set;
786N/Aimport sun.jvmstat.monitor.MonitorException;
786N/Aimport sun.jvmstat.monitor.MonitoredHost;
786N/Aimport sun.jvmstat.monitor.MonitoredVm;
786N/Aimport sun.jvmstat.monitor.VmIdentifier;
786N/A
786N/A/**
786N/A *
786N/A * @test
786N/A * @bug 6672135
786N/A * @summary setInterval() for local MonitoredHost and local MonitoredVm
786N/A * @author Tomas Hurka
786N/A */
786N/Apublic class CR6672135 {
786N/A
786N/A private static final int INTERVAL = 2000;
786N/A
786N/A public static void main(String[] args) {
786N/A int vmInterval;
786N/A int hostInterval;
786N/A
786N/A try {
786N/A MonitoredHost localHost = MonitoredHost.getMonitoredHost("localhost");
786N/A Set vms = localHost.activeVms();
786N/A Integer vmInt = (Integer) vms.iterator().next();
786N/A String uriString = "//" + vmInt + "?mode=r"; // NOI18N
786N/A VmIdentifier vmId = new VmIdentifier(uriString);
786N/A MonitoredVm vm = localHost.getMonitoredVm(vmId);
786N/A
786N/A vm.setInterval(INTERVAL);
786N/A localHost.setInterval(INTERVAL);
786N/A vmInterval = vm.getInterval();
786N/A hostInterval = localHost.getInterval();
786N/A } catch (Exception ex) {
786N/A throw new Error ("Test failed",ex);
786N/A }
786N/A System.out.println("VM "+vmInterval);
786N/A if (vmInterval != INTERVAL) {
786N/A throw new Error("Test failed");
786N/A }
786N/A System.out.println("Host "+hostInterval);
786N/A if (hostInterval != INTERVAL) {
786N/A throw new Error("Test failed");
786N/A }
786N/A }
786N/A}
786N/A