Search in sources :

Example 6 with DBAServerLock

use of org.jkiss.dbeaver.model.admin.locks.DBAServerLock in project dbeaver by dbeaver.

the class PostgreLockEditor method createLockViewer.

@SuppressWarnings("unchecked")
@Override
protected LockManagerViewer createLockViewer(DBCExecutionContext executionContext, Composite parent) {
    DBAServerLockManager<DBAServerLock, DBAServerLockItem> lockManager = (DBAServerLockManager) new PostgreLockManager((PostgreDataSource) executionContext.getDataSource());
    return new LockManagerViewer(this, parent, lockManager) {

        @Override
        protected void contributeToToolbar(DBAServerLockManager<DBAServerLock, DBAServerLockItem> sessionManager, IContributionManager contributionManager) {
            contributionManager.add(new Separator());
        }

        @Override
        protected void onLockSelect(final DBAServerLock lock) {
            super.onLockSelect(lock);
            if (lock != null) {
                final PostgreLock pLock = (PostgreLock) lock;
                super.refreshDetail(new HashMap<String, Object>() {

                    {
                        put(PostgreLockManager.pidHold, pLock.getHold_pid());
                        put(PostgreLockManager.pidWait, pLock.getWait_pid());
                    }
                });
            }
        }
    };
}
Also used : DBAServerLockItem(org.jkiss.dbeaver.model.admin.locks.DBAServerLockItem) PostgreDataSource(org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource) PostgreLockManager(org.jkiss.dbeaver.ext.postgresql.model.lock.PostgreLockManager) DBAServerLock(org.jkiss.dbeaver.model.admin.locks.DBAServerLock) PostgreLock(org.jkiss.dbeaver.ext.postgresql.model.lock.PostgreLock) DBAServerLockManager(org.jkiss.dbeaver.model.admin.locks.DBAServerLockManager) LockManagerViewer(org.jkiss.dbeaver.ext.ui.locks.manage.LockManagerViewer) IContributionManager(org.eclipse.jface.action.IContributionManager) Separator(org.eclipse.jface.action.Separator)

Example 7 with DBAServerLock

use of org.jkiss.dbeaver.model.admin.locks.DBAServerLock in project dbeaver by serge-rider.

the class ExasolLockEditor method createLockViewer.

@SuppressWarnings("unchecked")
@Override
protected LockManagerViewer createLockViewer(DBCExecutionContext executionContext, Composite parent) {
    @SuppressWarnings("rawtypes") DBAServerLockManager<DBAServerLock, DBAServerLockItem> lockManager = (DBAServerLockManager) new ExasolLockManager((ExasolDataSource) executionContext.getDataSource());
    return new LockManagerViewer(this, parent, lockManager) {

        @Override
        protected void contributeToToolbar(DBAServerLockManager<DBAServerLock, DBAServerLockItem> sessionManager, IContributionManager contributionManager) {
            contributionManager.add(new Separator());
        }

        @SuppressWarnings("serial")
        @Override
        protected void onLockSelect(final DBAServerLock lock) {
            super.onLockSelect(lock);
            if (lock != null) {
                final ExasolLock pLock = (ExasolLock) lock;
                super.refreshDetail(new HashMap<String, Object>() {

                    {
                        put(sidHold, BigInteger.valueOf(pLock.getHold_sid()));
                        put(sidWait, BigInteger.valueOf(pLock.getWait_sid().longValue()));
                    }
                });
            }
        }
    };
}
Also used : DBAServerLockItem(org.jkiss.dbeaver.model.admin.locks.DBAServerLockItem) ExasolLockManager(org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLockManager) ExasolLock(org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLock) DBAServerLock(org.jkiss.dbeaver.model.admin.locks.DBAServerLock) DBAServerLockManager(org.jkiss.dbeaver.model.admin.locks.DBAServerLockManager) ExasolDataSource(org.jkiss.dbeaver.ext.exasol.model.ExasolDataSource) LockManagerViewer(org.jkiss.dbeaver.ext.ui.locks.manage.LockManagerViewer) IContributionManager(org.eclipse.jface.action.IContributionManager) Separator(org.eclipse.jface.action.Separator)

