Search in sources :

Example 11 with JvmCoreException

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

the class AttributeContentProvider method refresh.

/**
     * Refreshes the content provider.
     * 
     * @param jvm The JVM
     * @param objectName The object name
     * @throws JvmCoreException
     */
protected void refresh(IActiveJvm jvm, ObjectName objectName) throws JvmCoreException {
    MBeanInfo mBeanInfo = null;
    List<AttributeNode> nodes = new ArrayList<AttributeNode>();
    try {
        mBeanInfo = jvm.getMBeanServer().getMBeanInfo(objectName);
    } catch (JvmCoreException e) {
        attributeRootNodes = nodes;
        throw e;
    }
    if (mBeanInfo == null) {
        attributeRootNodes = nodes;
        return;
    }
    AttributeParser parser = new AttributeParser();
    for (MBeanAttributeInfo attributeInfo : mBeanInfo.getAttributes()) {
        String name = attributeInfo.getName();
        Object value = getAttributeValue(jvm, objectName, name);
        AttributeNode attributeNode = null;
        for (AttributeNode node : attributeRootNodes) {
            if (node.getName().equals(name)) {
                attributeNode = node;
                attributeNode.setValue(value);
                break;
            }
        }
        if (attributeNode == null) {
            attributeNode = new AttributeNode(name, null, value);
        }
        parser.refreshAttribute(attributeNode);
        attributeNode.setWritable(attributeInfo.isWritable());
        nodes.add(attributeNode);
    }
    Collections.sort(nodes, new Comparator<AttributeNode>() {

        @Override
        public int compare(AttributeNode o1, AttributeNode o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });
    attributeRootNodes = nodes;
}
Also used : MBeanInfo(javax.management.MBeanInfo) ArrayList(java.util.ArrayList) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 12 with JvmCoreException

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

the class SWTResourceMonitor method isSupported.

/*
     * @see ISWTResourceMonitor#isSupported()
     */
@Override
public boolean isSupported() {
    try {
        ObjectName objectName = validateAgent();
        if (objectName == null) {
            return false;
        }
        Object attribute = jvm.getMBeanServer().getAttribute(objectName, TRACKING);
        return attribute != null;
    } catch (JvmCoreException e) {
        return false;
    }
}
Also used : ObjectName(javax.management.ObjectName) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 13 with JvmCoreException

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

the class Snapshot method rename.

/*
     * @see ISnapshot#rename(String)
     */
@Override
public void rename(String newName) throws JvmCoreException {
    File file = new File(fileStore.toURI());
    String newFilePath = fileStore.getParent().toURI().getPath() + File.separator + newName;
    File destFile = new File(newFilePath);
    if (file.renameTo(destFile)) {
        if (jvm instanceof AbstractJvm) {
            ((AbstractJvm) jvm).refreshSnapshots();
        }
    } else {
        throw new JvmCoreException(IStatus.ERROR, NLS.bind(Messages.renameFileFailedMsg, fileStore.toURI().getPath()), null);
    }
}
Also used : File(java.io.File) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 14 with JvmCoreException

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

the class OverviewProperties method refreshPropertyValues.

/**
     * Refreshes the property values.
     */
private void refreshPropertyValues() {
    for (List<OverviewProperty> properties : overviewProperties.values()) {
        for (OverviewProperty property : properties) {
            try {
                ObjectName objectName = ObjectName.getInstance(property.getObjectName());
                String attributeName = property.getAttributeName();
                Object attribute = activeJvm.getMBeanServer().getAttribute(objectName, attributeName);
                property.setValue(attribute);
            } catch (JvmCoreException e) {
                Activator.log(Messages.getMBeanAttributeFailedMsg, e);
            } catch (JMException e) {
                Activator.log(IStatus.ERROR, Messages.getMBeanAttributeFailedMsg, e);
            }
        }
    }
}
Also used : JMException(javax.management.JMException) ObjectName(javax.management.ObjectName) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 15 with JvmCoreException

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

the class OverviewProperties method addGarbageCollectionProperties.

/**
     * Adds the garbage collection properties.
     */
private void addGarbageCollectionProperties() {
    List<OverviewProperty> list = new ArrayList<OverviewProperty>();
    try {
        //$NON-NLS-1$
        ObjectName queryObjectName = ObjectName.getInstance("java.lang:type=GarbageCollector,name=*");
        Set<ObjectName> objectNames = activeJvm.getMBeanServer().queryNames(queryObjectName);
        for (ObjectName objectName : objectNames) {
            //$NON-NLS-1$
            String name = objectName.getKeyProperty("name");
            list.add(new OverviewProperty(OverviewCategory.GarbageCollector, NLS.bind(Messages.collectionCountLabel, name), "CollectionCount", name, null, //$NON-NLS-1$
            true));
            list.add(new OverviewProperty(OverviewCategory.GarbageCollector, NLS.bind(Messages.collectionTimeLabel, name), "CollectionTime", name, IFormat.MILLISEC_FORMAT, //$NON-NLS-1$
            true));
        }
    } catch (MalformedObjectNameException e) {
        Activator.log(IStatus.ERROR, Messages.getObjectNameFailedMsg, e);
    } catch (JvmCoreException e) {
        Activator.log(Messages.getObjectNameFailedMsg, e);
    }
    overviewProperties.put(OverviewCategory.GarbageCollector, list);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) ArrayList(java.util.ArrayList) ObjectName(javax.management.ObjectName) 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