use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class Tools method invokeGetSystemProperties.
/**
* Invokes the getSystemProperties method of VirtualMachine with reflection.
*
* @param vm The virtual machine
* @return The system properties
* @throws JvmCoreException
*/
protected Object invokeGetSystemProperties(Object vm) throws JvmCoreException {
try {
Class<?> clazz = Class.forName(VIRTUAL_MACHINE_CLASS);
Method method = clazz.getDeclaredMethod(GET_SYSTEM_PROPERTIES_METHOD);
return method.invoke(vm);
} catch (Throwable t) {
throw new JvmCoreException(IStatus.ERROR, t.getMessage(), t);
}
}
use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class Tools method invokeGetAgentProperties.
/**
* Invokes the getAgentProperties method of VirtualMachine
*
* @param virtualMachine The virtual machine
* @return The agent properties
* @throws JvmCoreException
*/
protected Properties invokeGetAgentProperties(Object virtualMachine) throws JvmCoreException {
try {
Class<?> clazz = Class.forName(VIRTUAL_MACHINE_CLASS);
Method method = clazz.getDeclaredMethod(GET_AGENT_PROPERTIES_METHOD);
return (Properties) method.invoke(virtualMachine);
} catch (Throwable t) {
throw new JvmCoreException(IStatus.ERROR, t.getMessage(), t);
}
}
use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class Tools method invokeLoadAgent.
/**
* Invokes the loadAgent method of VirtualMachine with reflection.
*
* @param virtualMachine The virtual machine
* @param path The path for agent jar file
* @param options The options given to agent
* @throws JvmCoreException
*/
protected void invokeLoadAgent(Object virtualMachine, String path, String options) throws JvmCoreException {
try {
Class<?> clazz = Class.forName(VIRTUAL_MACHINE_CLASS);
Method method = clazz.getDeclaredMethod(LOAD_AGENT_METHOD, new Class[] { String.class, String.class });
method.invoke(virtualMachine, path, options);
} catch (Throwable t) {
String message = t.getMessage();
if (message == null) {
Throwable cause = t.getCause();
while (cause != null) {
message = cause.getMessage();
if (message != null) {
break;
}
cause = cause.getCause();
}
}
throw new JvmCoreException(IStatus.ERROR, message, t);
}
}
use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class CpuProfiler method refreshBciProfileCache.
/*
* @see ICpuProfiler#refreshBciProfileCache(IProgressMonitor)
*/
@Override
public void refreshBciProfileCache(IProgressMonitor monitor) throws JvmCoreException {
if (type != ProfilerType.BCI) {
return;
}
validateAgent();
if (!isBciProfilerRunning()) {
return;
}
String dumpString = (String) invokeCpuProfilerMXBeanMethod(DUMP, null, null);
if (dumpString == null) {
return;
}
ByteArrayInputStream input = null;
try {
input = new ByteArrayInputStream(dumpString.getBytes());
CpuDumpParser parser = new CpuDumpParser(input, cpuModel, monitor);
parser.parse();
} catch (ParserConfigurationException e) {
throw new JvmCoreException(IStatus.ERROR, Messages.parseCpuDumpFailedMsg, e);
} catch (SAXException e) {
throw new JvmCoreException(IStatus.ERROR, Messages.parseCpuDumpFailedMsg, e);
} catch (IOException e) {
throw new JvmCoreException(IStatus.ERROR, Messages.parseCpuDumpFailedMsg, e);
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
// do nothing
}
}
}
}
use of org.talend.designer.runtime.visualization.JvmCoreException 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