Example 8 with DBAServerLock

use of org.jkiss.dbeaver.model.admin.locks.DBAServerLock in project dbeaver by serge-rider.

the class PostgreLockEditor method createLockViewer.

@SuppressWarnings("unchecked")
@Override
protected LockManagerViewer createLockViewer(DBCExecutionContext executionContext, Composite parent) {
    DBAServerLockManager<DBAServerLock, DBAServerLockItem> lockManager = (DBAServerLockManager) new PostgreLockManager((PostgreDataSource) executionContext.getDataSource());
    return new LockManagerViewer(this, parent, lockManager) {

        @Override
        protected void contributeToToolbar(DBAServerLockManager<DBAServerLock, DBAServerLockItem> sessionManager, IContributionManager contributionManager) {
            contributionManager.add(new Separator());
        }

        @Override
        protected void onLockSelect(final DBAServerLock lock) {
            super.onLockSelect(lock);
            if (lock != null) {
                final PostgreLock pLock = (PostgreLock) lock;
                super.refreshDetail(new HashMap<String, Object>() {

                    {
                        put(PostgreLockManager.pidHold, pLock.getHold_pid());
                        put(PostgreLockManager.pidWait, pLock.getWait_pid());
                    }
                });
            }
        }
    };
}
Also used : DBAServerLockItem(org.jkiss.dbeaver.model.admin.locks.DBAServerLockItem) PostgreDataSource(org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource) PostgreLockManager(org.jkiss.dbeaver.ext.postgresql.model.lock.PostgreLockManager) DBAServerLock(org.jkiss.dbeaver.model.admin.locks.DBAServerLock) PostgreLock(org.jkiss.dbeaver.ext.postgresql.model.lock.PostgreLock) DBAServerLockManager(org.jkiss.dbeaver.model.admin.locks.DBAServerLockManager) LockManagerViewer(org.jkiss.dbeaver.ext.ui.locks.manage.LockManagerViewer) IContributionManager(org.eclipse.jface.action.IContributionManager) Separator(org.eclipse.jface.action.Separator)

Example 9 with DBAServerLock

use of org.jkiss.dbeaver.model.admin.locks.DBAServerLock in project dbeaver by dbeaver.

the class LockGraphManager method createGraph.

@SuppressWarnings("unchecked")
private LockGraph createGraph(DBAServerLock root) {
    LockGraph graph = new LockGraph(root);
    int maxWidth = 1;
    int level = 1;
    LockGraphNode nodeRoot = nodes.get(root.getId());
    nodeRoot.setLevel(0);
    nodeRoot.setSpan(1);
    graph.getNodes().add(nodeRoot);
    graphIndex.put(root.getId(), graph);
    List<DBAServerLock> current = new ArrayList<>();
    // Prevent Cycle
    Set<DBAServerLock> touched = new HashSet<>();
    current.add(root);
    touched.add(root);
    Map<Object, DBAServerLock> childs = new HashMap<>();
    while (current.size() > 0) {
        if (maxWidth < current.size()) {
            maxWidth = current.size();
        }
        for (int index = 0; index < current.size(); index++) {
            DBAServerLock l = (DBAServerLock) current.get(index);
            LockGraphNode node = nodes.get(l.getId());
            if (index == 0) {
                node.setLevelPosition(LockGraphNode.LevelPosition.LEFT);
            } else if (index == current.size() - 1) {
                node.setLevelPosition(LockGraphNode.LevelPosition.RIGHT);
            } else {
                node.setLevelPosition(LockGraphNode.LevelPosition.CENTER);
            }
            node.setSpan(current.size());
            for (DBAServerLock c : l.waitThis()) {
                if (touched.contains(c))
                    continue;
                touched.add(c);
                childs.put(c.getId(), c);
                graphIndex.put(c.getId(), graph);
                LockGraphNode nodeChild = nodes.get(c.getId());
                graph.getNodes().add(nodeChild);
                nodeChild.setLevel(level);
                LockGraphEdge edge = new LockGraphEdge();
                edge.setSource(node);
                edge.setTarget(nodeChild);
            }
        }
        level++;
        current = new ArrayList<>(childs.values());
        childs.clear();
    }
    graph.setMaxWidth(maxWidth);
    return graph;
}
Also used : HashMap(java.util.HashMap) LockGraphEdge(org.jkiss.dbeaver.ext.ui.locks.graph.LockGraphEdge) ArrayList(java.util.ArrayList) LockGraphNode(org.jkiss.dbeaver.ext.ui.locks.graph.LockGraphNode) LockGraph(org.jkiss.dbeaver.ext.ui.locks.graph.LockGraph) DBAServerLock(org.jkiss.dbeaver.model.admin.locks.DBAServerLock) HashSet(java.util.HashSet)

