author | chegar |
Wed, 13 Jan 2016 14:32:42 +0000 | |
changeset 34953 | 67245e3259bf |
parent 34351 | f30070a16a4b |
permissions | -rw-r--r-- |
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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.jvmstat.perfdata.monitor; |
|
27 |
||
28 |
import java.util.List; |
|
29 |
||
30 |
import sun.jvmstat.monitor.*; |
|
31 |
import sun.jvmstat.monitor.event.VmListener; |
|
32 |
||
33 |
/** |
|
34 |
* Base class for all MonitoredVm implementations that utilize the |
|
35 |
* HotSpot PerfData instrumentation buffer as the communications |
|
36 |
* mechanism to the target Java Virtual Machine. |
|
37 |
* |
|
38 |
* @author Brian Doherty |
|
39 |
* @since 1.5 |
|
40 |
*/ |
|
41 |
public abstract class AbstractMonitoredVm implements BufferedMonitoredVm { |
|
42 |
||
43 |
/** |
|
44 |
* The VmIdentifier for the target. |
|
45 |
*/ |
|
46 |
protected VmIdentifier vmid; |
|
47 |
||
48 |
/** |
|
49 |
* The shared memory instrumentation buffer for the target. |
|
50 |
*/ |
|
51 |
protected AbstractPerfDataBuffer pdb; |
|
52 |
||
53 |
/** |
|
54 |
* The sampling interval, if the instrumentation buffer is acquired |
|
55 |
* by sampling instead of shared memory mechanisms. |
|
56 |
*/ |
|
57 |
protected int interval; |
|
58 |
||
59 |
/** |
|
60 |
* Create an AbstractMonitoredVm instance. |
|
61 |
* |
|
62 |
* @param vmid the VmIdentifier for the target |
|
63 |
* @param interval the initial sampling interval |
|
64 |
*/ |
|
65 |
public AbstractMonitoredVm(VmIdentifier vmid, int interval) |
|
66 |
throws MonitorException { |
|
67 |
this.vmid = vmid; |
|
68 |
this.interval = interval; |
|
69 |
} |
|
70 |
||
71 |
/** |
|
72 |
* {@inheritDoc} |
|
73 |
*/ |
|
74 |
public VmIdentifier getVmIdentifier() { |
|
75 |
return vmid; |
|
76 |
} |
|
77 |
||
78 |
/** |
|
79 |
* {@inheritDoc} |
|
80 |
*/ |
|
81 |
public Monitor findByName(String name) throws MonitorException { |
|
82 |
return pdb.findByName(name); |
|
83 |
} |
|
84 |
||
85 |
/** |
|
86 |
* {@inheritDoc} |
|
87 |
*/ |
|
88 |
public List<Monitor> findByPattern(String patternString) throws MonitorException { |
|
89 |
return pdb.findByPattern(patternString); |
|
90 |
} |
|
91 |
||
92 |
/** |
|
93 |
* {@inheritDoc} |
|
94 |
*/ |
|
95 |
public void detach() { |
|
96 |
/* |
|
97 |
* no default action required because the detach operation for the |
|
34953
67245e3259bf
8146736: Move sun.misc performance counters to jdk.internal.perf
chegar
parents:
34351
diff
changeset
|
98 |
* native byte buffer is managed by the Perf class. |
2 | 99 |
*/ |
100 |
} |
|
101 |
||
102 |
||
103 |
/* ---- Methods to support polled MonitoredVm Implementations ----- */ |
|
104 |
||
105 |
/** |
|
106 |
* {@inheritDoc} |
|
107 |
*/ |
|
108 |
public void setInterval(int interval) { |
|
109 |
this.interval = interval; |
|
110 |
} |
|
111 |
||
112 |
/** |
|
113 |
* {@inheritDoc} |
|
114 |
*/ |
|
115 |
public int getInterval() { |
|
116 |
return interval; |
|
117 |
} |
|
118 |
||
119 |
/** |
|
120 |
* {@inheritDoc} |
|
121 |
*/ |
|
122 |
public void setLastException(Exception e) { |
|
123 |
// XXX: implement |
|
124 |
} |
|
125 |
||
126 |
/** |
|
127 |
* {@inheritDoc} |
|
128 |
*/ |
|
129 |
public Exception getLastException() { |
|
130 |
// XXX: implement |
|
131 |
return null; |
|
132 |
} |
|
133 |
||
134 |
/** |
|
135 |
* {@inheritDoc} |
|
136 |
*/ |
|
137 |
public void clearLastException() { |
|
138 |
// XXX: implement |
|
139 |
} |
|
140 |
||
141 |
/** |
|
142 |
* {@inheritDoc} |
|
143 |
*/ |
|
144 |
public boolean isErrored() { |
|
145 |
// XXX: implement |
|
146 |
return false; |
|
147 |
} |
|
148 |
||
149 |
/** |
|
150 |
* Get a list of the inserted and removed monitors since last called. |
|
151 |
* |
|
152 |
* @return MonitorStatus - the status of available Monitors for the |
|
153 |
* target Java Virtual Machine. |
|
154 |
* @throws MonitorException Thrown if communications errors occur |
|
155 |
* while communicating with the target. |
|
156 |
*/ |
|
157 |
public MonitorStatus getMonitorStatus() throws MonitorException { |
|
158 |
return pdb.getMonitorStatus(); |
|
159 |
} |
|
160 |
||
161 |
||
162 |
/* --------------- Methods to support VmListeners ----------------- */ |
|
163 |
||
164 |
/** |
|
165 |
* {@inheritDoc} |
|
166 |
*/ |
|
167 |
public abstract void addVmListener(VmListener l); |
|
168 |
||
169 |
/** |
|
170 |
* {@inheritDoc} |
|
171 |
*/ |
|
172 |
public abstract void removeVmListener(VmListener l); |
|
173 |
||
174 |
||
175 |
/* ---- Methods to support BufferedMonitoredVm Implementations ---- */ |
|
176 |
||
177 |
/** |
|
178 |
* {@inheritDoc} |
|
179 |
*/ |
|
180 |
public byte[] getBytes() { |
|
181 |
return pdb.getBytes(); |
|
182 |
} |
|
183 |
||
184 |
/** |
|
185 |
* {@inheritDoc} |
|
186 |
*/ |
|
187 |
public int getCapacity() { |
|
188 |
return pdb.getCapacity(); |
|
189 |
} |
|
190 |
} |