use of org.talend.designer.runtime.visualization.JvmModelEvent in project tdi-studio-se by Talend.
the class CpuProfiler method dump.
/*
* @see ICpuProfiler#dump()
*/
@Override
public IFileStore dump() throws JvmCoreException {
String dump = cpuModel.getCpuDumpString(//$NON-NLS-1$
jvm.getPid() + "@" + jvm.getHost().getName(), jvm.getMainClass(), jvm.getMBeanServer().getJvmArguments());
StringBuffer fileName = new StringBuffer();
fileName.append(new Date().getTime()).append('.').append(SnapshotType.Cpu.getExtension());
IFileStore fileStore = Util.getFileStore(fileName.toString(), jvm.getBaseDirectory());
// restore the terminated JVM if already removed
AbstractJvm abstractJvm = jvm;
if (!((Host) jvm.getHost()).getJvms().contains(jvm)) {
jvm.saveJvmProperties();
abstractJvm = (AbstractJvm) ((Host) jvm.getHost()).addTerminatedJvm(jvm.getPid(), jvm.getPort(), jvm.getMainClass());
}
OutputStream os = null;
try {
os = fileStore.openOutputStream(EFS.NONE, null);
os.write(dump.getBytes());
Snapshot snapshot = new Snapshot(fileStore, abstractJvm);
abstractJvm.addSnapshot(snapshot);
JvmModel.getInstance().fireJvmModelChangeEvent(new JvmModelEvent(State.ShapshotTaken, jvm, snapshot));
} catch (CoreException e) {
throw new JvmCoreException(IStatus.ERROR, NLS.bind(Messages.openOutputStreamFailedMsg, fileStore.toURI().getPath()), e);
} catch (IOException e) {
try {
fileStore.delete(EFS.NONE, null);
} catch (CoreException e1) {
// do nothing
}
throw new JvmCoreException(IStatus.ERROR, NLS.bind(Messages.dumpCpuProfileDataFailedMsg, fileStore.toURI().getPath()), e);
} finally {
if (os != null) {
try {
os.close();
} catch (IOException e) {
// do nothing
}
}
}
return fileStore;
}
use of org.talend.designer.runtime.visualization.JvmModelEvent in project tdi-studio-se by Talend.
the class Host method addActiveJvm.
/**
* Adds the active JVM.
*
* @param jvm The active JVM.
* @return The active JVM
*/
protected IActiveJvm addActiveJvm(IActiveJvm jvm) {
for (IActiveJvm activeJvm : activeJvms) {
if (activeJvm.getPid() == jvm.getPid()) {
return jvm;
}
}
activeJvms.add(jvm);
JvmModel.getInstance().fireJvmModelChangeEvent(new JvmModelEvent(State.JvmAdded, jvm));
return jvm;
}
use of org.talend.designer.runtime.visualization.JvmModelEvent in project tdi-studio-se by Talend.
the class MBeanNotification method clear.
/*
* @see IMBeanNotification#clear(ObjectName)
*/
@Override
public void clear(ObjectName objectName) {
List<Notification> notification = notifications.get(objectName);
if (notification == null) {
return;
}
notification.clear();
JvmModel.getInstance().fireJvmModelChangeEvent(new JvmModelEvent(State.JvmModified, activeJvm));
}
use of org.talend.designer.runtime.visualization.JvmModelEvent in project tdi-studio-se by Talend.
the class MBeanNotification method subscribe.
/*
* @see IMBeanNotification#subscribe(ObjectName)
*/
@Override
public void subscribe(final ObjectName objectName) throws JvmCoreException {
NotificationListener listener = new NotificationListener() {
@Override
public void handleNotification(Notification notification, Object handback) {
List<Notification> list = notifications.get(objectName);
if (list == null) {
list = new ArrayList<Notification>();
}
list.add(new DecoratedNotification(notification));
notifications.put(objectName, list);
}
};
activeJvm.getMBeanServer().addNotificationListener(objectName, listener);
listeners.put(objectName, listener);
JvmModel.getInstance().fireJvmModelChangeEvent(new JvmModelEvent(State.JvmModified, activeJvm));
}
use of org.talend.designer.runtime.visualization.JvmModelEvent in project tdi-studio-se by Talend.
the class ActiveJvm method disconnect.
/*
* @see IActiveJvm#disconnect()
*/
@Override
public void disconnect() {
isConnected = false;
mBeanServer.dispose();
try {
if (swtResourceMonitor.isSupported()) {
swtResourceMonitor.setTracking(false);
}
} catch (JvmCoreException e) {
// do nothing
}
JvmModel.getInstance().fireJvmModelChangeEvent(new JvmModelEvent(State.JvmDisconnected, this));
}
Aggregations