From 667e97d5bbff7c6b95a73711d385bf5ae28659e1 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Wed, 25 Mar 2009 18:58:24 +0000 Subject: [PATCH] [190805] [performance][dstore] Right-click > Disconnect on a dstore connection is slow and spawns many Jobs --- .../events/ISystemResourceChangeEvents.java | 3 +- .../files/dstore/DStoreFileAdapter.java | 6 +- .../RemoteFilePropertyChangeListener.java | 130 +++++------------- .../rse/internal/ui/view/SystemView.java | 39 ++++-- 4 files changed, 75 insertions(+), 103 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/events/ISystemResourceChangeEvents.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/events/ISystemResourceChangeEvents.java index 4f329a71b8b..4b03ad6067f 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/events/ISystemResourceChangeEvents.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/events/ISystemResourceChangeEvents.java @@ -14,6 +14,7 @@ * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core * Martin Oberhuber (Wind River) - [cleanup] Add API "since" Javadoc tags * Martin Oberhuber (Wind River) - [261486][api][cleanup] Mark @noimplement interfaces as @noextend + * David McKnight (IBM) - [190805] [performance][dstore] Right-click > Disconnect on a dstore connection is slow and spawns many Jobs ********************************************************************************/ package org.eclipse.rse.core.events; @@ -137,7 +138,7 @@ public interface ISystemResourceChangeEvents /** * The event is an icon change event - * A source RSE object and it's parent RSE object are the expected parameters + * A source RSE object or an array of source RSE objects and the parent RSE object are the expected parameters */ public static final int EVENT_ICON_CHANGE = 81; diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/internal/subsystems/files/dstore/DStoreFileAdapter.java b/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/internal/subsystems/files/dstore/DStoreFileAdapter.java index 32221767d19..0a30513015e 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/internal/subsystems/files/dstore/DStoreFileAdapter.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/internal/subsystems/files/dstore/DStoreFileAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. + * Copyright (c) 2006, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,6 +16,7 @@ * Martin Oberhuber (Wind River) - [235363][api][breaking] IHostFileToRemoteFileAdapter methods should return AbstractRemoteFile * David McKnight (IBM) - [244765] Invalid thread access during workbench termination * David McKnight (IBM) - [255699] NPE when filter string doesn't return result in FileServiceSubSystem.list + * David McKnight (IBM) - [190805] [performance][dstore] Right-click > Disconnect on a dstore connection is slow and spawns many Jobs *******************************************************************************/ package org.eclipse.rse.internal.subsystems.files.dstore; @@ -43,6 +44,9 @@ public class DStoreFileAdapter implements IHostFileToRemoteFileAdapter private void registerFilePropertyChangeListener(FileServiceSubSystem ss) { + if (_listener != null && _listener.isFinished()){ + _listener = null; + } if (_listener == null) { DStoreConnectorService connectorService = (DStoreConnectorService)ss.getConnectorService(); diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/internal/subsystems/files/dstore/RemoteFilePropertyChangeListener.java b/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/internal/subsystems/files/dstore/RemoteFilePropertyChangeListener.java index e4486c55506..f3866f5ee88 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/internal/subsystems/files/dstore/RemoteFilePropertyChangeListener.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/internal/subsystems/files/dstore/RemoteFilePropertyChangeListener.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2008 IBM Corporation and others. + * Copyright (c) 2002, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,7 @@ * Contributors: * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry + * David McKnight (IBM) - [190805] [performance][dstore] Right-click > Disconnect on a dstore connection is slow and spawns many Jobs *******************************************************************************/ package org.eclipse.rse.internal.subsystems.files.dstore; @@ -40,8 +41,6 @@ import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants; import org.eclipse.rse.internal.subsystems.files.core.SystemFileResources; import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; -import org.eclipse.rse.ui.SystemBasePlugin; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.progress.UIJob; @@ -64,42 +63,15 @@ public class RemoteFilePropertyChangeListener implements IDomainListener, protected boolean _networkDown = false; protected HashMap _decorateJobs; - - protected static class FindShell implements Runnable - { - - private Shell shell; - - /** - * @see Runnable#run() - */ - public void run() - { - try - { - Shell[] shells = Display.getCurrent().getShells(); - for (int loop = 0; loop < shells.length && shell == null; loop++) - { - if (shells[loop].isEnabled()) - { - shell = shells[loop]; - } - } - } - catch (Exception e) - { - SystemBasePlugin.logError( - "StatusChangeListener.FindShell exception: ", e); //$NON-NLS-1$ - } - } - } + + protected boolean _finished = false; public class DecorateJob extends UIJob { - private DStoreFile[] _files; + private DataElement[] _files; private DStoreFile _parentFile; private boolean _isDone = false; - public DecorateJob(DStoreFile[] files, DStoreFile parentFile) + public DecorateJob(DataElement[] files, DStoreFile parentFile) { super(SystemFileResources.RESID_JOB_DECORATEFILES_NAME); _files= files; @@ -114,23 +86,28 @@ public class RemoteFilePropertyChangeListener implements IDomainListener, public IStatus runInUIThread(IProgressMonitor monitor) { _isDone = false; - for (int i = 0; i < _files.length; i++) - { - _registry.fireEvent(new - org.eclipse.rse.core.events.SystemResourceChangeEvent(_files[i], - ISystemResourceChangeEvents.EVENT_ICON_CHANGE, - _parentFile)); - } - - /* - _registry.fireEvent(new - org.eclipse.rse.ui.model.SystemResourceChangeEvent(_files, - ISystemResourceChangeEvent.EVENT_REPLACE_CHILDREN, - _parentFile)); - */ + IRemoteFile[] children = new IRemoteFile[_files.length]; + try { + for (int i = 0; i < _files.length; i++) + { + DataElement file = _files[i]; + StringBuffer path = new StringBuffer(file.getAttribute(DE.A_VALUE)); + path.append(_fileSubSystem.getSeparatorChar()); + path.append(file.getName()); + + children[i] = _fileSubSystem.getRemoteFileObject(path.toString(), monitor); + } + + _registry.fireEvent(new + org.eclipse.rse.core.events.SystemResourceChangeEvent(children, + ISystemResourceChangeEvents.EVENT_ICON_CHANGE, + _parentFile)); + } + catch (Exception e){} + _isDone = true; _decorateJobs.remove(_parentFile); - return Status.OK_STATUS; + return Status.OK_STATUS; } } @@ -140,6 +117,7 @@ public class RemoteFilePropertyChangeListener implements IDomainListener, { this.shell = shell; this._fileSubSystem = fileSS; + this.dataStore = dataStore; this.system = system; this._registry = RSECorePlugin.getTheSystemRegistry(); @@ -185,8 +163,14 @@ public class RemoteFilePropertyChangeListener implements IDomainListener, public void finish() { dataStore.getDomainNotifier().removeDomainListener(this); + _finished = true; } + public boolean isFinished() + { + return _finished; + } + /** * @see IDomainListener#domainChanged(DomainEvent) */ @@ -203,7 +187,6 @@ public class RemoteFilePropertyChangeListener implements IDomainListener, parentPath.append(parent.getName()); DStoreFile parentFile = (DStoreFile) _fileSubSystem.getCachedRemoteFile(parentPath.toString()); - boolean refreshParent = false; List toUpdate = new ArrayList(); for (int i = 0; i < children.size(); i++) { @@ -215,43 +198,19 @@ public class RemoteFilePropertyChangeListener implements IDomainListener, type.equals(IUniversalDataStoreConstants.UNIVERSAL_FOLDER_DESCRIPTOR))) { - StringBuffer path = new StringBuffer(subject.getAttribute(DE.A_VALUE)); - path.append(_fileSubSystem.getSeparatorChar()); - path.append(subject.getName()); - - - // find cached copy - try - { - DStoreFile updated = (DStoreFile) _fileSubSystem.getCachedRemoteFile(path.toString()); - - if (updated != null) - { - String classification = updated.getClassification(); - if (!classification.equals("file") && !classification.equals("directory")) //$NON-NLS-1$ //$NON-NLS-2$ - { - refreshParent = true; - toUpdate.add(updated); - } - - } - } - catch (Exception e) - { - e.printStackTrace(); - } + toUpdate.add(subject); } } - if (refreshParent) + if (!toUpdate.isEmpty()) { DecorateJob job = getDecorateJob(parentFile); if (job == null) { - job = new DecorateJob((DStoreFile[])toUpdate.toArray(new DStoreFile[toUpdate.size()]), parentFile); + job = new DecorateJob((DataElement[])toUpdate.toArray(new DataElement[toUpdate.size()]), parentFile); job.setRule(parentFile); putDecorateJob(parentFile, job); - job.schedule(5000); + job.schedule(1000); } } @@ -269,20 +228,7 @@ public class RemoteFilePropertyChangeListener implements IDomainListener, _decorateJobs.put(file, job); } - - public Shell getShell() - { - // dy: DomainNotifier (which calls this method) requires the shell not - // be disposed - //if (shell == null) { - if (shell == null || shell.isDisposed()) - { - FindShell findShell = new FindShell(); - Display.getDefault().syncExec(findShell); - shell = findShell.shell; - } - return shell; - } + /** * @see ICommunicationsListener#communicationsStateChange(CommunicationsEvent) diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java index 842df60ecb7..de6276a09b9 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2008 IBM Corporation and others. All rights reserved. + * Copyright (c) 2002, 2009 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -67,6 +67,7 @@ * David McKnight (IBM) - [249245] not showing inappropriate popup actions for: Refresh, Show In Table, Go Into, etc. * David McKnight (IBM) - [251625] Widget disposed exception when renaming/pasting a folder * David McKnight (IBM) - [257721] Doubleclick doing special handling and expanding + * David McKnight (IBM) - [190805] [performance][dstore] Right-click > Disconnect on a dstore connection is slow and spawns many Jobs ********************************************************************************/ package org.eclipse.rse.internal.ui.view; @@ -2176,18 +2177,38 @@ public class SystemView extends SafeTreeViewer case ISystemResourceChangeEvents.EVENT_ICON_CHANGE: if (debug) logDebugMsg("SV event: EVENT_ICON_CHANGE "); //$NON-NLS-1$ - if (initViewerFilters != null && initViewerFilters.length > 0) { - Widget w = findItem(src); - if (w == null) { - refresh(parent); + if (src instanceof Object[]){ + Object[] srcs = (Object[])src; + for (int s = 0; s < srcs.length; s++){ + if (initViewerFilters != null && initViewerFilters.length > 0) { + Widget w = findItem(srcs[s]); + if (w == null) { + refresh(parent); + } else { + properties[0] = IBasicPropertyConstants.P_IMAGE; + update(srcs[s], properties); // for refreshing non-structural properties in viewer when model changes + + } + } else { + properties[0] = IBasicPropertyConstants.P_IMAGE; + update(srcs[s], properties); // for refreshing non-structural properties in viewer when model changes + } + } + } + else { + if (initViewerFilters != null && initViewerFilters.length > 0) { + Widget w = findItem(src); + if (w == null) { + refresh(parent); + } else { + properties[0] = IBasicPropertyConstants.P_IMAGE; + update(src, properties); // for refreshing non-structural properties in viewer when model changes + + } } else { properties[0] = IBasicPropertyConstants.P_IMAGE; update(src, properties); // for refreshing non-structural properties in viewer when model changes - } - } else { - properties[0] = IBasicPropertyConstants.P_IMAGE; - update(src, properties); // for refreshing non-structural properties in viewer when model changes } //updatePropertySheet();