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
|
* 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
|
||||||
|
@ -11,11 +11,12 @@
|
||||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* 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) - [refactor] "shell" instead of "ssh" everywhere
|
||||||
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
* 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
|
* 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
|
* 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;
|
package org.eclipse.rse.internal.subsystems.processes.shell.linux;
|
||||||
|
@ -43,18 +44,21 @@ public class LinuxProcessHelper {
|
||||||
private HashMap _usernamesByUid;
|
private HashMap _usernamesByUid;
|
||||||
|
|
||||||
private HashMap _uidsByUserName;
|
private HashMap _uidsByUserName;
|
||||||
|
|
||||||
|
private IHost _host;
|
||||||
|
|
||||||
private static String COMMAND_GET_PASSWD = "getent passwd"; //$NON-NLS-1$
|
private static String COMMAND_GET_PASSWD = "getent passwd"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor
|
* constructor
|
||||||
*/
|
*/
|
||||||
public LinuxProcessHelper() {
|
public LinuxProcessHelper(IHost host) {
|
||||||
super();
|
super();
|
||||||
stateMap = new HashMap();
|
stateMap = new HashMap();
|
||||||
for (int i = ISystemProcessRemoteConstants.STATE_STARTING_INDEX; i < ISystemProcessRemoteConstants.STATE_ENDING_INDEX; i++) {
|
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]);
|
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
|
* this code is adapted from
|
||||||
* org.eclipse.rse.services.clientserver.processes.handlers.UniversalLinuxProcessHandler
|
* org.eclipse.rse.services.clientserver.processes.handlers.UniversalLinuxProcessHandler
|
||||||
*/
|
*/
|
||||||
public void populateUsernames(IHost host) {
|
public void populateUsernames() {
|
||||||
if (_usernamesByUid != null && _uidsByUserName != null || host == null)
|
if (_usernamesByUid != null && _uidsByUserName != null || _host == null)
|
||||||
return;
|
return;
|
||||||
_usernamesByUid = new HashMap();
|
_usernamesByUid = new HashMap();
|
||||||
_uidsByUserName = new HashMap();
|
_uidsByUserName = new HashMap();
|
||||||
|
|
||||||
IShellService shellService = Activator.getShellService(host);
|
IShellService shellService = Activator.getShellService(_host);
|
||||||
Process p = null;
|
Process p = null;
|
||||||
try {
|
try {
|
||||||
IHostShell hostShell = shellService.launchShell("", null, new NullProgressMonitor()); //$NON-NLS-1$
|
IHostShell hostShell = shellService.launchShell("", null, new NullProgressMonitor()); //$NON-NLS-1$
|
||||||
|
@ -112,7 +116,6 @@ public class LinuxProcessHelper {
|
||||||
new InputStreamReader(p.getInputStream()));
|
new InputStreamReader(p.getInputStream()));
|
||||||
|
|
||||||
String nextLine;
|
String nextLine;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while ((nextLine = bufferReader.readLine()) != null
|
while ((nextLine = bufferReader.readLine()) != null
|
||||||
&& !nextLine.equals(Activator.DONE_MARKUP_STRING)) {
|
&& !nextLine.equals(Activator.DONE_MARKUP_STRING)) {
|
||||||
|
@ -161,4 +164,11 @@ public class LinuxProcessHelper {
|
||||||
protected String getUserNameCommand() {
|
protected String getUserNameCommand() {
|
||||||
return Activator.formatShellCommand(COMMAND_GET_PASSWD);
|
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
|
* 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* 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;
|
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 LinuxRemoteProcessService_getSignalTypes_empty;
|
||||||
|
|
||||||
|
public static String LinuxShellProcessService_initHelper;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// initialize resource bundle
|
// initialize resource bundle
|
||||||
NLS.initializeMessages(BUNDLE_NAME, LinuxShellProcessResources.class);
|
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
|
# 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
|
||||||
# http://www.eclipse.org/legal/epl-v10.html
|
# http://www.eclipse.org/legal/epl-v10.html
|
||||||
#
|
#
|
||||||
# Contributors:
|
# 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) - [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
|
# NLS_MESSAGEFORMAT_VAR
|
||||||
|
@ -17,4 +18,5 @@
|
||||||
LinuxRemoteProcessService_name=Shell Process Service
|
LinuxRemoteProcessService_name=Shell Process Service
|
||||||
LinuxRemoteProcessService_description=listing processes on the remote target through a contributed shell service
|
LinuxRemoteProcessService_description=listing processes on the remote target through a contributed shell service
|
||||||
LinuxRemoteProcessService_monitor_fetchProcesses=Fetching Remote Process Information...
|
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
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* 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) - [refactor] "shell" instead of "ssh" everywhere
|
||||||
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
* 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
|
* 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
|
* 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
|
* 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()
|
* 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;
|
package org.eclipse.rse.internal.subsystems.processes.shell.linux;
|
||||||
|
@ -116,11 +117,22 @@ public class LinuxShellProcessService extends AbstractProcessService {
|
||||||
filter.setUsername(connectionUserId);
|
filter.setUsername(connectionUserId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monitor != null) {
|
if (monitor != null) {
|
||||||
monitor.beginTask(
|
monitor.beginTask(
|
||||||
LinuxShellProcessResources.LinuxRemoteProcessService_monitor_fetchProcesses,
|
LinuxShellProcessResources.LinuxRemoteProcessService_monitor_fetchProcesses,
|
||||||
100);
|
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);
|
IShellService shellService = Activator.getShellService(host);
|
||||||
IHostShell hostShell = shellService.launchShell(
|
IHostShell hostShell = shellService.launchShell(
|
||||||
"", null, new NullProgressMonitor()); //$NON-NLS-1$
|
"", null, new NullProgressMonitor()); //$NON-NLS-1$
|
||||||
|
@ -190,9 +202,7 @@ public class LinuxShellProcessService extends AbstractProcessService {
|
||||||
|
|
||||||
public void initService(final IProgressMonitor monitor) throws SystemMessageException {
|
public void initService(final IProgressMonitor monitor) throws SystemMessageException {
|
||||||
super.initService(monitor);
|
super.initService(monitor);
|
||||||
linuxProcessHelper = new LinuxProcessHelper();
|
linuxProcessHelper = new LinuxProcessHelper(host);
|
||||||
// initialize username /uid hashmap before getting any process
|
|
||||||
linuxProcessHelper.populateUsernames(host);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean progressWorked(final IProgressMonitor monitor,
|
private boolean progressWorked(final IProgressMonitor monitor,
|
||||||
|
|
Loading…
Add table
Reference in a new issue