jdk/src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/MonitoredVm.java
author martin
Thu, 30 Oct 2014 07:31:41 -0700
changeset 28059 e576535359cc
parent 25859 3317bb8137f4
child 31061 fead7d86d75f
permissions -rw-r--r--
8067377: My hobby: caning, then then canning, the the can-can Summary: Fix ALL the stutters! Reviewed-by: rriggs, mchung, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.jvmstat.monitor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import sun.jvmstat.monitor.event.VmListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * Interface for interacting with a monitorable Java Virtual Machine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * The MonitoredVm interface provides methods for discovery of exported
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * instrumentation, for attaching event listeners, and for overall
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * maintenance of the connection to the target.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * @author Brian Doherty
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
public interface MonitoredVm {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
     * Get the VmIdentifier associated with this MonitoredVm
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     * @return VmIdentifier - the fully resolved Vm identifier associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     *                        with this MonitoredVm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    VmIdentifier getVmIdentifier();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * Find a named Instrumentation object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * This method will look for the named instrumentation object in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * instrumentation exported by this Java Virtual Machine. If an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * instrumentation object with the given name exists, a Monitor interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * to that object will be return. Otherwise, the method returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * <tt>null</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * @param name the name of the Instrumentation object to find.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * @return Monitor - the {@link Monitor} object that can be used to
28059
e576535359cc 8067377: My hobby: caning, then then canning, the the can-can
martin
parents: 25859
diff changeset
    62
     *                   monitor the named instrumentation object, or
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     *                   <tt>null</tt> if the named object doesn't exist.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @throws MonitorException Thrown if an error occurs while communicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     *                          with the target Java Virtual Machine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    Monitor findByName(String name) throws MonitorException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * Find all Instrumentation objects with names matching the given pattern.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * This method returns a {@link List} of Monitor objects such that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * the name of each object matches the given pattern.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @param patternString a string containing a pattern as described in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     *                      {@link java.util.regex.Pattern}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * @return List<Monitor> - a List of {@link Monitor} objects that can be used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     *                monitor the instrumentation objects whose names match
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     *                the given pattern. If no instrumentation objects have`
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     *                names matching the given pattern, then an empty List
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     *                is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * @throws MonitorException Thrown if an error occurs while communicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     *                          with the target Java Virtual Machine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @see java.util.regex.Pattern
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    List<Monitor> findByPattern(String patternString) throws MonitorException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * Detach from target Java Virtual Machine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * After calling this method, updates of the instrumentation data values
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * may be halted. All event notifications are halted. Further interactions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * with this object should be avoided.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    void detach();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /* ---- Methods to support polled MonitoredVm Implementations ---- */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * Set the polling interval to <code>interval</code> milliseconds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * Polling based monitoring implementations need to refresh the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * instrumentation data on a periodic basis. This interface allows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * the interval to override the implementation specific default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * interval.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * @param interval the polling interval in milliseconds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    void setInterval(int interval);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * Get the polling interval.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @return int - the current polling interval in milliseconds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @see #setInterval
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    int getInterval();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * Set the last exception encountered while polling this MonitoredVm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * Polling implementations may choose to poll asynchronously. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * method allows an asynchronous task to communicate any polling related
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * exceptions with the application. When an a non-null exception is reported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * through this interface, the MonitoredVm instance is considered to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * be in the <em>errored</em> state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @param cause the exception to record.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @see #isErrored
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    void setLastException(Exception cause);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * Get the last exception encountered while polling this MonitoredVm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * Returns the last exception observed by the implementation dependent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * polling task or <tt>null</tt> if no such error has occurred.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @return Exception - the last exception that occurred during polling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     *                     or <tt>null</tt> if no error condition exists.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * @see #isErrored
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * @see #setLastException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    Exception getLastException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * Clear the last exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * Calling this method will clear the <em>errored</em> state of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * MonitoredVm. However, there is no guarantee that clearing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * the errored state return the asynchronous polling task to an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * operational state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    void clearLastException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * Test if this MonitoredVm is in the errored state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * The errored state exists only if an error was reported with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * call to {@link #setLastException} and only if the parameter to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * that call was non-null and no subsequent calls are made to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * {@link #clearLastException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @return boolean - true if the instance has a non-null error condition
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     *                   set, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @see #setLastException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @see #getLastException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    boolean isErrored();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * Add a VmListener. The given listener is added to the list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * VmListener objects to be notified of MonitoredVm related events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @param listener the VmListener to add.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @throws MonitorException Thrown if any problems occur while attempting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     *                          to add this listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    void addVmListener(VmListener listener) throws MonitorException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * Remove a VmListener. The given listener is removed from the list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * VmListener objects to be notified of MonitoredVm related events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @param listener the VmListener to be removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @throws MonitorException Thrown if any problems occur while attempting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *                            to remove this listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    void removeVmListener(VmListener listener) throws MonitorException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
}