From 85532fc26035787d0a668dd2ee3717c2eeda1fca Mon Sep 17 00:00:00 2001 From: David McKnight Date: Wed, 24 May 2006 18:53:37 +0000 Subject: [PATCH] applying patch provided by Michael Berger for defect 142974 --- .../dstore/core/client/ClientCommandHandler.java | 14 ++++++++++++-- .../dstore/core/server/ServerUpdateHandler.java | 11 ++++++++++- .../org/eclipse/dstore/core/util/XMLparser.java | 14 ++++++++++++-- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/client/ClientCommandHandler.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/client/ClientCommandHandler.java index f6803046ae2..8cc4dabecc6 100644 --- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/client/ClientCommandHandler.java +++ b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/client/ClientCommandHandler.java @@ -39,7 +39,7 @@ public class ClientCommandHandler extends CommandHandler protected DataElement _confirmKeepAliveDocumentElement; protected DataElement _pendingKeepAliveRequest; protected DataElement _pendingKeepAliveConfirmation; - + private static String[] _docAttributes = { DataStoreResources.DOCUMENT_TYPE, "client.doc.root.id", @@ -357,6 +357,7 @@ public class ClientCommandHandler extends CommandHandler document.setAttribute(DE.A_VALUE, "confirm"); document.setParent(null); _pendingKeepAliveConfirmation = document; + notifyInput(); } public void sendKeepAliveRequest() @@ -366,6 +367,15 @@ public class ClientCommandHandler extends CommandHandler document.setAttribute(DE.A_NAME, "request"); document.setAttribute(DE.A_VALUE, "request"); document.setParent(null); - _pendingKeepAliveRequest = document; + _pendingKeepAliveRequest = document; + notifyInput(); + } + + public synchronized void waitForInput() + { + if (_commands.size() == 0 && _classesToSend.size() == 0 && _pendingKeepAliveConfirmation == null && _pendingKeepAliveRequest == null) + { + super.waitForInput(); + } } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerUpdateHandler.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerUpdateHandler.java index cde5b289c5e..f5d8f8aaf59 100644 --- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerUpdateHandler.java +++ b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerUpdateHandler.java @@ -437,7 +437,8 @@ public class ServerUpdateHandler extends UpdateHandler document.setAttribute(DE.A_NAME, "request"); document.setAttribute(DE.A_VALUE, "request"); document.setParent(null); - _pendingKeepAliveRequest = document; + _pendingKeepAliveRequest = document; + notifyInput(); } public void sendKeepAliveConfirmation() @@ -448,6 +449,14 @@ public class ServerUpdateHandler extends UpdateHandler document.setAttribute(DE.A_VALUE, "confirm"); document.setParent(null); _pendingKeepAliveConfirmation = document; + notifyInput(); } + public synchronized void waitForInput() + { + if (_dataObjects.size() == 0 && _classesToSend.size() == 0 && _pendingKeepAliveConfirmation == null && _pendingKeepAliveRequest == null) + { + super.waitForInput(); + } + } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/util/XMLparser.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/util/XMLparser.java index 6128091167d..6b334feb530 100644 --- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/util/XMLparser.java +++ b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/util/XMLparser.java @@ -50,7 +50,8 @@ public class XMLparser public static final int IO_SOCKET_READ_TIMEOUT = 3600000; public static final long KEEPALIVE_RESPONSE_TIMEOUT = 60000; - + public static final boolean VERBOSE_KEEPALIVE = false; + private DataStore _dataStore; private DataElement _rootDataElement; private Stack _tagStack; @@ -301,6 +302,7 @@ public class XMLparser { _initialKart = new KeepAliveRequestThread(KEEPALIVE_RESPONSE_TIMEOUT, _dataStore); _firstTime = false; + if (VERBOSE_KEEPALIVE) System.out.println("Starting initial KeepAlive thread."); _initialKart.start(); continue; } @@ -309,11 +311,13 @@ public class XMLparser if (!_initialKart.failed()) { _isKeepAliveCompatible = true; + if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive compatible."); _initialKart = null; } else { _isKeepAliveCompatible = false; + if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive incompatible."); _initialKart = null; } } @@ -332,12 +336,14 @@ public class XMLparser if ((_kart != null) && _kart.failed()) { done = true; - handlePanic(new Exception("KeepAlive request to client wasnt answered in time.")); + if (_dataStore.isVirtual()) handlePanic(new Exception("KeepAlive request to server wasnt answered in time.")); + else handlePanic(new Exception("KeepAlive request to client wasnt answered in time.")); continue; } else { _kart = new KeepAliveRequestThread(KEEPALIVE_RESPONSE_TIMEOUT, _dataStore); + if (VERBOSE_KEEPALIVE) System.out.println("No activity on socket. KeepAlive thread started."); _kart.start(); continue; } @@ -610,11 +616,13 @@ public class XMLparser } else if (_isKeepAlive && (result != null)) { + if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive request received, sending confirmation."); result.getDataStore().sendKeepAliveConfirmation(); _isKeepAlive = false; } else if (_isKeepAliveConfirm && (result != null)) { + if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive confirmation received."); if (_initialKart != null) _initialKart.interrupt(); _isKeepAliveConfirm = false; } @@ -1004,8 +1012,10 @@ public class XMLparser } catch (InterruptedException e) { + if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive thread interrupted."); return; } + if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive thread failed to be interrupted."); _failed = true; }