Example 10 with DBAServerLock

use of org.jkiss.dbeaver.model.admin.locks.DBAServerLock in project dbeaver by dbeaver.

the class LockGraphManager method buildGraphs.

@SuppressWarnings({ "unchecked", "rawtypes" })
public void buildGraphs(Map<Object, ? extends DBAServerLock> locks) {
    Set<DBAServerLock> roots = new HashSet<>();
    this.nodes.clear();
    this.graphIndex.clear();
    for (DBAServerLock l : locks.values()) {
        if (locks.containsKey(l.getHoldID()) && (!l.getHoldID().equals(l.getId()))) {
            DBAServerLock holder = locks.get(l.getHoldID());
            l.setHoldBy(holder);
            holder.waitThis().add(l);
        } else {
            roots.add(l);
        }
        nodes.put(l.getId(), new LockGraphNode(l));
    }
    for (DBAServerLock root : roots) {
        createGraph(root);
    }
}
Also used : DBAServerLock(org.jkiss.dbeaver.model.admin.locks.DBAServerLock) HashSet(java.util.HashSet) LockGraphNode(org.jkiss.dbeaver.ext.ui.locks.graph.LockGraphNode)

Aggregations

DBAServerLock (org.jkiss.dbeaver.model.admin.locks.DBAServerLock)15 IContributionManager (org.eclipse.jface.action.IContributionManager)9 Separator (org.eclipse.jface.action.Separator)9 LockManagerViewer (org.jkiss.dbeaver.ext.ui.locks.manage.LockManagerViewer)9 DBAServerLockItem (org.jkiss.dbeaver.model.admin.locks.DBAServerLockItem)9 DBAServerLockManager (org.jkiss.dbeaver.model.admin.locks.DBAServerLockManager)9 ExasolDataSource (org.jkiss.dbeaver.ext.exasol.model.ExasolDataSource)3 ExasolLock (org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLock)3 ExasolLockManager (org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLockManager)3 OracleDataSource (org.jkiss.dbeaver.ext.oracle.model.OracleDataSource)3 OracleLock (org.jkiss.dbeaver.ext.oracle.model.lock.OracleLock)3 OracleLockManager (org.jkiss.dbeaver.ext.oracle.model.lock.OracleLockManager)3 PostgreDataSource (org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource)3 PostgreLock (org.jkiss.dbeaver.ext.postgresql.model.lock.PostgreLock)3 PostgreLockManager (org.jkiss.dbeaver.ext.postgresql.model.lock.PostgreLockManager)3 HashSet (java.util.HashSet)2 LockGraphNode (org.jkiss.dbeaver.ext.ui.locks.graph.LockGraphNode)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LockGraph (org.jkiss.dbeaver.ext.ui.locks.graph.LockGraph)1