1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-30 11:43:33 +02:00

[190805] [performance][dstore] Right-click > Disconnect on a dstore connection is slow and spawns many Jobs

This commit is contained in:
David McKnight 2009-03-25 18:58:24 +00:00
parent d919839bae
commit 667e97d5bb
4 changed files with 75 additions and 103 deletions

View file

@ -14,6 +14,7 @@
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core * 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) - [cleanup] Add API "since" Javadoc tags
* Martin Oberhuber (Wind River) - [261486][api][cleanup] Mark @noimplement interfaces as @noextend * 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; package org.eclipse.rse.core.events;
@ -137,7 +138,7 @@ public interface ISystemResourceChangeEvents
/** /**
* The event is an icon change event * 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; public static final int EVENT_ICON_CHANGE = 81;

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -16,6 +16,7 @@
* Martin Oberhuber (Wind River) - [235363][api][breaking] IHostFileToRemoteFileAdapter methods should return AbstractRemoteFile * 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) - [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) - [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; package org.eclipse.rse.internal.subsystems.files.dstore;
@ -43,6 +44,9 @@ public class DStoreFileAdapter implements IHostFileToRemoteFileAdapter
private void registerFilePropertyChangeListener(FileServiceSubSystem ss) private void registerFilePropertyChangeListener(FileServiceSubSystem ss)
{ {
if (_listener != null && _listener.isFinished()){
_listener = null;
}
if (_listener == null) if (_listener == null)
{ {
DStoreConnectorService connectorService = (DStoreConnectorService)ss.getConnectorService(); DStoreConnectorService connectorService = (DStoreConnectorService)ss.getConnectorService();

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -14,6 +14,7 @@
* Contributors: * Contributors:
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * 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; 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.internal.subsystems.files.core.SystemFileResources;
import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem; import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; 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.swt.widgets.Shell;
import org.eclipse.ui.progress.UIJob; import org.eclipse.ui.progress.UIJob;
@ -64,42 +63,15 @@ public class RemoteFilePropertyChangeListener implements IDomainListener,
protected boolean _networkDown = false; protected boolean _networkDown = false;
protected HashMap _decorateJobs; protected HashMap _decorateJobs;
protected static class FindShell implements Runnable protected boolean _finished = false;
{
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$
}
}
}
public class DecorateJob extends UIJob public class DecorateJob extends UIJob
{ {
private DStoreFile[] _files; private DataElement[] _files;
private DStoreFile _parentFile; private DStoreFile _parentFile;
private boolean _isDone = false; private boolean _isDone = false;
public DecorateJob(DStoreFile[] files, DStoreFile parentFile) public DecorateJob(DataElement[] files, DStoreFile parentFile)
{ {
super(SystemFileResources.RESID_JOB_DECORATEFILES_NAME); super(SystemFileResources.RESID_JOB_DECORATEFILES_NAME);
_files= files; _files= files;
@ -114,23 +86,28 @@ public class RemoteFilePropertyChangeListener implements IDomainListener,
public IStatus runInUIThread(IProgressMonitor monitor) public IStatus runInUIThread(IProgressMonitor monitor)
{ {
_isDone = false; _isDone = false;
for (int i = 0; i < _files.length; i++) IRemoteFile[] children = new IRemoteFile[_files.length];
{ try {
_registry.fireEvent(new for (int i = 0; i < _files.length; i++)
org.eclipse.rse.core.events.SystemResourceChangeEvent(_files[i], {
ISystemResourceChangeEvents.EVENT_ICON_CHANGE, DataElement file = _files[i];
_parentFile)); StringBuffer path = new StringBuffer(file.getAttribute(DE.A_VALUE));
} path.append(_fileSubSystem.getSeparatorChar());
path.append(file.getName());
/*
_registry.fireEvent(new children[i] = _fileSubSystem.getRemoteFileObject(path.toString(), monitor);
org.eclipse.rse.ui.model.SystemResourceChangeEvent(_files, }
ISystemResourceChangeEvent.EVENT_REPLACE_CHILDREN,
_parentFile)); _registry.fireEvent(new
*/ org.eclipse.rse.core.events.SystemResourceChangeEvent(children,
ISystemResourceChangeEvents.EVENT_ICON_CHANGE,
_parentFile));
}
catch (Exception e){}
_isDone = true; _isDone = true;
_decorateJobs.remove(_parentFile); _decorateJobs.remove(_parentFile);
return Status.OK_STATUS; return Status.OK_STATUS;
} }
} }
@ -140,6 +117,7 @@ public class RemoteFilePropertyChangeListener implements IDomainListener,
{ {
this.shell = shell; this.shell = shell;
this._fileSubSystem = fileSS; this._fileSubSystem = fileSS;
this.dataStore = dataStore; this.dataStore = dataStore;
this.system = system; this.system = system;
this._registry = RSECorePlugin.getTheSystemRegistry(); this._registry = RSECorePlugin.getTheSystemRegistry();
@ -185,8 +163,14 @@ public class RemoteFilePropertyChangeListener implements IDomainListener,
public void finish() public void finish()
{ {
dataStore.getDomainNotifier().removeDomainListener(this); dataStore.getDomainNotifier().removeDomainListener(this);
_finished = true;
} }
public boolean isFinished()
{
return _finished;
}
/** /**
* @see IDomainListener#domainChanged(DomainEvent) * @see IDomainListener#domainChanged(DomainEvent)
*/ */
@ -203,7 +187,6 @@ public class RemoteFilePropertyChangeListener implements IDomainListener,
parentPath.append(parent.getName()); parentPath.append(parent.getName());
DStoreFile parentFile = (DStoreFile) _fileSubSystem.getCachedRemoteFile(parentPath.toString()); DStoreFile parentFile = (DStoreFile) _fileSubSystem.getCachedRemoteFile(parentPath.toString());
boolean refreshParent = false;
List toUpdate = new ArrayList(); List toUpdate = new ArrayList();
for (int i = 0; i < children.size(); i++) for (int i = 0; i < children.size(); i++)
{ {
@ -215,43 +198,19 @@ public class RemoteFilePropertyChangeListener implements IDomainListener,
type.equals(IUniversalDataStoreConstants.UNIVERSAL_FOLDER_DESCRIPTOR))) type.equals(IUniversalDataStoreConstants.UNIVERSAL_FOLDER_DESCRIPTOR)))
{ {
StringBuffer path = new StringBuffer(subject.getAttribute(DE.A_VALUE)); toUpdate.add(subject);
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();
}
} }
} }
if (refreshParent) if (!toUpdate.isEmpty())
{ {
DecorateJob job = getDecorateJob(parentFile); DecorateJob job = getDecorateJob(parentFile);
if (job == null) 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); job.setRule(parentFile);
putDecorateJob(parentFile, job); putDecorateJob(parentFile, job);
job.schedule(5000); job.schedule(1000);
} }
} }
@ -269,20 +228,7 @@ public class RemoteFilePropertyChangeListener implements IDomainListener,
_decorateJobs.put(file, job); _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) * @see ICommunicationsListener#communicationsStateChange(CommunicationsEvent)

View file

@ -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 * 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 * of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html * 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) - [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) - [251625] Widget disposed exception when renaming/pasting a folder
* David McKnight (IBM) - [257721] Doubleclick doing special handling and expanding * 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; package org.eclipse.rse.internal.ui.view;
@ -2176,18 +2177,38 @@ public class SystemView extends SafeTreeViewer
case ISystemResourceChangeEvents.EVENT_ICON_CHANGE: case ISystemResourceChangeEvents.EVENT_ICON_CHANGE:
if (debug) logDebugMsg("SV event: EVENT_ICON_CHANGE "); //$NON-NLS-1$ if (debug) logDebugMsg("SV event: EVENT_ICON_CHANGE "); //$NON-NLS-1$
if (initViewerFilters != null && initViewerFilters.length > 0) { if (src instanceof Object[]){
Widget w = findItem(src); Object[] srcs = (Object[])src;
if (w == null) { for (int s = 0; s < srcs.length; s++){
refresh(parent); 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 { } else {
properties[0] = IBasicPropertyConstants.P_IMAGE; properties[0] = IBasicPropertyConstants.P_IMAGE;
update(src, properties); // for refreshing non-structural properties in viewer when model changes 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(); //updatePropertySheet();