Search in sources :

Example 51 with JvmCoreException

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);
        }
    }
}
Also used : ISnapshot(org.talend.designer.runtime.visualization.ISnapshot) IPath(org.eclipse.core.runtime.IPath) ISnapshot(org.talend.designer.runtime.visualization.ISnapshot) File(java.io.File) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 52 with JvmCoreException

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);
}
Also used : Timer(java.util.Timer) TimerTask(java.util.TimerTask) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 53 with JvmCoreException

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;
}
Also used : Properties(java.util.Properties) File(java.io.File) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 54 with JvmCoreException

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);
    }
}
Also used : Method(java.lang.reflect.Method) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 55 with JvmCoreException

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);
    }
}
Also used : Set(java.util.Set) Method(java.lang.reflect.Method) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Aggregations

JvmCoreException (org.talend.designer.runtime.visualization.JvmCoreException)64 IOException (java.io.IOException)16 IActiveJvm (org.talend.designer.runtime.visualization.IActiveJvm)14 Method (java.lang.reflect.Method)11 ObjectName (javax.management.ObjectName)10 IFileStore (org.eclipse.core.filesystem.IFileStore)6 CoreException (org.eclipse.core.runtime.CoreException)6 IMonitoredMXBeanGroup (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup)6 File (java.io.File)5 Properties (java.util.Properties)5 IPath (org.eclipse.core.runtime.IPath)5 OutputStream (java.io.OutputStream)4 JMException (javax.management.JMException)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IHost (org.talend.designer.runtime.visualization.IHost)4 JvmModelEvent (org.talend.designer.runtime.visualization.JvmModelEvent)4 Date (java.util.Date)3 Timer (java.util.Timer)3 TimerTask (java.util.TimerTask)3 RGB (org.eclipse.swt.graphics.RGB)3