From 20b5a96ef01b5fda7b570f623b113289c67bb1e3 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Wed, 15 Dec 2010 16:38:25 +0000 Subject: [PATCH] [289234][multithread][api] Reset and Restart KeepAliveRequestThread --- .../META-INF/MANIFEST.MF | 2 +- .../dstore/core/server/ServerReceiver.java | 15 ++++++++++++++- .../org/eclipse/dstore/core/util/Receiver.java | 13 ++++++++++++- .../dstore/internal/core/util/XMLparser.java | 17 +++++++++++++++++ 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/rse/plugins/org.eclipse.dstore.core/META-INF/MANIFEST.MF b/rse/plugins/org.eclipse.dstore.core/META-INF/MANIFEST.MF index 914caf75a3c..fd5e4b3657f 100644 --- a/rse/plugins/org.eclipse.dstore.core/META-INF/MANIFEST.MF +++ b/rse/plugins/org.eclipse.dstore.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.dstore.core -Bundle-Version: 3.2.100.qualifier +Bundle-Version: 3.3.100.qualifier Bundle-Activator: org.eclipse.dstore.core.Activator Bundle-Localization: plugin Require-Bundle: org.eclipse.ui, diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerReceiver.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerReceiver.java index 5af28e2b2cc..61afbca2efe 100644 --- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerReceiver.java +++ b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerReceiver.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2009 IBM Corporation and others. + * 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 * which accompanies this distribution, and is available at @@ -18,6 +18,7 @@ * Noriaki Takatsu (IBM) - [257666] [multithread] TCP/IP socket connection is not closed * David McKnight (IBM) - [257666] modified original patch to simplify * Noriaki Takatsu (IBM) - [283656] [dstore][multithread] Serviceability issue + * Noriaki Takatsu (IBM) - [289234][multithread][api] Reset and Restart KeepAliveRequestThread *******************************************************************************/ package org.eclipse.dstore.core.server; @@ -118,5 +119,17 @@ public class ServerReceiver extends Receiver System.out.println(IOe); } } + + /** + * Interrupt the current KeepAliveRequest thread and restart + * the KeepAliveRequest thread with the specified timeout + * + * @param timeout when the KeepAliveRequest thread is expired + * @since 3.3 + */ + public void resetKeepAliveRequest(long timeout) + { + xmlParser().resetKeepAliveRequest(timeout, socket()); + } } diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/util/Receiver.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/util/Receiver.java index bf67676050e..51c43192a59 100644 --- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/util/Receiver.java +++ b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/util/Receiver.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2009 IBM Corporation and others. + * 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 * which accompanies this distribution, and is available at @@ -17,6 +17,7 @@ * Noriaki Takatsu (IBM) - [220126] [dstore][api][breaking] Single process server for multiple clients * David McKnight (IBM) - [225507][api][breaking] RSE dstore API leaks non-API types * David McKnight (IBM) - [226561] [apidoc] Add API markup to RSE Javadocs where extend / implement is allowed + * Noriaki Takatsu (IBM) - [289234][multithread][api] Reset and Restart KeepAliveRequestThread *******************************************************************************/ package org.eclipse.dstore.core.util; @@ -184,6 +185,16 @@ public abstract class Receiver extends SecuredThread implements IDataStorePrefer { return _socket; } + + /** + * Returns the associated xml parser + * @return the xml parser + * @since 3.3 + */ + public XMLparser xmlParser() + { + return _xmlParser; + } /** * Implemented to provide a means of handling received input 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 96ec8ec0805..dd24467000f 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 @@ -20,6 +20,7 @@ * David McKnight (IBM) [305218][dstore] problem reading double-byte characters through data socket layer * David McKnight (IBM) [307541][dstore] fix for Bug 305218 breaks RDz connections * David McKnight (IBM) [322407][dstore] Connection dropped automatically when idle + * Noriaki Takatsu (IBM) - [289234][multithread][api] Reset and Restart KeepAliveRequestThread *******************************************************************************/ package org.eclipse.dstore.internal.core.util; @@ -1118,4 +1119,20 @@ public class XMLparser } } + /** + * Interrupt the current KeepAliveRequest thread and restart + * the KeepAliveRequest thread with the specified timeout + * + * @param timeout when the KeepAliveRequest thread is expired + * @param socket to wait for + * + * @since 3.3 + */ + public void resetKeepAliveRequest(long timeout, Socket socket) { + if (_kart != null && _kart.isAlive()){ + _kart.interrupt(); + } + _kart = new KeepAliveRequestThread(timeout, socket); + _kart.start(); + } }