From bc27d20ae0fdd5117aca792564182695ead594d3 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Fri, 7 Mar 2008 14:11:13 +0000 Subject: [PATCH] [220123] [api][dstore] Configurable timeout on irresponsiveness --- .../dstore/internal/core/util/XMLparser.java | 60 ++++++++++--------- .../dstore/DStoreConnectorService.java | 3 +- .../connectorservice/dstore/Activator.java | 35 +++++++++-- 3 files changed, 65 insertions(+), 33 deletions(-) diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLparser.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLparser.java index 68a4c687537..5c5ed2efabf 100644 --- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLparser.java +++ b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLparser.java @@ -82,6 +82,7 @@ public class XMLparser private Throwable _panicException = null; private boolean _isKeepAliveCompatible = false; + private boolean _isKeepAliveEnabled = true; private boolean _firstTime = true; private KeepAliveRequestThread _kart = null; @@ -131,6 +132,7 @@ public class XMLparser public void setEnableKeepalive(boolean enable){ // if false, we ignore the keepalive stuff _isKeepAliveCompatible = enable; + _isKeepAliveEnabled = enable; } /** @@ -308,34 +310,36 @@ public class XMLparser boolean inquotes = false; while (!done) { - - if (_firstTime) + if (_isKeepAliveEnabled) { - _initialKart = new KeepAliveRequestThread(KEEPALIVE_RESPONSE_TIMEOUT); - _firstTime = false; - if (VERBOSE_KEEPALIVE) System.out.println("Starting initial KeepAlive thread."); //$NON-NLS-1$ - _initialKart.start(); - continue; - } - else if (_initialKart != null && !_initialKart.isAlive()) - { - if (!_initialKart.failed()) + if (_firstTime) { - _isKeepAliveCompatible = true; - if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive compatible."); //$NON-NLS-1$ - _initialKart = null; - } - else + _initialKart = new KeepAliveRequestThread(KEEPALIVE_RESPONSE_TIMEOUT); + _firstTime = false; + if (VERBOSE_KEEPALIVE) System.out.println("Starting initial KeepAlive thread."); //$NON-NLS-1$ + _initialKart.start(); + continue; + } + else if (_initialKart != null && !_initialKart.isAlive()) { - _isKeepAliveCompatible = false; - if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive incompatible."); //$NON-NLS-1$ - _initialKart = null; + if (!_initialKart.failed()) + { + _isKeepAliveCompatible = true; + if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive compatible."); //$NON-NLS-1$ + _initialKart = null; + } + else + { + _isKeepAliveCompatible = false; + if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive incompatible."); //$NON-NLS-1$ + _initialKart = null; + } } } - + int in = -1; - if (_isKeepAliveCompatible) + if (_isKeepAliveEnabled && _isKeepAliveCompatible) { socket.setSoTimeout(IO_SOCKET_READ_TIMEOUT); try @@ -349,14 +353,16 @@ public class XMLparser done = true; if (_dataStore.isVirtual()) handlePanic(new Exception("KeepAlive request to server wasnt answered in time.")); //$NON-NLS-1$ else handlePanic(new Exception("KeepAlive request to client wasnt answered in time.")); //$NON-NLS-1$ - continue; + return null; } else { - _kart = new KeepAliveRequestThread(KEEPALIVE_RESPONSE_TIMEOUT); - if (VERBOSE_KEEPALIVE) System.out.println("No activity on socket. KeepAlive thread started."); //$NON-NLS-1$ - _kart.start(); - continue; + if (_kart == null){ + _kart = new KeepAliveRequestThread(KEEPALIVE_RESPONSE_TIMEOUT); + if (VERBOSE_KEEPALIVE) System.out.println("No activity on socket. KeepAlive thread started."); //$NON-NLS-1$ + _kart.start(); + continue; + } } } } @@ -671,7 +677,7 @@ public class XMLparser } else if (_isKeepAlive) { - if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive request received, sending confirmation."); //$NON-NLS-1$ + if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive request received, sending confirmation."); //$NON-NLS-1$ result.getDataStore().sendKeepAliveConfirmation(); _isKeepAlive = false; } diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java index 7354cda0a3b..3ace9d4d080 100644 --- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java +++ b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java @@ -26,6 +26,7 @@ * David McKnight (IBM) - [218685] [api][breaking][dstore] Unable to connect when using SSL. * David McKnight (IBM) - [220123][dstore] Configurable timeout on irresponsiveness * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared + * David McKnight (IBM) - [220123] [api][dstore] Configurable timeout on irresponsiveness *******************************************************************************/ package org.eclipse.rse.connectorservice.dstore; @@ -963,7 +964,7 @@ public class DStoreConnectorService extends StandardConnectorService implements // this preference is set on the server side dataStore.setPreference(RemoteClassLoader.CACHING_PREFERENCE, cacheRemoteClasses ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ - if (serverVersion >= 9){ // keepalive preferences + if (serverVersion >= 8){ // keepalive preferences boolean doKeepalive = store.getBoolean(IUniversalDStoreConstants.RESID_PREF_DO_KEEPALIVE); int keepaliveResponseTimeout = store.getInt(IUniversalDStoreConstants.RESID_PREF_KEEPALIVE_RESPONSE_TIMEOUT); diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/Activator.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/Activator.java index 86141917ac3..0197d31b595 100644 --- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/Activator.java +++ b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/Activator.java @@ -13,13 +13,13 @@ * Contributors: * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible + * David McKnight (IBM) - [220123] [api][dstore] Configurable timeout on irresponsiveness ********************************************************************************/ package org.eclipse.rse.internal.connectorservice.dstore; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.rse.connectorservice.dstore.IUniversalDStoreConstants; -import org.eclipse.rse.ui.ISystemPreferencesConstants; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.SystemBasePlugin; import org.osgi.framework.BundleContext; @@ -48,11 +48,36 @@ public class Activator extends SystemBasePlugin { public void start(BundleContext context) throws Exception { super.start(context); - IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore(); - store.setDefault(IUniversalDStoreConstants.RESID_PREF_SOCKET_TIMEOUT, IUniversalDStoreConstants.DEFAULT_PREF_SOCKET_TIMEOUT); - store.setDefault(ISystemPreferencesConstants.ALERT_SSL, ISystemPreferencesConstants.DEFAULT_ALERT_SSL); - store.setDefault(ISystemPreferencesConstants.ALERT_NONSSL, ISystemPreferencesConstants.DEFAULT_ALERT_NON_SSL); + initializeDefaultPreferences(); + } + + + public void initializeDefaultPreferences() { + IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore(); + + int timeout = IUniversalDStoreConstants.DEFAULT_PREF_SOCKET_TIMEOUT; + store.setDefault(IUniversalDStoreConstants.RESID_PREF_SOCKET_TIMEOUT, timeout); + + // do keepalive + boolean doKeepalive = IUniversalDStoreConstants.DEFAULT_PREF_DO_KEEPALIVE; + store.setValue(IUniversalDStoreConstants.RESID_PREF_DO_KEEPALIVE, doKeepalive); + + // socket read timeout + int socketTimeout = IUniversalDStoreConstants.DEFAULT_PREF_SOCKET_READ_TIMEOUT; + store.setDefault(IUniversalDStoreConstants.RESID_PREF_SOCKET_READ_TIMEOUT, socketTimeout); + + // keepalive response timeout + int keepaliveTimeout = IUniversalDStoreConstants.DEFAULT_PREF_KEEPALIVE_RESPONSE_TIMEOUT; + store.setDefault(IUniversalDStoreConstants.RESID_PREF_KEEPALIVE_RESPONSE_TIMEOUT, keepaliveTimeout); + + // show mismatched server warning + boolean showMismatchedWarning = IUniversalDStoreConstants.DEFAULT_ALERT_MISMATCHED_SERVER; + store.setDefault(IUniversalDStoreConstants.ALERT_MISMATCHED_SERVER, showMismatchedWarning); + + // cache remote classes + boolean cacheRemoteClasses = IUniversalDStoreConstants.DEFAULT_PREF_CACHE_REMOTE_CLASSES; + store.setDefault(IUniversalDStoreConstants.RESID_PREF_CACHE_REMOTE_CLASSES, cacheRemoteClasses); } /**