JBoss Remoting SVN: r5136 - remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-05 20:20:15 -0400 (Tue, 05 May 2009)
New Revision: 5136
Modified:
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/LeasePinger.java
Log:
JBREM-1112 (and others to be named): Removed a log statement.
Modified: remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/LeasePinger.java
===================================================================
--- remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/LeasePinger.java 2009-05-06 00:19:41 UTC (rev 5135)
+++ remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/LeasePinger.java 2009-05-06 00:20:15 UTC (rev 5136)
@@ -166,10 +166,6 @@
startPing();
}
}
- else
- {
- log.debug(this + " has already shut down");
- }
}
public boolean removeClient(String sessionID)
15 years, 6 months
JBoss Remoting SVN: r5135 - remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-05 20:19:41 -0400 (Tue, 05 May 2009)
New Revision: 5135
Modified:
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/ConnectionValidator.java
Log:
JBREM-1112 (and others to be named): Modified a log statement.
Modified: remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/ConnectionValidator.java
===================================================================
--- remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/ConnectionValidator.java 2009-05-05 20:06:35 UTC (rev 5134)
+++ remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/ConnectionValidator.java 2009-05-06 00:19:41 UTC (rev 5135)
@@ -864,7 +864,7 @@
else
{
// log.debug(ConnectionValidator.this + " unable to shut down lease pinger: " + leasePinger + ". Client must have shut down");
- log.debug(ConnectionValidator.this + " unable to shut down null lease pinger. Client must have shut down");
+ log.debug(ConnectionValidator.this + ": lease pinger == null: perhaps leasing is not enabled for this connection");
notifyListeners(new Exception("Could not connect to server!"));
}
15 years, 6 months
JBoss Remoting SVN: r5134 - remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2009-05-05 16:06:35 -0400 (Tue, 05 May 2009)
New Revision: 5134
Added:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/RemoteInterruptedException.java
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Remoting.java
Log:
Convenience exception handling methods
Added: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/RemoteInterruptedException.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/RemoteInterruptedException.java (rev 0)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/RemoteInterruptedException.java 2009-05-05 20:06:35 UTC (rev 5134)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting3;
+
+/**
+ * The remote execution was interrupted due to an {@link InterruptedException}. Since it is an error to propagate such
+ * an exception to a different thread, this exception may be thrown in its place.
+ */
+public class RemoteInterruptedException extends RuntimeException {
+
+ private static final long serialVersionUID = 7273630153650065304L;
+
+ /**
+ * Constructs a {@code RemoteInterruptedException} with no detail message. The cause is not initialized, and may
+ * subsequently be initialized by a call to {@link #initCause(Throwable) initCause}.
+ */
+ public RemoteInterruptedException() {
+ }
+
+ /**
+ * Constructs a {@code RemoteInterruptedException} with the specified detail message. The cause is not initialized, and
+ * may subsequently be initialized by a call to {@link #initCause(Throwable) initCause}.
+ *
+ * @param msg the detail message
+ */
+ public RemoteInterruptedException(final String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructs a {@code RemoteInterruptedException} with the specified cause. The detail message is set to:
+ * <pre>(cause == null ? null : cause.toString())</pre>
+ * (which typically contains the class and detail message of {@code cause}).
+ *
+ * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method)
+ */
+ public RemoteInterruptedException(final Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Constructs a {@code RemoteInterruptedException} with the specified detail message and cause.
+ *
+ * @param msg the detail message
+ * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method)
+ */
+ public RemoteInterruptedException(final String msg, final Throwable cause) {
+ super(msg, cause);
+ }
+}
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Remoting.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Remoting.java 2009-05-05 08:24:28 UTC (rev 5133)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Remoting.java 2009-05-05 20:06:35 UTC (rev 5134)
@@ -132,5 +132,50 @@
}
}
+ /**
+ * Convenience method to rethrow the cause of a {@code RemoteExecutionException} as a specific type, in order
+ * to simplify application exception handling.
+ * <p/>
+ * A typical usage might look like this:
+ * <pre>
+ * try {
+ * client.invoke(request);
+ * } catch (RemoteExecutionException ree) {
+ * Remoting.rethrowAs(IOException.class, ree);
+ * Remoting.rethrowAs(RuntimeException.class, ree);
+ * Remoting.rethrowUnexpected(ree);
+ * }
+ * </pre>
+ * <p/>
+ * Note that if the nested exception is an {@link InterruptedException}, the type that will actually be thrown
+ * will be {@link RemoteInterruptedException}.
+ *
+ * @param type the class of the exception
+ * @param original the remote execution exception
+ * @param <T> the exception type
+ * @throws T the exception, if it matches the given type
+ */
+ public static <T extends Throwable> void rethrowAs(Class<T> type, RemoteExecutionException original) throws T {
+ final Throwable cause = original.getCause();
+ if (cause == null) {
+ return;
+ }
+ if (type.isAssignableFrom(cause.getClass())) {
+ if (cause instanceof InterruptedException) {
+ throw new RemoteInterruptedException(cause.getMessage(), cause.getCause());
+ }
+ throw type.cast(cause);
+ }
+ return;
+ }
+
+ public static void rethrowUnexpected(RemoteExecutionException original) throws IllegalStateException {
+ Throwable cause = original.getCause();
+ if (cause instanceof InterruptedException) {
+ cause = new RemoteInterruptedException(cause.getMessage(), cause.getCause());
+ }
+ throw new IllegalStateException("Unexpected remote exception occurred", cause);
+ }
+
private Remoting() { /* empty */ }
}
15 years, 6 months
JBoss Remoting SVN: r5133 - remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-05 04:24:28 -0400 (Tue, 05 May 2009)
New Revision: 5133
Modified:
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java
Log:
JBREM-1112 (and others to be named): In establishLease(), call to Client.addConnectionListener() is taken out of finally block.
Modified: remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java
===================================================================
--- remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java 2009-05-05 08:23:32 UTC (rev 5132)
+++ remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java 2009-05-05 08:24:28 UTC (rev 5133)
@@ -344,7 +344,8 @@
{
synchronized(clientLeaseLock)
{
- if (passedLeasePinger != leasePinger)
+ log.debug(this + " entering terminateLease()");
+ if (passedLeasePinger != null && passedLeasePinger != leasePinger)
{
log.debug(this + ": " + passedLeasePinger + " != " + leasePinger);
return;
@@ -365,7 +366,7 @@
}
catch (Exception e)
{
- log.debug("error shutting down lease pinger");
+ log.debug("error shutting down lease pinger", e);
}
leasePinger = null;
}
@@ -422,7 +423,7 @@
if (leasePinger != null)
{
leasePinger.addClient(clientSessionID, configuration, leasePeriod);
- log.debug(this + " added client with session ID " + clientSessionID + " to the lease pinger");
+ log.debug(this + " added client with session ID " + clientSessionID + " to " + leasePinger);
return;
}
@@ -437,7 +438,7 @@
Map requestMap = new HashMap();
requestMap.put(LeasePinger.LEASE_PINGER_ID, leasePingerId);
requestMap.put("time", Long.toString(System.currentTimeMillis()));
- log.info(this + " initiating lease for leasePingerId " + leasePingerId);
+ log.debug(this + " initiating lease for leasePingerId " + leasePingerId);
InvocationRequest ir = new InvocationRequest(invokerSessionID, null, "$PING$", requestMap, new HashMap(), null);
Object ret = invoke(ir);
@@ -477,10 +478,11 @@
e.initCause(throwable);
throw e;
}
- finally
+// finally
{
// Client client = (Client) configuration.get(Client.CLIENT);
// ConnectionListener listener = (ConnectionListener) configuration.get(Client.CONNECTION_LISTENER);
+ log.debug(this + ": client = " + client + ", listener = " + listener);
if (client != null && listener != null)
{
client.addConnectionListener(listener, configuration);
15 years, 6 months
JBoss Remoting SVN: r5132 - remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-05 04:23:32 -0400 (Tue, 05 May 2009)
New Revision: 5132
Modified:
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/LeasePinger.java
Log:
JBREM-1112 (and others to be named): Added some logging.
Modified: remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/LeasePinger.java
===================================================================
--- remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/LeasePinger.java 2009-05-05 08:22:57 UTC (rev 5131)
+++ remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/LeasePinger.java 2009-05-05 08:23:32 UTC (rev 5132)
@@ -70,6 +70,7 @@
public void stopPing()
{
+ log.debug(this + " entered stopPing()");
if(trace) { log.trace(this + " stopping lease timer"); }
if (timerTask != null)
@@ -77,10 +78,10 @@
timerTask.cancel();
timerTask = null;
- Iterator it = clients.keySet().iterator();
+ Iterator it = clients.values().iterator();
{
Client client = (Client) it.next();
- client.disconnectAndNotify();
+ client.notifyAndDisconnect();
it.remove();
}
@@ -165,6 +166,10 @@
startPing();
}
}
+ else
+ {
+ log.debug(this + " has already shut down");
+ }
}
public boolean removeClient(String sessionID)
15 years, 6 months
JBoss Remoting SVN: r5131 - remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-05 04:22:57 -0400 (Tue, 05 May 2009)
New Revision: 5131
Modified:
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/ConnectionValidator.java
Log:
JBREM-1112 (and others to be named): Calls notifyListeners() if leasePinger == null.
Modified: remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/ConnectionValidator.java
===================================================================
--- remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/ConnectionValidator.java 2009-05-05 08:22:05 UTC (rev 5130)
+++ remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/ConnectionValidator.java 2009-05-05 08:22:57 UTC (rev 5131)
@@ -532,6 +532,7 @@
leasePinger = sharedInvoker.getLeasePinger();
}
}
+ log.debug(this + ": sharedInvoker = " + sharedInvoker + ", leasePinger = " + leasePinger);
}
private void getParametersFromMap(Map config)
@@ -854,6 +855,7 @@
{
log.debug(ConnectionValidator.this + " shutting down lease pinger: " + leasePinger);
int disconnectTimeout = (failureDisconnectTimeout == -1) ? client.getDisconnectTimeout() : failureDisconnectTimeout;
+ log.debug(ConnectionValidator.this + " disconnectTimeout: " + disconnectTimeout);
// MicroRemoteClientInvoker.terminateLease() will call LeasePinger.stopPing(), which will call
// Client.disconnectAndNotify() for all Clients with registered ConnectionListeners, and
// Client.disconnectAndNotify() will call ConnectionValidator.notifyListeners().
@@ -863,6 +865,7 @@
{
// log.debug(ConnectionValidator.this + " unable to shut down lease pinger: " + leasePinger + ". Client must have shut down");
log.debug(ConnectionValidator.this + " unable to shut down null lease pinger. Client must have shut down");
+ notifyListeners(new Exception("Could not connect to server!"));
}
cancel();
15 years, 6 months
JBoss Remoting SVN: r5130 - remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-05 04:22:05 -0400 (Tue, 05 May 2009)
New Revision: 5130
Modified:
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/Client.java
Log:
JBREM-1112 (and others to be named): Renamed and rewrote disconnectAndNotify().
Modified: remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/Client.java
===================================================================
--- remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/Client.java 2009-05-05 01:54:59 UTC (rev 5129)
+++ remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/Client.java 2009-05-05 08:22:05 UTC (rev 5130)
@@ -396,6 +396,7 @@
// synchronized (connectionValidatorLock)
// {
+ log.debug(this + " in addConnectionListener()");
if (connectionValidator == null)
{
Map map = new HashMap(configuration);
@@ -553,6 +554,7 @@
*/
public void connect(ConnectionListener listener, Map metadata) throws Exception
{
+ log.debug(this + ".connect(" + listener + ")");
if (isConnected())
return;
@@ -574,6 +576,7 @@
connect(invoker, listener, metadata);
connected = true;
+ log.debug(this + " is connected");
}
/**
@@ -1638,15 +1641,45 @@
// Package protected ----------------------------------------------------------------------------
- synchronized void disconnectAndNotify()
+ synchronized void notifyAndDisconnect()
{
// synchronized (connectionValidatorLock)
{
- disconnect();
+// disconnect();
if (connectionValidator != null)
{
+ log.debug(this + " calling connectionValidator.notifyListeners()");
connectionValidator.notifyListeners(new Exception("Could not connect to server!"));
+ Iterator it = connectionListeners.iterator();
+ while (it.hasNext())
+ {
+ ConnectionListener listener = (ConnectionListener) it.next();
+ connectionValidator.removeConnectionListener(this, listener);
+ }
+ if (connectionValidator.isStopped())
+ {
+ connectionValidators.remove(connectionValidatorKey);
+ log.debug(this + " removed from static map: " + connectionValidator);
+ }
+ else
+ {
+ log.debug(this + ": " + connectionValidator + " is not stopped");
+ }
+
+ connectionValidator = null;
+ connectionValidatorKey = null;
}
+
+ if (invoker != null)
+ {
+ // Need to remove myself from registry so will not keep reference to me since I am of no
+ // use now. Will have to create a new one.
+
+ InvokerRegistry.destroyClientInvoker(invoker.getLocator(), configuration);
+ invoker = null;
+ }
+
+ connected = false;
}
}
@@ -1769,6 +1802,7 @@
}
temp.put(CLIENT, this);
temp.put(CONNECTION_LISTENER, listener);
+ log.debug(this + " calling MicroRemoteClientInvoker.establishLease()");
invoker.establishLease(sessionId, temp, leasePeriod);
}
else if (listener != null)
15 years, 6 months
JBoss Remoting SVN: r5129 - remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/callback.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-04 21:54:59 -0400 (Mon, 04 May 2009)
New Revision: 5129
Modified:
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java
Log:
JBREM-1112 (and others to be named): Calls callbackClient.setSessionId() once instead of each time handleCallback() is called.
Modified: remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java
===================================================================
--- remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java 2009-05-05 01:52:00 UTC (rev 5128)
+++ remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java 2009-05-05 01:54:59 UTC (rev 5129)
@@ -217,6 +217,7 @@
metadata.put(SERVER_INVOKER_CALLBACK_HANDLER, this);
callBackClient = new Client(invocation.getLocator(), invocation.getSubsystem(), metadata);
+ callBackClient.setSessionId(sessionId);
createCallbackErrorHandler(owner, invocation.getSubsystem());
}
else
@@ -818,7 +819,7 @@
InternalInvocation internalInvocation =
new InternalInvocation(InternalInvocation.HANDLECALLBACK, new Object[]{callback});
- callBackClient.setSessionId(sessionId);
+// callBackClient.setSessionId(sessionId);
if (asynch)
{
15 years, 7 months
JBoss Remoting SVN: r5128 - remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-04 21:52:00 -0400 (Mon, 04 May 2009)
New Revision: 5128
Modified:
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java
Log:
JBREM-1112 (and others to be named): (1) establishLease() calls client.addConnectionListener(); (2) terminateLease() takes LeasePinger parameter..
Modified: remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java
===================================================================
--- remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java 2009-05-05 01:49:23 UTC (rev 5127)
+++ remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java 2009-05-05 01:52:00 UTC (rev 5128)
@@ -337,8 +337,18 @@
public void terminateLease(String sessionId, int disconnectTimeout)
{
+ terminateLease(sessionId, disconnectTimeout, null);
+ }
+
+ public void terminateLease(String sessionId, int disconnectTimeout, LeasePinger passedLeasePinger)
+ {
synchronized(clientLeaseLock)
{
+ if (passedLeasePinger != leasePinger)
+ {
+ log.debug(this + ": " + passedLeasePinger + " != " + leasePinger);
+ return;
+ }
if(leasePinger != null)
{
leasePinger.setDisconnectTimeout(disconnectTimeout);
@@ -402,6 +412,9 @@
public void establishLease(String clientSessionID, Map configuration, long leasePeriod)
throws Throwable
{
+ Client client = (Client) configuration.get(Client.CLIENT);
+ ConnectionListener listener = (ConnectionListener) configuration.remove(Client.CONNECTION_LISTENER);
+
synchronized (clientLeaseLock)
{
// if already have a lease pinger, then already have a client with an established
@@ -464,6 +477,15 @@
e.initCause(throwable);
throw e;
}
+ finally
+ {
+// Client client = (Client) configuration.get(Client.CLIENT);
+// ConnectionListener listener = (ConnectionListener) configuration.get(Client.CONNECTION_LISTENER);
+ if (client != null && listener != null)
+ {
+ client.addConnectionListener(listener, configuration);
+ }
+ }
}
}
15 years, 7 months
JBoss Remoting SVN: r5127 - remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-05-04 21:49:23 -0400 (Mon, 04 May 2009)
New Revision: 5127
Modified:
remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/LeasePinger.java
Log:
JBREM-1112 (and others to be named): Stores Clients so stopPing() can call Client.disconnectAndNotify().
Modified: remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/LeasePinger.java
===================================================================
--- remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/LeasePinger.java 2009-05-05 01:46:25 UTC (rev 5126)
+++ remoting2/branches/2.2.2-SP11_JBREM-1112/src/main/org/jboss/remoting/LeasePinger.java 2009-05-05 01:49:23 UTC (rev 5127)
@@ -2,8 +2,6 @@
import org.jboss.logging.Logger;
import org.jboss.remoting.transport.ClientInvoker;
-import org.jboss.util.id.GUID;
-
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -41,6 +39,7 @@
private ClientInvoker invoker = null;
private String invokerSessionID = null;
+ private Map clientSessionIds = new ConcurrentHashMap();
private Map clients = new ConcurrentHashMap();
private TimerTask timerTask = null;
@@ -78,6 +77,13 @@
timerTask.cancel();
timerTask = null;
+ Iterator it = clients.keySet().iterator();
+ {
+ Client client = (Client) it.next();
+ client.disconnectAndNotify();
+ it.remove();
+ }
+
try
{
// sending request map with no ClientHolders will indicate to server
@@ -108,14 +114,15 @@
// if (trace)
{
log.debug(this + " shut down");
- if (!clients.isEmpty())
+ if (!clientSessionIds.isEmpty())
{
- log.debug(this + " " + clients.size() + " remaining clients:");
- Iterator it = clients.keySet().iterator();
+ log.debug(this + " " + clientSessionIds.size() + " remaining clients:");
+ it = clientSessionIds.keySet().iterator();
while (it.hasNext())
{
log.debug(this + ": " + it.next());
}
+ clientSessionIds.clear();
}
else
{
@@ -134,8 +141,14 @@
if(trace) { log.trace(this + " adding new client with session ID " + sessionID + " and lease period " + leasePeriod); }
+ Client client = (Client) configuration.remove(Client.CLIENT);
+ if (client != null)
+ {
+ clients.put(sessionID, client);
+ }
+
ClientHolder newClient = new ClientHolder(sessionID, configuration, leasePeriod);
- clients.put(sessionID, newClient);
+ clientSessionIds.put(sessionID, newClient);
sendClientPing();
@@ -162,7 +175,7 @@
// Don't remove holder until after client has been removed from server side Lease, to
// avoid a race with LeaseTimerTask sending a PING without the Client being removed.
- ClientHolder holder = (ClientHolder)clients.get(sessionID);
+ ClientHolder holder = (ClientHolder)clientSessionIds.get(sessionID);
if (holder != null)
{
@@ -191,7 +204,7 @@
"client with session ID " + sessionID);
}
- clients.remove(sessionID);
+ clientSessionIds.remove(sessionID);
}
else
{
@@ -199,7 +212,7 @@
", but no such lease was found: probably it was registered with an older LeasePinger");
}
- if (clients.isEmpty())
+ if (clientSessionIds.isEmpty())
{
isLastClientLease = true;
if(trace) { log.trace(this + " has no more client leases"); }
@@ -211,7 +224,7 @@
long tempPingPeriod = defaultPingPeriod;
- for (Iterator i = clients.values().iterator(); i.hasNext(); )
+ for (Iterator i = clientSessionIds.values().iterator(); i.hasNext(); )
{
ClientHolder clientHolder = (ClientHolder)i.next();
long clientHolderLeasePeriod = clientHolder.getLeasePeriod();
@@ -247,7 +260,7 @@
}
// look to see if the client is still amont those serviced by this lease pinger
- if (clients.containsKey(sessionID))
+ if (clientSessionIds.containsKey(sessionID))
{
return pingPeriod;
}
@@ -297,9 +310,9 @@
if(trace)
{
StringBuffer sb = new StringBuffer();
- if(clients != null)
+ if(clientSessionIds != null)
{
- for(Iterator i = clients.values().iterator(); i.hasNext(); )
+ for(Iterator i = clientSessionIds.values().iterator(); i.hasNext(); )
{
ClientHolder h = (ClientHolder)i.next();
sb.append(" ").append(h.getSessionId()).append('\n');
@@ -310,7 +323,7 @@
"for following clients:\n" + sb.toString());
}
- Map clientsClone = new ConcurrentHashMap(clients);
+ Map clientsClone = new ConcurrentHashMap(clientSessionIds);
Map requestClients = new ConcurrentHashMap();
requestClients.put(ClientHolder.CLIENT_HOLDER_KEY, clientsClone);
requestClients.put(LeasePinger.LEASE_PINGER_ID, leasePingerId);
15 years, 7 months