use of org.talend.designer.runtime.visualization.internal.core.Host 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.internal.core.Host in project tdi-studio-se by Talend.
the class JvmModel method removeHost.
/**
* Removes the host.
*
* @param host The host
*/
public void removeHost(IHost host) {
hosts.remove(host);
try {
IPath hostDir = ((Host) host).getHostDir();
Util.deleteDir(hostDir.toFile());
} catch (JvmCoreException e) {
Activator.log(IStatus.ERROR, NLS.bind(Messages.removeHostFailedMsg, host.getName()), e);
}
fireJvmModelChangeEvent(new JvmModelEvent(State.HostRemoved, null));
}
use of org.talend.designer.runtime.visualization.internal.core.Host in project tdi-studio-se by Talend.
the class JvmModel method addHost.
/**
* Adds the host.
*
* @param hostname The host name
* @return The host
*/
public IHost addHost(String hostname) {
IHost host = getHost(hostname);
if (host != null) {
return host;
}
host = new Host(hostname);
hosts.add(host);
fireJvmModelChangeEvent(new JvmModelEvent(State.HostAdded, null));
return host;
}
Aggregations