use of org.talend.designer.runtime.visualization.internal.core.AbstractJvm 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;
}
Aggregations