mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
[175300] deferred populating usernames until it's really needed.
This commit is contained in:
parent
5f24001c46
commit
d2613c4d56
4 changed files with 42 additions and 17 deletions
|
@ -1,5 +1,5 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2005, 2008 IBM Corporation and others. All rights reserved.
|
||||
* Copyright (c) 2005, 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
|
||||
|
@ -11,11 +11,12 @@
|
|||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* Yu-Fen Kuo (MontaVista) - adapted from RSE UniversalLinuxProcessHandler
|
||||
* Yu-Fen Kuo (MontaVista) - adapted from RSE UniversalLinuxProcessHandler
|
||||
* Martin Oberhuber (Wind River) - [refactor] "shell" instead of "ssh" everywhere
|
||||
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
||||
* David McKnight (IBM) - [175308] Need to use a job to wait for shell to exit
|
||||
* Martin Oberhuber (Wind River) - [226301][api] IShellService should throw SystemMessageException on error
|
||||
* Anna Dushistova (MontaVista) - [175300][performance] processes.shell.linux subsystem is slow over ssh
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.subsystems.processes.shell.linux;
|
||||
|
@ -43,18 +44,21 @@ public class LinuxProcessHelper {
|
|||
private HashMap _usernamesByUid;
|
||||
|
||||
private HashMap _uidsByUserName;
|
||||
|
||||
private IHost _host;
|
||||
|
||||
private static String COMMAND_GET_PASSWD = "getent passwd"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
public LinuxProcessHelper() {
|
||||
public LinuxProcessHelper(IHost host) {
|
||||
super();
|
||||
stateMap = new HashMap();
|
||||
for (int i = ISystemProcessRemoteConstants.STATE_STARTING_INDEX; i < ISystemProcessRemoteConstants.STATE_ENDING_INDEX; i++) {
|
||||
stateMap.put(new Character(ISystemProcessRemoteConstants.ALL_STATES[i]), ISystemProcessRemoteConstants.ALL_STATES_STR[i]);
|
||||
}
|
||||
_host = host;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,13 +90,13 @@ public class LinuxProcessHelper {
|
|||
* this code is adapted from
|
||||
* org.eclipse.rse.services.clientserver.processes.handlers.UniversalLinuxProcessHandler
|
||||
*/
|
||||
public void populateUsernames(IHost host) {
|
||||
if (_usernamesByUid != null && _uidsByUserName != null || host == null)
|
||||
public void populateUsernames() {
|
||||
if (_usernamesByUid != null && _uidsByUserName != null || _host == null)
|
||||
return;
|
||||
_usernamesByUid = new HashMap();
|
||||
_uidsByUserName = new HashMap();
|
||||
|
||||
IShellService shellService = Activator.getShellService(host);
|
||||
IShellService shellService = Activator.getShellService(_host);
|
||||
Process p = null;
|
||||
try {
|
||||
IHostShell hostShell = shellService.launchShell("", null, new NullProgressMonitor()); //$NON-NLS-1$
|
||||
|
@ -112,7 +116,6 @@ public class LinuxProcessHelper {
|
|||
new InputStreamReader(p.getInputStream()));
|
||||
|
||||
String nextLine;
|
||||
|
||||
try {
|
||||
while ((nextLine = bufferReader.readLine()) != null
|
||||
&& !nextLine.equals(Activator.DONE_MARKUP_STRING)) {
|
||||
|
@ -161,4 +164,11 @@ public class LinuxProcessHelper {
|
|||
protected String getUserNameCommand() {
|
||||
return Activator.formatShellCommand(COMMAND_GET_PASSWD);
|
||||
}
|
||||
|
||||
public boolean isInitialized(){
|
||||
if (_usernamesByUid != null && _uidsByUserName != null){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2009 Wind River Systems, Inc. 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
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - initial API and implementation
|
||||
* Martin Oberhuber (Wind River) - initial API and implementation
|
||||
* Anna Dushistova (MontaVista) - [175300][performance] processes.shell.linux subsystem is slow over ssh
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.subsystems.processes.shell.linux;
|
||||
|
@ -24,6 +25,8 @@ public class LinuxShellProcessResources extends NLS {
|
|||
|
||||
public static String LinuxRemoteProcessService_getSignalTypes_empty;
|
||||
|
||||
public static String LinuxShellProcessService_initHelper;
|
||||
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages(BUNDLE_NAME, LinuxShellProcessResources.class);
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
################################################################################
|
||||
# Copyright (c) 2006, 2008 MontaVista Software, Inc. and others.
|
||||
# Copyright (c) 2006, 2009 MontaVista Software, Inc. 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
|
||||
#
|
||||
# Contributors:
|
||||
# Yu-Fen Kuo (MontaVista) - initial API and implementation
|
||||
# Yu-Fen Kuo (MontaVista) - initial API and implementation
|
||||
# Martin Oberhuber (Wind River) - [refactor] "shell" instead of "ssh" everywhere
|
||||
# Xuan Chen (IBM) - added NLS_MESSAGEFORMAT comments
|
||||
# Xuan Chen (IBM) - added NLS_MESSAGEFORMAT comments
|
||||
# Anna Dushistova (MontaVista) - [175300][performance] processes.shell.linux subsystem is slow over ssh
|
||||
################################################################################
|
||||
|
||||
# NLS_MESSAGEFORMAT_VAR
|
||||
|
@ -17,4 +18,5 @@
|
|||
LinuxRemoteProcessService_name=Shell Process Service
|
||||
LinuxRemoteProcessService_description=listing processes on the remote target through a contributed shell service
|
||||
LinuxRemoteProcessService_monitor_fetchProcesses=Fetching Remote Process Information...
|
||||
LinuxRemoteProcessService_getSignalTypes_empty=Failed to retrieve signal types from remote target.
|
||||
LinuxRemoteProcessService_getSignalTypes_empty=Failed to retrieve signal types from remote target.
|
||||
LinuxShellProcessService_initHelper=Populating usernames
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Yu-Fen Kuo (MontaVista) - initial API and implementation
|
||||
* Yu-Fen Kuo (MontaVista) - initial API and implementation
|
||||
* Martin Oberhuber (Wind River) - [refactor] "shell" instead of "ssh" everywhere
|
||||
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
||||
* David McKnight (IBM) - [175308] Need to use a job to wait for shell to exit
|
||||
|
@ -14,6 +14,7 @@
|
|||
* Martin Oberhuber (Wind River) - [226301][api] IShellService should throw SystemMessageException on error
|
||||
* Anna Dushistova (MontaVista) - [239159] The shell process subsystem not working without the shells subsystem present for the systemType
|
||||
* David McKnight (IBM) - [272882] [api] Handle exceptions in IService.initService()
|
||||
* Anna Dushistova (MontaVista) - [175300][performance] processes.shell.linux subsystem is slow over ssh
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.subsystems.processes.shell.linux;
|
||||
|
@ -116,11 +117,22 @@ public class LinuxShellProcessService extends AbstractProcessService {
|
|||
filter.setUsername(connectionUserId);
|
||||
}
|
||||
}
|
||||
|
||||
if (monitor != null) {
|
||||
monitor.beginTask(
|
||||
LinuxShellProcessResources.LinuxRemoteProcessService_monitor_fetchProcesses,
|
||||
100);
|
||||
}
|
||||
if(!linuxProcessHelper.isInitialized()){
|
||||
// initialize username /uid hashmap before getting any process
|
||||
if (monitor != null) {
|
||||
monitor.setTaskName(LinuxShellProcessResources.LinuxShellProcessService_initHelper);
|
||||
}
|
||||
linuxProcessHelper.populateUsernames();
|
||||
if (monitor != null) {
|
||||
monitor.setTaskName(LinuxShellProcessResources.LinuxRemoteProcessService_monitor_fetchProcesses);
|
||||
}
|
||||
}
|
||||
IShellService shellService = Activator.getShellService(host);
|
||||
IHostShell hostShell = shellService.launchShell(
|
||||
"", null, new NullProgressMonitor()); //$NON-NLS-1$
|
||||
|
@ -190,9 +202,7 @@ public class LinuxShellProcessService extends AbstractProcessService {
|
|||
|
||||
public void initService(final IProgressMonitor monitor) throws SystemMessageException {
|
||||
super.initService(monitor);
|
||||
linuxProcessHelper = new LinuxProcessHelper();
|
||||
// initialize username /uid hashmap before getting any process
|
||||
linuxProcessHelper.populateUsernames(host);
|
||||
linuxProcessHelper = new LinuxProcessHelper(host);
|
||||
}
|
||||
|
||||
private boolean progressWorked(final IProgressMonitor monitor,
|
||||
|
|
Loading…
Add table
Reference in a new issue