use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class HeapDumpHandler method getHeapHistogram.
/**
* Gets the heap histogram from target JVM.
* <p>
* e.g.
*
* <pre>
* num #instances #bytes class name
* ----------------------------------------------
* 1: 18329 2104376 <constMethodKlass>
* 2: 18329 1479904 <methodKlass>
* 3: 2518 1051520 [B
* 4: 11664 989856 [C
* 5: 11547 277128 java.lang.String
* </pre>
*
* @param virtualMachine The virtual machine
* @param isLive True to dump only live objects
* @return The heap histogram
* @throws JvmCoreException
*/
private static String getHeapHistogram(Object virtualMachine, boolean isLive) throws JvmCoreException {
InputStream in = Tools.getInstance().invokeHeapHisto(virtualMachine, isLive);
byte[] bytes = new byte[BUFFER_SIZE];
int length;
StringBuilder builder = new StringBuilder();
try {
while ((length = in.read(bytes)) != -1) {
String string = new String(bytes, 0, length, IConstants.UTF8);
builder.append(string);
}
} catch (UnsupportedEncodingException e) {
throw new JvmCoreException(IStatus.ERROR, Messages.charsetNotSupportedMsg, e);
} catch (IOException e) {
throw new JvmCoreException(IStatus.ERROR, Messages.readInputStreamFailedMsg, e);
} finally {
try {
in.close();
} catch (IOException e) {
// ignore
}
}
return builder.toString();
}
use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class Tools method invokeFindByName.
/**
* Invokes the findByName method of MonitoredVm with reflection.
*
* @param monitoredVm The monitored VM
* @param name The name
* @return The monitor
* @throws JvmCoreException
*/
protected Object invokeFindByName(Object monitoredVm, String name) throws JvmCoreException {
try {
Class<?> clazz = Class.forName(MONITORED_VM_CLASS);
Method method = clazz.getDeclaredMethod(FIND_BY_NAME_METHOD, new Class[] { String.class });
return method.invoke(monitoredVm, name);
} 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 invokeDetach.
/**
* Invokes the detach method of VirtualMachine with reflection.
*
* @param vm The virtual machine
* @throws JvmCoreException
*/
protected void invokeDetach(Object vm) throws JvmCoreException {
try {
Class<?> clazz = Class.forName(VIRTUAL_MACHINE_CLASS);
Method method = clazz.getDeclaredMethod(DETACH_METHOD);
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 invokeGetValue.
/**
* Invokes the getValue method of Monitor with reflection.
*
* @param monitor The monitor
* @return The value
* @throws JvmCoreException
*/
protected Object invokeGetValue(Object monitor) throws JvmCoreException {
try {
Class<?> clazz = Class.forName(MONITOR_CLASS);
Method method = clazz.getDeclaredMethod(GET_VALUE_METHOD);
return method.invoke(monitor);
} 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 invokeGetMonitoredVm.
/**
* Invokes the getMonitoredVm of MonitoredHost with reflection.
*
* @param monitoredHost The monitored host
* @param vmIdentifier The VM identifier
* @return The monitored VM
* @throws JvmCoreException
*/
protected synchronized Object invokeGetMonitoredVm(Object monitoredHost, Object vmIdentifier) throws JvmCoreException {
try {
Class<?> clazz = Class.forName(MONITORED_HOST_CLASS);
Class<?> clazz2 = Class.forName(VM_IDENTIFIER_CLASS);
Method method = clazz.getDeclaredMethod(GET_MONITORED_VM_METHOD, new Class[] { clazz2 });
return method.invoke(monitoredHost, vmIdentifier);
} catch (Throwable t) {
throw new JvmCoreException(IStatus.ERROR, t.getMessage(), t);
}
}
Aggregations