use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class Tools method invokeAttach.
/**
* Invokes the attach method of VirtualMachine with reflection.
*
* @param pid The process ID
* @return The virtual machine
* @throws JvmCoreException
*/
protected Object invokeAttach(int pid) throws JvmCoreException {
try {
Class<?> clazz = Class.forName(VIRTUAL_MACHINE_CLASS);
Method method = clazz.getDeclaredMethod(ATTACH_METHOD, new Class[] { String.class });
return method.invoke(null, String.valueOf(pid));
} catch (Throwable t) {
throw new JvmCoreException(IStatus.ERROR, t.getCause().getMessage(), t);
}
}
use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class Tools method invokeHeapHisto.
/**
* Invokes the heapHisto method of HotSpotVirtualMachine with reflection.
*
* @param virtualMachine The virtual machine
* @param isLive True to dump only live objects
* @return The input stream of heap histo
* @throws JvmCoreException
*/
protected InputStream invokeHeapHisto(Object virtualMachine, boolean isLive) throws JvmCoreException {
try {
Class<?> clazz = Class.forName(HOT_SPOT_VIRTUAL_MACHINE_CLASS);
Method method = clazz.getDeclaredMethod(HEAP_HISTO_METHOD, new Class[] { Object[].class });
Object[] arg = new Object[] { isLive ? HEAP_HISTO_LIVE_OPTION : HEAP_HISTO_ALL_OPTION };
return (InputStream) method.invoke(virtualMachine, (Object) arg);
} 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 SWTResourcesPage method refresh.
/**
* Refreshes the appearance.
*
* @param force <tt>true</tt> to force refresh
*/
protected void refresh(final boolean force) {
final boolean isVisible = isVisible();
new RefreshJob(NLS.bind(Messages.refreshMemorySectionJobLabel, section.getJvm().getPid()), toString()) {
@Override
protected void refreshModel(IProgressMonitor monitor) {
try {
IActiveJvm jvm = section.getJvm();
if (isVisible && jvm != null && jvm.isConnected() && (!section.isRefreshSuspended() || force) && jvm.getSWTResourceMonitor().isSupported()) {
jvm.getSWTResourceMonitor().refreshResourcesCache();
}
} catch (JvmCoreException e) {
Activator.log(Messages.refreshHeapDataFailedMsg, e);
}
}
@Override
protected void refreshUI() {
IActiveJvm jvm = section.getJvm();
boolean isConnected = jvm != null && jvm.isConnected();
if (!isDisposed()) {
refreshBackground();
}
refreshAction.setEnabled(isConnected);
clearSWTResourceAction.setEnabled(isConnected);
if (!force && section.isRefreshSuspended() || !isVisible) {
return;
}
TreeViewer resourceViewer = resourceFilteredTree.getViewer();
if (!resourceViewer.getControl().isDisposed()) {
resourceViewer.refresh();
if (jvm != null) {
resourceFilteredTree.updateStatusLine(jvm.getSWTResourceMonitor().getResources());
}
// select the first item if no item is selected
if (resourceViewer.getSelection().isEmpty()) {
TreeItem[] items = resourceViewer.getTree().getItems();
if (items != null && items.length > 0) {
resourceViewer.getTree().select(items[0]);
stackTraceViewer.setInput(resourceViewer.getSelection());
} else {
stackTraceViewer.setInput(null);
}
}
}
if (!stackTraceViewer.getControl().isDisposed()) {
stackTraceViewer.refresh();
}
}
}.schedule();
}
use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class ConfigureChartAction method performConfiguration.
/**
* Performs the configuration.
*
* @param chartTitle The chart title
* @param axisUnit The axis unit
* @param attributes The attributes
* @param removedAttributes The removed attributes
*/
private void performConfiguration(String chartTitle, AxisUnit axisUnit, List<MBeanAttribute> attributes, List<MBeanAttribute> removedAttributes) {
IMonitoredMXBeanGroup group = chart.getAttributeGroup();
group.setName(chartTitle);
group.setAxisUnit(axisUnit);
for (MBeanAttribute attribute : attributes) {
ObjectName objectName = attribute.getObjectName();
String attributeName = attribute.getAttributeName();
IMonitoredMXBeanAttribute monitoredAttribute = group.getAttribute(objectName, attributeName);
RGB rgb = attribute.getRgb();
if (monitoredAttribute == null) {
try {
group.addAttribute(objectName.getCanonicalName(), attributeName, new int[] { rgb.red, rgb.green, rgb.blue });
} catch (JvmCoreException e) {
Activator.log(Messages.addAttributeFailedMsg, e);
}
} else {
monitoredAttribute.setRGB(rgb.red, rgb.green, rgb.blue);
}
}
for (MBeanAttribute removedAttribute : removedAttributes) {
group.removeAttribute(removedAttribute.getObjectName().getCanonicalName(), removedAttribute.getAttributeName());
}
chart.refresh();
}
use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class CpuSection method setProfiledPackages.
/**
* Sets the profiled packages to CPU profiler.
*/
void setProfiledPackages() {
IActiveJvm jvm = getJvm();
if (jvm == null) {
return;
}
Set<String> packages = new LinkedHashSet<String>();
String packagesString = Activator.getDefault().getDialogSettings(CpuSection.class.getName()).get(IConstants.PACKAGES_KEY);
if (packagesString != null) {
if (packagesString.contains(",")) {
//$NON-NLS-1$
for (String item : packagesString.split(",")) {
//$NON-NLS-1$
packages.add(item);
}
} else if (!packagesString.isEmpty()) {
packages.add(packagesString);
}
try {
jvm.getCpuProfiler().setProfiledPackages(packages);
} catch (JvmCoreException e) {
Activator.log(Messages.setProfiledPackagesFailedMsg, e);
}
}
}
Aggregations