use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class AbstractJvm method refreshSnapshots.
/**
* Refreshes the snapshots.
*/
protected void refreshSnapshots() {
snapshots = new ArrayList<ISnapshot>();
IPath baseDirectory;
try {
baseDirectory = getBaseDirectory();
} catch (JvmCoreException e) {
// do nothing
return;
}
File[] files = baseDirectory.toFile().listFiles();
if (files == null) {
return;
}
for (File file : files) {
String fileName = file.getName();
if (Snapshot.isValidFile(fileName)) {
Snapshot snapshot = new Snapshot(Util.getFileStore(fileName, baseDirectory), this);
snapshots.add(snapshot);
}
}
}
use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class MBeanServer method startUpdateTimer.
/**
* Starts the update timer.
*
* @param updatePeriod The update period
*/
private void startUpdateTimer(int updatePeriod) {
if (timer != null) {
timer.cancel();
}
timer = new Timer(true);
TimerTask timerTask = new TimerTask() {
@Override
public void run() {
try {
refresh();
} catch (JvmCoreException e) {
Activator.log(IStatus.ERROR, e.getMessage(), e);
timer.cancel();
} catch (Throwable t) {
timer.cancel();
}
}
};
timer.schedule(timerTask, 0, updatePeriod);
}
use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class JvmAttachHandler method getLocalConnectorAddress.
/**
* Gets the local connector address.
*
* @param monitoredVm The monitored JVM
* @param pid The process ID
*
* @return The local connector address
* @throws JvmCoreException
*/
private static String getLocalConnectorAddress(Object monitoredVm, int pid) throws JvmCoreException {
String url = null;
Tools tools = Tools.getInstance();
Object virtualMachine = null;
try {
virtualMachine = tools.invokeAttach(pid);
String javaHome = ((Properties) tools.invokeGetSystemProperties(virtualMachine)).getProperty(IConstants.JAVA_HOME_PROPERTY_KEY);
File file = new File(javaHome + IConstants.MANAGEMENT_AGENT_JAR);
if (!file.exists()) {
String message = NLS.bind(Messages.fileNotFoundMsg, file.getPath());
throw new JvmCoreException(IStatus.ERROR, message, new Exception());
}
tools.invokeLoadAgent(virtualMachine, file.getAbsolutePath(), IConstants.JMX_REMOTE_AGENT);
Properties props = tools.invokeGetAgentProperties(virtualMachine);
url = (String) props.get(LOCAL_CONNECTOR_ADDRESS);
} finally {
if (virtualMachine != null) {
try {
tools.invokeDetach(virtualMachine);
} catch (JvmCoreException e) {
// ignore
}
}
}
return url;
}
use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class Tools method invokeGetMonitoredHost.
/**
* Invokes the getMonitoredHost method of MonitoredHost with reflection.
*
* @param name The host name
* @return The monitored host
* @throws JvmCoreException
*/
protected synchronized Object invokeGetMonitoredHost(String name) throws JvmCoreException {
try {
Class<?> clazz = Class.forName(MONITORED_HOST_CLASS);
Method method = clazz.getDeclaredMethod(GET_MONITORED_HOST_CLASS, new Class[] { String.class });
return method.invoke(null, 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 invokeActiveVms.
/**
* Invokes the activeVms method of MonitoredHost with reflection.
*
* @param monitoredHost The monitored host
* @return The active VMs.
* @throws JvmCoreException
*/
@SuppressWarnings("unchecked")
protected Set<Integer> invokeActiveVms(Object monitoredHost) throws JvmCoreException {
try {
Class<?> clazz = Class.forName(MONITORED_HOST_CLASS);
Method method = clazz.getDeclaredMethod(ACTIVE_VMS_METHOD);
return (Set<Integer>) method.invoke(monitoredHost);
} catch (Throwable t) {
throw new JvmCoreException(IStatus.ERROR, t.getMessage(), t);
}
}
Aggregations