Search in sources :

Example 46 with JvmCoreException

use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.

the class MBeanServer method setAttribute.

/*
     * @see IMBeanServer#setAttribute(ObjectName, Attribute)
     */
@Override
public void setAttribute(ObjectName objectName, Attribute attribute) throws JvmCoreException {
    Assert.isNotNull(objectName);
    Assert.isNotNull(attribute);
    if (!checkReachability()) {
        return;
    }
    try {
        connection.setAttribute(objectName, attribute);
    } catch (JMException e) {
        throw new JvmCoreException(IStatus.ERROR, NLS.bind(Messages.setAttributeFailedMsg, attribute.getName()), e);
    } catch (IOException e) {
        throw new JvmCoreException(IStatus.ERROR, NLS.bind(Messages.setAttributeFailedMsg, attribute.getName()), e);
    }
}
Also used : JMException(javax.management.JMException) IOException(java.io.IOException) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 47 with JvmCoreException

use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.

the class ShowInTimelineAction method performShowInTimeline.

/**
     * Performs showing a new chart with attributes in Timeline tab.
     * 
     * @param chartTitle The chart title
     * @param axisUnit The axis unit
     * @param attributes The attributes
     */
private void performShowInTimeline(String chartTitle, AxisUnit axisUnit, List<MBeanAttribute> attributes) {
    IActiveJvm jvm = section.getJvm();
    if (jvm == null) {
        return;
    }
    IMonitoredMXBeanGroup group = jvm.getMBeanServer().addMonitoredAttributeGroup(chartTitle, axisUnit);
    for (MBeanAttribute attribute : attributes) {
        ObjectName objectName = attribute.getObjectName();
        String attributeName = attribute.getAttributeName();
        RGB rgb = attribute.getRgb();
        try {
            group.addAttribute(objectName.getCanonicalName(), attributeName, new int[] { rgb.red, rgb.green, rgb.blue });
        } catch (JvmCoreException e) {
            Activator.log(NLS.bind(Messages.addAttributeFailedMsg, attributeName), e);
        }
    }
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) IMonitoredMXBeanGroup(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup) MBeanAttribute(org.talend.designer.runtime.visualization.internal.ui.properties.timeline.MBeanAttribute) RGB(org.eclipse.swt.graphics.RGB) ObjectName(javax.management.ObjectName) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 48 with JvmCoreException

use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.

the class MBeanServer method connectToMBeanServer.

/**
     * Connects to the MBean server in the given VM.
     * 
     * @param url The JMX service URL
     * @return The MBean server connection
     * @throws JvmCoreException
     */
private MBeanServerConnection connectToMBeanServer(JMXServiceURL url) throws JvmCoreException {
    JMXConnector jmxc;
    try {
        if (jvm.getUserName() != null && jvm.getPassword() != null) {
            Map<String, String[]> env = new HashMap<String, String[]>();
            env.put(JMXConnector.CREDENTIALS, new String[] { jvm.getUserName(), jvm.getPassword() });
            jmxc = JMXConnectorFactory.connect(url, env);
        } else {
            jmxc = JMXConnectorFactory.connect(url);
        }
        return jmxc.getMBeanServerConnection();
    } catch (IOException e) {
        IHost host = jvm.getHost();
        if (host != null && host.getActiveJvms().contains(jvm)) {
            host.removeJvm(jvm.getPid());
        }
        throw new JvmCoreException(IStatus.INFO, Messages.connectToMBeanServerFailedMsg, e);
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) JMXConnector(javax.management.remote.JMXConnector) IHost(org.talend.designer.runtime.visualization.IHost) IOException(java.io.IOException) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 49 with JvmCoreException

use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.

the class MBeanServer method invoke.

/*
     * @see IMBeanServer#invoke(ObjectName, String, String[], String[])
     */
@Override
public Object invoke(ObjectName objectName, String method, Object[] params, String[] signatures) throws JvmCoreException {
    Assert.isNotNull(objectName);
    Assert.isNotNull(method);
    if (!checkReachability()) {
        return null;
    }
    try {
        return connection.invoke(objectName, method, params, signatures);
    } catch (JMException e) {
        throw new JvmCoreException(IStatus.ERROR, NLS.bind(Messages.mBeanOperationFailedMsg, method), e);
    } catch (IOException e) {
        throw new JvmCoreException(IStatus.ERROR, NLS.bind(Messages.mBeanOperationFailedMsg, method), e);
    }
}
Also used : JMException(javax.management.JMException) IOException(java.io.IOException) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 50 with JvmCoreException

use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.

the class AbstractJvm method getBaseDirectory.

/**
     * Gets the base directory.
     * 
     * @return The base directory
     * @throws JvmCoreException
     */
public IPath getBaseDirectory() throws JvmCoreException {
    IPath stateLocation = Activator.getDefault().getStateLocation();
    IPath dirPath = stateLocation.append(File.separator + host.getName() + Host.DIR_SUFFIX + File.separator + pid + IJvm.DIR_SUFFIX);
    if (!dirPath.toFile().exists() && !dirPath.toFile().mkdir()) {
        throw new JvmCoreException(IStatus.ERROR, NLS.bind(Messages.createDirectoryFailedMsg, dirPath.toFile().getName()), null);
    }
    return dirPath;
}
Also used : IPath(org.eclipse.core.runtime.IPath) 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