[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[tm-cvs-commit] dmcknight org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view SystemViewRemoteFileAdapter.java

Update of /cvsroot/tools/org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view
In directory dev2:/tmp/cvs-serv3151/src/org/eclipse/rse/internal/files/ui/view

Modified Files:
	SystemViewRemoteFileAdapter.java 
Log Message:
[284157] [performance] too many jobs kicked off for getting file permissions for table


Index: SystemViewRemoteFileAdapter.java
===================================================================
RCS file: /cvsroot/tools/org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java,v
retrieving revision 1.106
retrieving revision 1.107
diff -C2 -d -r1.106 -r1.107
*** SystemViewRemoteFileAdapter.java	25 Nov 2010 16:34:10 -0000	1.106
--- SystemViewRemoteFileAdapter.java	16 Mar 2011 15:44:09 -0000	1.107
***************
*** 1,4 ****
  /*******************************************************************************
!  * Copyright (c) 2002, 2010 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
--- 1,4 ----
  /*******************************************************************************
!  * Copyright (c) 2002, 2011 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
***************
*** 71,74 ****
--- 71,75 ----
   * David McKnight   (IBM)        - [324192] Cannot open a renamed file
   * David McKnight     (IBM)      - [228743] [usability][dnd] Paste into read-only folder fails silently
+  * David McKnight   (IBM)        - [284157] [performance] too many jobs kicked off for getting file permissions for table
   *******************************************************************************/
  
***************
*** 78,81 ****
--- 79,83 ----
  import java.util.ArrayList;
  import java.util.Date;
+ import java.util.HashMap;
  import java.util.Iterator;
  import java.util.List;
***************
*** 122,125 ****
--- 124,128 ----
  import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
  import org.eclipse.rse.files.ui.resources.UniversalFileTransferUtility;
+ import org.eclipse.rse.internal.core.RSECoreMessages;
  import org.eclipse.rse.internal.files.ui.Activator;
  import org.eclipse.rse.internal.files.ui.FileResources;
***************
*** 266,269 ****
--- 269,324 ----
  	static final String _downloadMessage = FileResources.MSG_DOWNLOADING_PROGRESS;
  
+ 	public HashMap _permissionsJobMap = new HashMap();
+ 	
+ 	class MultiFetchPermissionsJob extends Job {
+ 		private List _files;
+ 		private IFilePermissionsService _service;
+ 		private boolean _started = false;
+ 		
+ 		public MultiFetchPermissionsJob(IFilePermissionsService service){						
+ 			super(RSECoreMessages.RSESubSystemOperation_Get_properties_message); 
+ 			_files = new ArrayList();
+ 			_service = service;
+ 		}
+ 		
+ 		protected IStatus run(IProgressMonitor monitor) {
+ 			final ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
+ 			IRemoteFile[] files = null;
+ 			_started = true;
+ 			synchronized (_files){
+ 				files = (IRemoteFile[])_files.toArray(new IRemoteFile[_files.size()]);			
+ 			}
+ 			for (int i = 0; i < files.length; i++){			
+ 				IRemoteFile rFile = files[i];
+ 
+ 				try {
+ 					// service will take care of setting this on the host file
+ 					_service.getFilePermissions(rFile.getHostFile(), monitor);	
+ 					registry.fireEvent(new SystemResourceChangeEvent(rFile, ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE, rFile));						
+ 				}
+ 				catch (Exception e){
+ 				}
+ 			}
+ 						
+ 			_permissionsJobMap.remove(_service);
+ 			return Status.OK_STATUS;
+ 		}
+ 
+ 		public int size(){
+ 			return _files.size();
+ 		}
+ 		
+ 		public boolean isStarted(){
+ 			return _started;
+ 		}
+ 		
+ 		public void addFile(IRemoteFile file){
+ 			_files.add(file);
+ 		}
+ 		
+ 		
+ 	}
+ 
+ 	
  	/**
  	 * Constructor
***************
*** 1501,1524 ****
  					((IHostFilePermissionsContainer)rFile.getHostFile()).setPermissions(new PendingHostFilePermissions());
  				}
! 
! 				Job deferredFetch = new Job(NLS.bind(FileResources.MESSAGE_GETTING_PERMISSIONS, file.getAbsolutePath()))
! 				{
! 					public IStatus run(IProgressMonitor monitor){
! 						try
! 						{
! 							// service will take care of setting this on the host file
! 							service.getFilePermissions(rFile.getHostFile(), monitor);
! 							ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
! 							registry.fireEvent(new SystemResourceChangeEvent(rFile, ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE, rFile));
! 						}
! 						catch (Exception e)
! 						{
! 						}
! 						return Status.OK_STATUS;
! 					}
! 				};
! 				deferredFetch.schedule();
! 
! 
  				return true; // query kicked off
  			}
--- 1556,1571 ----
  					((IHostFilePermissionsContainer)rFile.getHostFile()).setPermissions(new PendingHostFilePermissions());
  				}
! 				
! 				MultiFetchPermissionsJob deferredFetch = (MultiFetchPermissionsJob)_permissionsJobMap.get(service);
! 				if (deferredFetch == null || deferredFetch.isStarted() || deferredFetch.size() > 50){ // max 50 files per job
! 					deferredFetch = new MultiFetchPermissionsJob(service);
! 					_permissionsJobMap.put(service, deferredFetch);
! 					deferredFetch.addFile(file);
! 					deferredFetch.schedule(100);
! 				}
! 				else {
! 					deferredFetch.addFile(file);
! 				}
! 				
  				return true; // query kicked off
  			}