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);
Show replies by date