/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Concrete implementation of the AbstractMonitoredVm class for the
* <em>rmi:</em> protocol for the HotSpot PerfData monitoring implementation.
* <p>
* This class provides the ability to acquire to the instrumentation buffer
* of a live, remote target Java Virtual Machine through an RMI server.
*
* @author Brian Doherty
* @since 1.5
*/
/**
* Create a RemoteMonitoredVm instance.
*
* @param rvm the proxy to the remote MonitoredVm instance.
* @param vmid the vm identifier specifying the remot target JVM
* @param timer the timer used to run polling tasks
* @param interval the sampling interval
*/
throws MonitorException {
}
/**
* Method to attach to the remote MonitoredVm.
*/
// if continuous sampling is requested, register with the sampler thread
if (interval > 0) {
samplerTask = new SamplerTask();
}
}
/**
* {@inheritDoc}
*/
public void detach() {
try {
if (interval > 0) {
if (samplerTask != null) {
samplerTask = null;
}
if (notifierTask != null) {
notifierTask = null;
}
sample();
}
} catch (RemoteException e) {
// XXX: - use logging api? throw an exception instead?
e.printStackTrace();
} finally {
super.detach();
}
}
/**
* Get a copy of the remote instrumentation buffer.
*<p>
* The data in the remote instrumentation buffer is copied into
* a local byte buffer.
*
* @throws RemoteException Thrown on any communications errors with
* the remote system.
*/
assert updateBuffer != null;
}
/**
* Get the proxy to the remote MonitoredVm.
*
* @return RemoteVm - the proxy to the remote MonitoredVm.
*/
return rvm;
}
/**
* {@inheritDoc}
*/
synchronized(listeners) {
if (notifierTask == null) {
notifierTask = new NotifierTask();
}
}
}
/**
* {@inheritDoc}
*/
synchronized(listeners) {
notifierTask = null;
}
}
}
/**
* {@inheritDoc}
*/
synchronized(listeners) {
if (newInterval == interval) {
return;
}
int oldInterval = interval;
super.setInterval(newInterval);
if (samplerTask != null) {
samplerTask = new SamplerTask();
}
if (notifierTask != null) {
notifierTask = new NotifierTask();
}
}
}
/**
* Fire MonitoredVmStructureChanged events.
*
* @param inserted List of Monitor objects inserted.
* @param removed List of Monitor objects removed.
*/
synchronized(listeners) {
}
}
}
}
/**
* Fire MonitoredVmStructureChanged events.
*/
void fireMonitorsUpdatedEvents() {
synchronized(listeners) {
}
}
l.monitorsUpdated(ev);
}
}
/*
* Timer Tasks. There are two separate timer tasks here. The SamplerTask
* is active whenever we are attached to the remote JVM with a periodic
* sampling interval > 0. The NotifierTask is only active if a VmListener
* has registered with this RemoteMonitoredVm instance. Also, in the future
* we may want to run these tasks at different intervals. Currently,
* they run at the same interval and some significant work may
* need to be done to complete the separation of these two intervals.
*/
/**
* Class to periodically check the state of the defined monitors
* for the remote MonitoredVm instance and to notify listeners of
* any detected changes.
*/
public void run() {
super.run();
try {
}
} catch (MonitorException e) {
// XXX: use logging api? fire disconnect events? mark errored?
// fireDisconnectedEvents();
+ getVmIdentifier());
e.printStackTrace();
// XXX: should we cancle the notifierTask here?
// this.cancel();
}
}
}
/**
* Class to periodically sample the remote instrumentation byte buffer
* and refresh the local copy. Registered listeners are notified of
* the completion of a sampling event.
*/
public void run() {
super.run();
try {
sample();
} catch (RemoteException e) {
// XXX: use logging api, mark vm as errored.
+ getVmIdentifier());
e.printStackTrace();
this.cancel();
}
}
}
}