Author: fhanik
Date: Tue Mar 21 08:15:21 2006
New Revision: 387569
URL: http://svn.apache.org/viewcvs?rev=387569&view=rev
Log:
The DeltaSession now implements ReplicatedMapEntry, so it can be used in the
LazyReplicatedMap scenario
Modified:
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/ClusterManager.java
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/ClusterManagerBase.java
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaManager.java
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaRequest.java
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaSession.java
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/SerializablePrincipal.java
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/SimpleTcpReplicationManager.java
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
Modified:
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/ClusterManager.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/ClusterManager.java?rev=387569&r1=387568&r2=387569&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/ClusterManager.java
(original)
+++
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/ClusterManager.java
Tue Mar 21 08:15:21 2006
@@ -18,6 +18,8 @@
import org.apache.catalina.Manager;
+import java.io.IOException;
+import org.apache.catalina.tribes.io.ReplicationStream;
/**
@@ -98,4 +100,11 @@
* @since 5.5.10
*/
public boolean isDefaultMode();
+
+ public ReplicationStream getReplicationStream(byte[] data) throws
IOException;
+
+ public ReplicationStream getReplicationStream(byte[] data, int offset, int
length) throws IOException;
+
+ public boolean isNotifyListenersOnReplication();
+
}
Modified:
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/ClusterManagerBase.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/ClusterManagerBase.java?rev=387569&r1=387568&r2=387569&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/ClusterManagerBase.java
(original)
+++
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/ClusterManagerBase.java
Tue Mar 21 08:15:21 2006
@@ -41,6 +41,10 @@
* @throws IOException
*/
public ReplicationStream getReplicationStream(byte[] data) throws
IOException {
+ return getReplicationStream(data,0,data.length);
+ }
+
+ public ReplicationStream getReplicationStream(byte[] data, int offset, int
length) throws IOException {
ByteArrayInputStream fis =null;
ReplicationStream ois = null;
Loader loader = null;
@@ -55,7 +59,7 @@
else
classLoader = Thread.currentThread().getContextClassLoader();
//end fix
- fis = new ByteArrayInputStream(data);
+ fis = new ByteArrayInputStream(data,offset,length);
if ( classLoader == Thread.currentThread().getContextClassLoader() ) {
ois = new ReplicationStream(fis, new ClassLoader[] {classLoader});
} else {
Modified:
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaManager.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaManager.java?rev=387569&r1=387568&r2=387569&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaManager.java
(original)
+++
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaManager.java
Tue Mar 21 08:15:21 2006
@@ -611,7 +611,7 @@
* @throws ClassNotFoundException
* @throws IOException
*/
- protected DeltaRequest loadDeltaRequest(DeltaSession session, byte[] data)
throws ClassNotFoundException, IOException {
+ protected DeltaRequest deserializeDeltaRequest(DeltaSession session,
byte[] data) throws ClassNotFoundException, IOException {
ReplicationStream ois = getReplicationStream(data);
session.getDeltaRequest().readExternal(ois);
ois.close();
@@ -626,13 +626,8 @@
* @return serialized delta request
* @throws IOException
*/
- protected byte[] unloadDeltaRequest(DeltaRequest deltaRequest) throws
IOException {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
- deltaRequest.writeExternal(oos);
- oos.flush();
- oos.close();
- return bos.toByteArray();
+ protected byte[] serializeDeltaRequest(DeltaRequest deltaRequest) throws
IOException {
+ return deltaRequest.serialize();
}
/**
@@ -1115,7 +1110,7 @@
isDeltaRequest = deltaRequest.getSize() > 0 ;
if (isDeltaRequest) {
counterSend_EVT_SESSION_DELTA++;
- byte[] data = unloadDeltaRequest(deltaRequest);
+ byte[] data = serializeDeltaRequest(deltaRequest);
msg = new SessionMessageImpl(getName(),
SessionMessage.EVT_SESSION_DELTA,
data,
@@ -1365,7 +1360,7 @@
DeltaSession session = (DeltaSession) findSession(msg.getSessionID());
if (session != null) {
if (log.isDebugEnabled())
log.debug(sm.getString("deltaManager.receiveMessage.delta",getName(),
msg.getSessionID()));
- DeltaRequest dreq = loadDeltaRequest(session, delta);
+ DeltaRequest dreq = deserializeDeltaRequest(session, delta);
dreq.execute(session, notifyListenersOnReplication);
session.setPrimarySession(false);
}
Modified:
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaRequest.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaRequest.java?rev=387569&r1=387568&r2=387569&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaRequest.java
(original)
+++
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaRequest.java
Tue Mar 21 08:15:21 2006
@@ -32,6 +32,9 @@
import org.apache.catalina.realm.GenericPrincipal;
import org.apache.catalina.util.StringManager;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
public class DeltaRequest implements Externalizable {
@@ -216,8 +219,7 @@
actionPool.clear();
}
- public synchronized void readExternal(java.io.ObjectInput in) throws
java.io.IOException,
- java.lang.ClassNotFoundException {
+ public synchronized void readExternal(java.io.ObjectInput in) throws
IOException,ClassNotFoundException {
//sessionId - String
//recordAll - boolean
//size - int
@@ -262,6 +264,23 @@
AttributeInfo info = (AttributeInfo)actions.get(i);
info.writeExternal(out);
}
+ }
+
+ /**
+ * serialize DeltaRequest
+ * @see DeltaRequest#writeExternal(java.io.ObjectOutput)
+ *
+ * @param deltaRequest
+ * @return serialized delta request
+ * @throws IOException
+ */
+ protected byte[] serialize() throws IOException {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(bos);
+ writeExternal(oos);
+ oos.flush();
+ oos.close();
+ return bos.toByteArray();
}
private static class AttributeInfo implements java.io.Externalizable {
Modified:
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaSession.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaSession.java?rev=387569&r1=387568&r2=387569&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaSession.java
(original)
+++
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaSession.java
Tue Mar 21 08:15:21 2006
@@ -50,6 +50,14 @@
import org.apache.catalina.realm.GenericPrincipal;
import org.apache.catalina.util.Enumerator;
import org.apache.catalina.util.StringManager;
+import org.apache.catalina.tribes.tipis.ReplicatedMapEntry;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.concurrent.locks.Lock;
+import org.apache.catalina.ha.ClusterManager;
+import org.apache.catalina.tribes.io.ReplicationStream;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
/**
*
@@ -74,12 +82,9 @@
* @version $Revision: 372887 $ $Date: 2006-01-27 09:58:58 -0600 (Fri, 27 Jan
2006) $
*/
-public class DeltaSession
- implements HttpSession, Session, Serializable,
- ClusterSession {
+public class DeltaSession implements HttpSession, Session,
Externalizable,ClusterSession,ReplicatedMapEntry {
- public static org.apache.commons.logging.Log log =
org.apache.commons.logging.LogFactory
- .getLog(DeltaManager.class);
+ public static org.apache.commons.logging.Log log =
org.apache.commons.logging.LogFactory.getLog(DeltaManager.class);
/**
* The string manager for this package.
@@ -245,6 +250,8 @@
* The access count for this session
*/
protected transient int accessCount = 0;
+
+ protected Lock diffLock = new ReentrantReadWriteLock().writeLock();
// ----------------------------------------------------------- Constructors
@@ -260,9 +267,85 @@
this.resetDeltaRequest();
}
- // ----------------------------------------------------- Session Properties
+ // ----------------------------------------------------- ReplicatedMapEntry
/**
+ * Has the object changed since last replication
+ * and is not in a locked state
+ * @return boolean
+ */
+ public boolean isDirty() {
+ return getDeltaRequest().getSize()>0;
+ }
+
+ /**
+ * If this returns true, the map will extract the diff using getDiff()
+ * Otherwise it will serialize the entire object.
+ * @return boolean
+ */
+ public boolean isDiffable() {
+ return true;
+ }
+
+ /**
+ * Returns a diff and sets the dirty map to false
+ * @return byte[]
+ * @throws IOException
+ */
+ public byte[] getDiff() throws IOException {
+ return getDeltaRequest().serialize();
+ }
+
+
+ /**
+ * Applies a diff to an existing object.
+ * @param diff byte[]
+ * @param offset int
+ * @param length int
+ * @throws IOException
+ */
+ public void applyDiff(byte[] diff, int offset, int length) throws
IOException, ClassNotFoundException {
+ ReplicationStream stream =
((ClusterManager)getManager()).getReplicationStream(diff,offset,length);
+ getDeltaRequest().readExternal(stream);
+ getDeltaRequest().execute(this);
+ }
+
+ /**
+ * Resets the current diff state and resets the dirty flag
+ */
+ public void resetDiff() {
+ resetDeltaRequest();
+ }
+
+ /**
+ * Lock during serialization
+ */
+ public void lock() {
+ diffLock.lock();
+ }
+
+ /**
+ * Unlock after serialization
+ */
+ public void unlock() {
+ diffLock.unlock();
+ }
+
+ public void setOwner(Object owner) {
+ if ( owner instanceof ClusterManager ) {
+ ClusterManager cm = (ClusterManager)owner;
+ this.setManager(cm);
+ this.setValid(true);
+ this.setPrimarySession(false);
+ this.access();
+ if (cm.isNotifyListenersOnReplication())
this.setId(getIdInternal());
+ this.resetDeltaRequest();
+ this.endAccess();
+ }
+ }
+ // ----------------------------------------------------- Session Properties
+
+ /**
* returns true if this session is the primary session, if that is the
case,
* the manager can expire it upon timeout.
*/
@@ -285,9 +368,7 @@
* if any.
*/
public String getAuthType() {
-
return (this.authType);
-
}
/**
@@ -298,11 +379,9 @@
* The new cached authentication type
*/
public void setAuthType(String authType) {
-
String oldAuthType = this.authType;
this.authType = authType;
support.firePropertyChange("authType", oldAuthType, this.authType);
-
}
/**
@@ -313,11 +392,9 @@
* The new creation time
*/
public void setCreationTime(long time) {
-
this.creationTime = time;
this.lastAccessedTime = time;
this.thisAccessedTime = time;
-
}
/**
@@ -325,16 +402,13 @@
*/
public String getId() {
return (this.id);
-
}
/**
* Return the session identifier for this session.
*/
public String getIdInternal() {
-
return (this.id);
-
}
/**
@@ -367,7 +441,6 @@
*
*/
public void tellNew() {
-
// Notify interested session event listeners
fireSessionEvent(Session.SESSION_CREATED_EVENT, null);
@@ -404,9 +477,7 @@
* <code><description>/<version></code>.
*/
public String getInfo() {
-
return (info);
-
}
/**
@@ -416,12 +487,10 @@
* value associated with the session, do not affect the access time.
*/
public long getLastAccessedTime() {
-
if (!isValid()) {
throw new
IllegalStateException(sm.getString("standardSession.getId.ise"));
}
return (this.lastAccessedTime);
-
}
/**
@@ -648,12 +717,10 @@
String expiredId = getIdInternal();
synchronized (this) {
-
if (manager == null)
return;
expiring = true;
-
// Notify interested application event listeners
// FIXME - Assumes we call listeners in reverse order
Context context = (Context) manager.getContainer();
@@ -803,6 +870,11 @@
// ------------------------------------------------ Session Package Methods
+ public synchronized void readExternal(ObjectInput in) throws
IOException,ClassNotFoundException {
+ readObjectData(in);
+ }
+
+
/**
* Read a serialized version of the contents of this session object from
the
* specified object input stream, without requiring that the
StandardSession
@@ -816,7 +888,7 @@
* @exception IOException
* if an input/output error occurs
*/
- public void readObjectData(ObjectInputStream stream) throws
ClassNotFoundException, IOException {
+ public void readObjectData(ObjectInput stream) throws
ClassNotFoundException, IOException {
readObject(stream);
}
@@ -831,7 +903,7 @@
* @exception IOException
* if an input/output error occurs
*/
- public void writeObjectData(ObjectOutputStream stream) throws IOException {
+ public void writeObjectData(ObjectOutput stream) throws IOException {
writeObject(stream);
}
@@ -1112,93 +1184,97 @@
return;
}
- // Validate our current state
- if (!isValid())
- throw new
IllegalStateException(sm.getString("standardSession.setAttribute.ise"));
- if (! (value instanceof java.io.Serializable)) {
- throw new IllegalArgumentException("Attribute [" + name + "] is
not serializable");
- }
+ try {
+ lock();
+ // Validate our current state
+ if (!isValid())
+ throw new
IllegalStateException(sm.getString("standardSession.setAttribute.ise"));
+ if (! (value instanceof java.io.Serializable)) {
+ throw new IllegalArgumentException("Attribute [" + name + "]
is not serializable");
+ }
- if (addDeltaRequest && (deltaRequest != null))
- deltaRequest.setAttribute(name, value);
+ if (addDeltaRequest && (deltaRequest != null))
+ deltaRequest.setAttribute(name, value);
- // Construct an event with the new value
- HttpSessionBindingEvent event = null;
+ // Construct an event with the new value
+ HttpSessionBindingEvent event = null;
- // Call the valueBound() method if necessary
- if (value instanceof HttpSessionBindingListener && notify) {
- // Don't call any notification if replacing with the same value
- Object oldValue = attributes.get(name);
- if (value != oldValue) {
- event = new HttpSessionBindingEvent(getSession(), name, value);
+ // Call the valueBound() method if necessary
+ if (value instanceof HttpSessionBindingListener && notify) {
+ // Don't call any notification if replacing with the same value
+ Object oldValue = attributes.get(name);
+ if (value != oldValue) {
+ event = new HttpSessionBindingEvent(getSession(), name,
value);
+ try {
+ ( (HttpSessionBindingListener)
value).valueBound(event);
+ } catch (Exception x) {
+ log.error(sm.getString("deltaSession.valueBound.ex"),
x);
+ }
+ }
+ }
+
+ // Replace or add this attribute
+ Object unbound = attributes.put(name, value);
+ // Call the valueUnbound() method if necessary
+ if ( (unbound != null) && (unbound != value) && notify
+ && (unbound instanceof HttpSessionBindingListener)) {
try {
- ( (HttpSessionBindingListener) value).valueBound(event);
+ ( (HttpSessionBindingListener) unbound).valueUnbound(new
HttpSessionBindingEvent((HttpSession) getSession(), name));
} catch (Exception x) {
- log.error(sm.getString("deltaSession.valueBound.ex"), x);
+ log.error(sm.getString("deltaSession.valueBinding.ex"), x);
}
- }
- }
- // Replace or add this attribute
- Object unbound = attributes.put(name, value);
- // Call the valueUnbound() method if necessary
- if ( (unbound != null) && (unbound != value) && notify
- && (unbound instanceof HttpSessionBindingListener)) {
- try {
- ( (HttpSessionBindingListener) unbound).valueUnbound(new
HttpSessionBindingEvent((HttpSession) getSession(), name));
- } catch (Exception x) {
- log.error(sm.getString("deltaSession.valueBinding.ex"), x);
}
- }
-
- //dont notify any listeners
- if (!notify)
- return;
-
- // Notify interested application event listeners
- Context context = (Context) manager.getContainer();
- //fix for standalone manager without container
- if (context != null) {
- Object listeners[] = context.getApplicationEventListeners();
- if (listeners == null)
+ //dont notify any listeners
+ if (!notify)
return;
- for (int i = 0; i < listeners.length; i++) {
- if (! (listeners[i] instanceof HttpSessionAttributeListener))
- continue;
- HttpSessionAttributeListener listener =
(HttpSessionAttributeListener) listeners[i];
- try {
- if (unbound != null) {
-
fireContainerEvent(context,"beforeSessionAttributeReplaced", listener);
- if (event == null) {
- event = new
HttpSessionBindingEvent(getSession(),name, unbound);
- }
- listener.attributeReplaced(event);
-
fireContainerEvent(context,"afterSessionAttributeReplaced", listener);
- } else {
-
fireContainerEvent(context,"beforeSessionAttributeAdded", listener);
- if (event == null) {
- event =
- new HttpSessionBindingEvent(getSession(),name,
value);
- }
- listener.attributeAdded(event);
-
fireContainerEvent(context,"afterSessionAttributeAdded", listener);
- }
- } catch (Throwable t) {
+
+ // Notify interested application event listeners
+ Context context = (Context) manager.getContainer();
+ //fix for standalone manager without container
+ if (context != null) {
+ Object listeners[] = context.getApplicationEventListeners();
+ if (listeners == null)
+ return;
+ for (int i = 0; i < listeners.length; i++) {
+ if (! (listeners[i] instanceof
HttpSessionAttributeListener))
+ continue;
+ HttpSessionAttributeListener listener =
(HttpSessionAttributeListener) listeners[i];
try {
if (unbound != null) {
+
fireContainerEvent(context,"beforeSessionAttributeReplaced", listener);
+ if (event == null) {
+ event = new
HttpSessionBindingEvent(getSession(),name, unbound);
+ }
+ listener.attributeReplaced(event);
fireContainerEvent(context,"afterSessionAttributeReplaced", listener);
} else {
+
fireContainerEvent(context,"beforeSessionAttributeAdded", listener);
+ if (event == null) {
+ event =
+ new
HttpSessionBindingEvent(getSession(),name, value);
+ }
+ listener.attributeAdded(event);
fireContainerEvent(context,"afterSessionAttributeAdded", listener);
}
- } catch (Exception e) {}
- // FIXME - should we do anything besides log these?
-
log.error(sm.getString("standardSession.attributeEvent"),t);
- }
- } //for
- } //end if
- //end fix
-
+ } catch (Throwable t) {
+ try {
+ if (unbound != null) {
+
fireContainerEvent(context,"afterSessionAttributeReplaced", listener);
+ } else {
+
fireContainerEvent(context,"afterSessionAttributeAdded", listener);
+ }
+ } catch (Exception e) {}
+ // FIXME - should we do anything besides log these?
+
log.error(sm.getString("standardSession.attributeEvent"),t);
+ }
+ } //for
+ } //end if
+ //end fix
+ } finally {
+ unlock();
+ }
}
// -------------------------------------------- HttpSession Private Methods
@@ -1218,7 +1294,7 @@
* @exception IOException
* if an input/output error occurs
*/
- private void readObject(ObjectInputStream stream) throws
ClassNotFoundException, IOException {
+ private void readObject(ObjectInput stream) throws ClassNotFoundException,
IOException {
// Deserialize the scalar instance variables (except Manager)
authType = null; // Transient only
@@ -1260,6 +1336,11 @@
notes = new Hashtable();
}
}
+
+ public synchronized void writeExternal(ObjectOutput out ) throws
java.io.IOException {
+ writeObject(out);
+ }
+
/**
* Write a serialized version of this session object to the specified
object
@@ -1282,7 +1363,7 @@
* @exception IOException
* if an input/output error occurs
*/
- private void writeObject(ObjectOutputStream stream) throws IOException {
+ private void writeObject(ObjectOutput stream) throws IOException {
// Write the scalar instance variables (except Manager)
stream.writeObject(new Long(creationTime));
@@ -1413,60 +1494,65 @@
protected void removeAttributeInternal(String name, boolean notify,
boolean addDeltaRequest) {
- // Remove this attribute from our collection
- Object value = attributes.remove(name);
- if (value == null)
- return;
+ try {
+ lock();
- if (addDeltaRequest && (deltaRequest != null))
- deltaRequest.removeAttribute(name);
+ // Remove this attribute from our collection
+ Object value = attributes.remove(name);
+ if (value == null)
+ return;
- // Do we need to do valueUnbound() and attributeRemoved() notification?
- if (!notify) {
- return;
- }
+ if (addDeltaRequest && (deltaRequest != null))
+ deltaRequest.removeAttribute(name);
- // Call the valueUnbound() method if necessary
- HttpSessionBindingEvent event = null;
- if (value instanceof HttpSessionBindingListener) {
- event = new HttpSessionBindingEvent((HttpSession) getSession(),
name, value);
- try {
- ( (HttpSessionBindingListener) value).valueUnbound(event);
- } catch (Exception x) {
- log.error(sm.getString("deltaSession.valueUnbound.ex"), x);
- }
- }
- // Notify interested application event listeners
- Context context = (Context) manager.getContainer();
- //fix for standalone manager without container
- if (context != null) {
- Object listeners[] = context.getApplicationEventListeners();
- if (listeners == null)
+ // Do we need to do valueUnbound() and attributeRemoved()
notification?
+ if (!notify) {
return;
- for (int i = 0; i < listeners.length; i++) {
- if (! (listeners[i] instanceof HttpSessionAttributeListener))
- continue;
- HttpSessionAttributeListener listener =
(HttpSessionAttributeListener) listeners[i];
+ }
+
+ // Call the valueUnbound() method if necessary
+ HttpSessionBindingEvent event = null;
+ if (value instanceof HttpSessionBindingListener) {
+ event = new HttpSessionBindingEvent((HttpSession)
getSession(), name, value);
try {
-
fireContainerEvent(context,"beforeSessionAttributeRemoved", listener);
- if (event == null) {
- event = new HttpSessionBindingEvent(getSession(),
name, value);
- }
- listener.attributeRemoved(event);
- fireContainerEvent(context,
"afterSessionAttributeRemoved",listener);
- } catch (Throwable t) {
+ ( (HttpSessionBindingListener) value).valueUnbound(event);
+ } catch (Exception x) {
+ log.error(sm.getString("deltaSession.valueUnbound.ex"), x);
+ }
+ }
+ // Notify interested application event listeners
+ Context context = (Context) manager.getContainer();
+ //fix for standalone manager without container
+ if (context != null) {
+ Object listeners[] = context.getApplicationEventListeners();
+ if (listeners == null)
+ return;
+ for (int i = 0; i < listeners.length; i++) {
+ if (! (listeners[i] instanceof
HttpSessionAttributeListener))
+ continue;
+ HttpSessionAttributeListener listener =
(HttpSessionAttributeListener) listeners[i];
try {
-
fireContainerEvent(context,"afterSessionAttributeRemoved", listener);
- } catch (Exception e) {
- ;
+
fireContainerEvent(context,"beforeSessionAttributeRemoved", listener);
+ if (event == null) {
+ event = new HttpSessionBindingEvent(getSession(),
name, value);
+ }
+ listener.attributeRemoved(event);
+ fireContainerEvent(context,
"afterSessionAttributeRemoved",listener);
+ } catch (Throwable t) {
+ try {
+
fireContainerEvent(context,"afterSessionAttributeRemoved", listener);
+ } catch (Exception e) {
+ ;
+ }
+ // FIXME - should we do anything besides log these?
+
log.error(sm.getString("standardSession.attributeEvent"),t);
}
- // FIXME - should we do anything besides log these?
-
log.error(sm.getString("standardSession.attributeEvent"),t);
- }
- } //for
- } //end if
- //end fix
-
+ } //for
+ } //end if
+ //end fix
+ }finally {
+ unlock();
+ }
}
protected long getLastTimeReplicated() {
Modified:
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/SerializablePrincipal.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/SerializablePrincipal.java?rev=387569&r1=387568&r2=387569&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/SerializablePrincipal.java
(original)
+++
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/SerializablePrincipal.java
Tue Mar 21 08:15:21 2006
@@ -32,6 +32,8 @@
* @version $Revision: 303587 $ $Date: 2004-12-09 08:36:43 -0600 (Thu, 09 Dec
2004) $
*/
import org.apache.catalina.realm.GenericPrincipal;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
public class SerializablePrincipal implements java.io.Serializable {
@@ -165,7 +167,7 @@
return new
GenericPrincipal(realm,name,password,getRoles()!=null?Arrays.asList(getRoles()):null);
}
- public static GenericPrincipal readPrincipal(java.io.ObjectInputStream in,
Realm realm) throws java.io.IOException{
+ public static GenericPrincipal readPrincipal(ObjectInput in, Realm realm)
throws java.io.IOException{
String name = in.readUTF();
boolean hasPwd = in.readBoolean();
String pwd = null;
@@ -176,7 +178,7 @@
return new GenericPrincipal(realm,name,pwd,Arrays.asList(roles));
}
- public static void writePrincipal(GenericPrincipal p,
java.io.ObjectOutputStream out) throws java.io.IOException {
+ public static void writePrincipal(GenericPrincipal p, ObjectOutput out)
throws java.io.IOException {
out.writeUTF(p.getName());
out.writeBoolean(p.getPassword()!=null);
if ( p.getPassword()!= null ) out.writeUTF(p.getPassword());
Modified:
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/SimpleTcpReplicationManager.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/SimpleTcpReplicationManager.java?rev=387569&r1=387568&r2=387569&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/SimpleTcpReplicationManager.java
(original)
+++
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/SimpleTcpReplicationManager.java
Tue Mar 21 08:15:21 2006
@@ -372,6 +372,10 @@
* @throws IOException
*/
public ReplicationStream getReplicationStream(byte[] data) throws
IOException {
+ return getReplicationStream(data,0,data.length);
+ }
+
+ public ReplicationStream getReplicationStream(byte[] data, int offset, int
length) throws IOException {
ByteArrayInputStream fis =null;
ReplicationStream ois = null;
Loader loader = null;
@@ -386,7 +390,7 @@
else
classLoader = Thread.currentThread().getContextClassLoader();
//end fix
- fis = new ByteArrayInputStream(data);
+ fis = new ByteArrayInputStream(data, offset, length);
if ( classLoader == Thread.currentThread().getContextClassLoader() ) {
ois = new ReplicationStream(fis, new ClassLoader[] {classLoader});
} else {
Modified:
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/tcp/SimpleTcpCluster.java?rev=387569&r1=387568&r2=387569&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
(original)
+++
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
Tue Mar 21 08:15:21 2006
@@ -168,6 +168,11 @@
* dynamic sender <code>properties</code>
*/
private Map properties = new HashMap();
+
+ private int channelSendOptions =
+ Channel.SEND_OPTIONS_ASYNCHRONOUS |
+ Channel.SEND_OPTIONS_SYNCHRONIZED_ACK |
+ Channel.SEND_OPTIONS_USE_ACK;
// ------------------------------------------------------------- Properties
@@ -779,11 +784,11 @@
msg.setAddress(getLocalMember());
if (dest != null) {
if (!getLocalMember().equals(dest)) {
- channel.send(new Member[] {dest},
msg,channel.SEND_OPTIONS_DEFAULT);
+ channel.send(new Member[] {dest}, msg,channelSendOptions);
} else
log.error("Unable to send message to local member " + msg);
} else {
-
channel.send(channel.getMembers(),msg,channel.SEND_OPTIONS_DEFAULT);
+ channel.send(channel.getMembers(),msg,channelSendOptions);
}
} catch (Exception x) {
log.error("Unable to send message through cluster sender.", x);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]