Search in sources :

Example 1 with IThreadElement

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

the class ThreadComparator method compare.

/*
     * @see ViewerComparator#compare(Viewer, Object, Object)
     */
@Override
public int compare(Viewer treeViewer, Object e1, Object e2) {
    int result = 0;
    if (!(e1 instanceof IThreadElement) || !(e2 instanceof IThreadElement) || !(treeViewer instanceof TreeViewer)) {
        return result;
    }
    IThreadElement element1 = (IThreadElement) e1;
    IThreadElement element2 = (IThreadElement) e2;
    Tree tree = ((TreeViewer) treeViewer).getTree();
    if (columnIndex == getColumnIndex(tree, ThreadColumn.THREAD)) {
        result = super.compare(treeViewer, element1.getThreadName(), element2.getThreadName());
    } else if (columnIndex == getColumnIndex(tree, ThreadColumn.STATE)) {
        String state1 = element1.getThreadState().name();
        String state2 = element2.getThreadState().name();
        if (element1.isDeadlocked()) {
            //$NON-NLS-1$
            state1 = "DEADLOCKED";
        }
        if (element2.isDeadlocked()) {
            //$NON-NLS-1$
            state2 = "DEADLOCKED";
        }
        result = super.compare(treeViewer, state1, state2);
    } else if (columnIndex == getColumnIndex(tree, ThreadColumn.CPU)) {
        result = (element1.getCpuUsage() > element2.getCpuUsage()) ? 1 : -1;
    } else if (columnIndex == getColumnIndex(tree, ThreadColumn.BLOCKED_TIME)) {
        long time1 = element1.getBlockedTime();
        long time2 = element2.getBlockedTime();
        result = (time1 > time2) ? 1 : -1;
    } else if (columnIndex == getColumnIndex(tree, ThreadColumn.BLOCKED_COUNT)) {
        long count1 = element1.getBlockedCount();
        long count2 = element2.getBlockedCount();
        result = (count1 > count2) ? 1 : -1;
    } else if (columnIndex == getColumnIndex(tree, ThreadColumn.WAITED_TIME)) {
        long time1 = element1.getWaitedTime();
        long time2 = element2.getWaitedTime();
        result = (time1 > time2) ? 1 : -1;
    } else if (columnIndex == getColumnIndex(tree, ThreadColumn.WAITED_COUNT)) {
        long count1 = element1.getWaitedCount();
        long count2 = element2.getWaitedCount();
        result = (count1 > count2) ? 1 : -1;
    } else if (columnIndex == getColumnIndex(tree, ThreadColumn.LOCK)) {
        result = super.compare(treeViewer, element1.getLockName(), element2.getLockName());
    } else if (columnIndex == getColumnIndex(tree, ThreadColumn.LOCK_OWNWER)) {
        result = super.compare(treeViewer, element1.getLockOwnerName(), element2.getLockOwnerName());
    }
    if (sortDirection == SWT.DOWN) {
        result *= -1;
    }
    return result;
}
Also used : IThreadElement(org.talend.designer.runtime.visualization.IThreadElement) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Tree(org.eclipse.swt.widgets.Tree)

Example 2 with IThreadElement

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

the class ThreadDumpEditor method createThreadsPage.

/**
     * Creates the threads page.
     */
private void createThreadsPage() {
    threadSashForm = new ThreadSashForm(getContainer(), getEditorSite().getActionBars());
    threadSashForm.setInput(new IThreadInput() {

        @Override
        public IThreadElement[] getThreadListElements() {
            return threadListElements.toArray(new IThreadElement[0]);
        }
    });
    int page = addPage(threadSashForm);
    setPageText(page, Messages.threadsTabLabel);
    setPageImage(page, getThreadImage());
    threadSashForm.refresh();
}
Also used : IThreadElement(org.talend.designer.runtime.visualization.IThreadElement) IThreadInput(org.talend.designer.runtime.visualization.internal.ui.properties.thread.IThreadInput) ThreadSashForm(org.talend.designer.runtime.visualization.internal.ui.properties.thread.ThreadSashForm)

Example 3 with IThreadElement

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

the class MBeanServer method getThreadNames.

/*
     * @see IMBeanServer#getThreadNames()
     */
@Override
public String[] getThreadNames() throws JvmCoreException {
    IThreadElement[] threads = getThreadCache();
    List<String> threadNames = new ArrayList<String>();
    for (IThreadElement thread : threads) {
        threadNames.add(thread.getThreadName());
    }
    return threadNames.toArray(new String[0]);
}
Also used : IThreadElement(org.talend.designer.runtime.visualization.IThreadElement) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList)

Example 4 with IThreadElement

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

the class ActiveJvm method refreshMainClass.

/**
     * Refreshes the main class.
     * 
     * @throws JvmCoreException
     */
private void refreshMainClass() throws JvmCoreException {
    mBeanServer.refreshThreadCache();
    for (IThreadElement element : mBeanServer.getThreadCache()) {
        if (element.getThreadName().equals(MAIN_THREAD)) {
            StackTraceElement[] elements = element.getStackTraceElements();
            if (elements == null || elements.length == 0) {
                return;
            }
            StackTraceElement lastElement = elements[elements.length - 1];
            setMainClass(lastElement.getClassName());
            break;
        }
    }
}
Also used : IThreadElement(org.talend.designer.runtime.visualization.IThreadElement)

Aggregations

IThreadElement (org.talend.designer.runtime.visualization.IThreadElement)4 ArrayList (java.util.ArrayList)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Tree (org.eclipse.swt.widgets.Tree)1 IThreadInput (org.talend.designer.runtime.visualization.internal.ui.properties.thread.IThreadInput)1 ThreadSashForm (org.talend.designer.runtime.visualization.internal.ui.properties.thread.ThreadSashForm)1