You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/10/22 23:09:54 UTC
svn commit: r1187789 [3/3] - in
/tomcat/trunk/java/org/apache/catalina/tribes: ./ group/
group/interceptors/ io/ membership/ tipis/ transport/ transport/bio/
transport/bio/util/ transport/nio/ util/
Modified: tomcat/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java Sat Oct 22 21:09:52 2011
@@ -67,7 +67,7 @@ public abstract class AbstractReplicated
* The load factor used when none specified in constructor.
**/
public static final float DEFAULT_LOAD_FACTOR = 0.75f;
-
+
/**
* Used to identify the map
*/
@@ -78,8 +78,8 @@ public abstract class AbstractReplicated
// INSTANCE VARIABLES
//------------------------------------------------------------------------------
protected abstract int getStateMessageType();
-
-
+
+
/**
* Timeout for RPC messages, how long we will wait for a reply
*/
@@ -122,21 +122,21 @@ public abstract class AbstractReplicated
* External class loaders if serialization and deserialization is to be performed successfully.
*/
protected transient ClassLoader[] externalLoaders;
-
+
/**
* The node we are currently backing up data to, this index will rotate
* on a round robin basis
*/
protected transient int currentNode = 0;
-
+
/**
* Since the map keeps internal membership
* this is the timeout for a ping message to be responded to
- * If a remote map doesn't respond within this timeframe,
+ * If a remote map doesn't respond within this timeframe,
* its considered dead.
*/
protected transient long accessTimeout = 5000;
-
+
/**
* Readable string of the mapContextName value
*/
@@ -145,7 +145,7 @@ public abstract class AbstractReplicated
//------------------------------------------------------------------------------
// map owner interface
//------------------------------------------------------------------------------
-
+
public static interface MapOwner {
// a typo, should have been "objectMadePrimary"
public void objectMadePrimay(Object key, Object value);
@@ -165,16 +165,16 @@ public abstract class AbstractReplicated
* @param cls - a list of classloaders to be used for deserialization of objects.
*/
public AbstractReplicatedMap(MapOwner owner,
- Channel channel,
- long timeout,
- String mapContextName,
+ Channel channel,
+ long timeout,
+ String mapContextName,
int initialCapacity,
float loadFactor,
int channelSendOptions,
ClassLoader[] cls) {
super(initialCapacity, loadFactor, 15);
init(owner, channel, mapContextName, timeout, channelSendOptions, cls);
-
+
}
/**
@@ -216,8 +216,8 @@ public abstract class AbstractReplicated
this.channel.addChannelListener(this);
//listen for membership notifications
this.channel.addMembershipListener(this);
-
-
+
+
try {
//broadcast our map, this just notifies other members of our existence
broadcast(MapMessage.MSG_INIT, true);
@@ -234,8 +234,8 @@ public abstract class AbstractReplicated
throw new RuntimeException("Unable to start replicated map.",x);
}
}
-
-
+
+
/**
* Sends a ping out to all the members in the cluster, not just map members
* that this map is alive.
@@ -244,19 +244,19 @@ public abstract class AbstractReplicated
*/
protected void ping(long timeout) throws ChannelException {
//send out a map membership message, only wait for the first reply
- MapMessage msg = new MapMessage(this.mapContextName,
+ MapMessage msg = new MapMessage(this.mapContextName,
MapMessage.MSG_INIT,
- false,
- null,
- null,
- null,
+ false,
+ null,
+ null,
+ null,
channel.getLocalMember(false),
null);
if ( channel.getMembers().length > 0 ) {
try {
//send a ping, wait for all nodes to reply
- Response[] resp = rpcChannel.send(channel.getMembers(),
- msg, RpcChannel.ALL_REPLY,
+ Response[] resp = rpcChannel.send(channel.getMembers(),
+ msg, RpcChannel.ALL_REPLY,
(channelSendOptions),
(int) accessTimeout);
for (int i = 0; i < resp.length; i++) {
@@ -268,7 +268,7 @@ public abstract class AbstractReplicated
for (FaultyMember faultyMember : faultyMembers) {
memberDisappeared(faultyMember.getMember());
}
- }
+ }
}
//update our map of members, expire some if we didn't receive a ping back
synchronized (mapMembers) {
@@ -276,7 +276,7 @@ public abstract class AbstractReplicated
long now = System.currentTimeMillis();
while ( it.hasNext() ) {
Map.Entry<Member,Long> entry = it.next();
- long access = entry.getValue().longValue();
+ long access = entry.getValue().longValue();
if ( (now - access) > timeout ) {
it.remove();
memberDisappeared(entry.getKey());
@@ -297,7 +297,7 @@ public abstract class AbstractReplicated
mapMembers.put(member, new Long(System.currentTimeMillis()));
}
}
-
+
/**
* Helper method to broadcast a message to all members in a channel
* @param msgtype int
@@ -349,12 +349,12 @@ public abstract class AbstractReplicated
this.stateTransferred = false;
this.externalLoaders = null;
}
-
+
@Override
public int hashCode() {
return Arrays.hashCode(this.mapContextName);
}
-
+
@Override
public boolean equals(Object o) {
if ( !(o instanceof AbstractReplicatedMap)) return false;
@@ -376,7 +376,7 @@ public abstract class AbstractReplicated
public Member[] getMapMembers() {
return getMapMembers(this.mapMembers);
}
-
+
public Member[] getMapMembersExcl(Member[] exclude) {
synchronized (mapMembers) {
@SuppressWarnings("unchecked") // mapMembers has the correct type
@@ -404,11 +404,11 @@ public abstract class AbstractReplicated
Object value = entry.getValue();
//check to see if we need to replicate this object isDirty()||complete
boolean repl = complete || ( (value instanceof ReplicatedMapEntry) && ( (ReplicatedMapEntry) value).isDirty());
-
+
if (!repl) {
if ( log.isTraceEnabled() )
log.trace("Not replicating:"+key+", no change made");
-
+
return;
}
//check to see if the message is diffable
@@ -430,7 +430,7 @@ public abstract class AbstractReplicated
} finally {
rentry.unlock();
}
-
+
}
if (msg == null) {
//construct a complete
@@ -512,7 +512,7 @@ public abstract class AbstractReplicated
mapmsg.setPrimary(channel.getLocalMember(false));
return mapmsg;
}
-
+
//map start request
if (mapmsg.getMsgType() == MapMessage.MSG_START) {
mapmsg.setPrimary(channel.getLocalMember(false));
@@ -538,7 +538,7 @@ public abstract class AbstractReplicated
MapEntry entry = (MapEntry) super.get(e.getKey());
if ( entry != null && entry.isSerializable() ) {
boolean copy = (mapmsg.getMsgType() == MapMessage.MSG_STATE_COPY);
- MapMessage me = new MapMessage(mapContextName,
+ MapMessage me = new MapMessage(mapContextName,
copy?MapMessage.MSG_COPY:MapMessage.MSG_PROXY,
false, (Serializable) entry.getKey(), copy?(Serializable) entry.getValue():null, null, entry.getPrimary(),entry.getBackupNodes());
list.add(me);
@@ -546,7 +546,7 @@ public abstract class AbstractReplicated
}
mapmsg.setValue(list);
return mapmsg;
-
+
} //synchronized
}
@@ -588,7 +588,7 @@ public abstract class AbstractReplicated
if ( log.isTraceEnabled() ) {
log.trace("Map["+mapname+"] received message:"+mapmsg);
}
-
+
try {
mapmsg.deserialize(getExternalLoaders());
} catch (IOException x) {
@@ -598,7 +598,7 @@ public abstract class AbstractReplicated
log.error("Unable to deserialize MapMessage.", x);
return;
}
- if ( log.isTraceEnabled() )
+ if ( log.isTraceEnabled() )
log.trace("Map message received from:"+sender.getName()+" msg:"+mapmsg);
if (mapmsg.getMsgType() == MapMessage.MSG_START) {
mapMemberAdded(mapmsg.getPrimary());
@@ -713,7 +713,7 @@ public abstract class AbstractReplicated
} //synchronized
}//end if
}
-
+
public boolean inSet(Member m, Member[] set) {
if ( set == null ) return false;
boolean result = false;
@@ -726,7 +726,7 @@ public abstract class AbstractReplicated
ArrayList<Member> result = new ArrayList<Member>();
for (int i=0; i<set.length; i++ ) {
boolean include = true;
- for (int j=0; j<mbrs.length; j++ )
+ for (int j=0; j<mbrs.length; j++ )
if ( mbrs[j].equals(set[i]) ) include = false;
if ( include ) result.add(set[i]);
}
@@ -748,7 +748,7 @@ public abstract class AbstractReplicated
return; //the member was not part of our map.
}
}
-
+
Iterator<Map.Entry<?,?>> i = super.entrySet().iterator();
while (i.hasNext()) {
Map.Entry<?,?> e = i.next();
@@ -767,10 +767,10 @@ public abstract class AbstractReplicated
if (log.isDebugEnabled()) log.debug("[2] Primary disappeared");
entry.setPrimary(null);
} //end if
-
+
if ( entry.isProxy() &&
- entry.getPrimary() == null &&
- entry.getBackupNodes()!=null &&
+ entry.getPrimary() == null &&
+ entry.getBackupNodes()!=null &&
entry.getBackupNodes().length == 1 &&
entry.getBackupNodes()[0].equals(member) ) {
//remove proxies that have no backup nor primaries
@@ -778,7 +778,7 @@ public abstract class AbstractReplicated
i.remove();
} else if ( entry.getPrimary() == null &&
entry.isBackup() &&
- entry.getBackupNodes()!=null &&
+ entry.getBackupNodes()!=null &&
entry.getBackupNodes().length == 1 &&
entry.getBackupNodes()[0].equals(channel.getLocalMember(false)) ) {
try {
@@ -789,7 +789,7 @@ public abstract class AbstractReplicated
Member[] backup = publishEntryInfo(entry.getKey(), entry.getValue());
entry.setBackupNodes(backup);
if ( mapOwner!=null ) mapOwner.objectMadePrimay(entry.getKey(),entry.getValue());
-
+
} catch (ChannelException x) {
log.error("Unable to relocate[" + entry.getKey() + "] to a new backup node", x);
}
@@ -817,7 +817,7 @@ public abstract class AbstractReplicated
}
protected abstract Member[] publishEntryInfo(Object key, Object value) throws ChannelException;
-
+
@Override
public void heartbeat() {
try {
@@ -827,13 +827,13 @@ public abstract class AbstractReplicated
}
}
-//------------------------------------------------------------------------------
-// METHODS TO OVERRIDE
//------------------------------------------------------------------------------
-
+// METHODS TO OVERRIDE
+//------------------------------------------------------------------------------
+
/**
- * Removes an object from this map, it will also remove it from
- *
+ * Removes an object from this map, it will also remove it from
+ *
* @param key Object
* @return Object
*/
@@ -854,11 +854,11 @@ public abstract class AbstractReplicated
}
return entry!=null?entry.getValue():null;
}
-
+
public MapEntry getInternal(Object key) {
return (MapEntry)super.get(key);
}
-
+
@Override
public Object get(Object key) {
MapEntry entry = (MapEntry)super.get(key);
@@ -900,7 +900,7 @@ public abstract class AbstractReplicated
}
if ( entry.getValue() != null && entry.getValue() instanceof ReplicatedMapEntry ) {
ReplicatedMapEntry val = (ReplicatedMapEntry)entry.getValue();
- val.setOwner(getMapOwner());
+ val.setOwner(getMapOwner());
}
}
entry.setPrimary(channel.getLocalMember(false));
@@ -916,9 +916,9 @@ public abstract class AbstractReplicated
}
if (log.isTraceEnabled()) log.trace("Requesting id:"+key+" result:"+entry.getValue());
return entry.getValue();
- }
+ }
+
-
protected void printMap(String header) {
try {
System.out.println("\nDEBUG MAP:"+header);
@@ -941,7 +941,7 @@ public abstract class AbstractReplicated
ignore.printStackTrace();
}
}
-
+
/**
* Returns true if the key has an entry in the map.
* The entry can be a proxy or a backup entry, invoking <code>get(key)</code>
@@ -953,20 +953,20 @@ public abstract class AbstractReplicated
public boolean containsKey(Object key) {
return super.containsKey(key);
}
-
+
@Override
public Object put(Object key, Object value) {
return put(key,value,true);
}
-
+
public Object put(Object key, Object value, boolean notify) {
MapEntry entry = new MapEntry(key,value);
entry.setBackup(false);
entry.setProxy(false);
entry.setPrimary(channel.getLocalMember(false));
-
+
Object old = null;
-
+
//make sure that any old values get removed
if ( containsKey(key) ) old = remove(key);
try {
@@ -980,8 +980,8 @@ public abstract class AbstractReplicated
super.put(key,entry);
return old;
}
-
-
+
+
/**
* Copies all values from one map to this instance
* @param m Map
@@ -994,12 +994,12 @@ public abstract class AbstractReplicated
put(entry.getKey(),entry.getValue());
}
}
-
+
@Override
public void clear() {
clear(true);
}
-
+
public void clear(boolean notify) {
if ( notify ) {
//only delete active keys
@@ -1010,7 +1010,7 @@ public abstract class AbstractReplicated
super.clear();
}
}
-
+
@Override
public boolean containsValue(Object value) {
if ( value == null ) {
@@ -1025,30 +1025,30 @@ public abstract class AbstractReplicated
return false;
}//end if
}
-
+
@Override
public Object clone() {
throw new UnsupportedOperationException("This operation is not valid on a replicated map");
}
-
+
/**
* Returns the entire contents of the map
- * Map.Entry.getValue() will return a LazyReplicatedMap.MapEntry object containing all the information
+ * Map.Entry.getValue() will return a LazyReplicatedMap.MapEntry object containing all the information
* about the object.
* @return Set
*/
public Set entrySetFull() {
return super.entrySet();
}
-
+
public Set keySetFull() {
return super.keySet();
}
-
+
public int sizeFull() {
return super.size();
}
-
+
@Override
public Set<MapEntry> entrySet() {
LinkedHashSet<MapEntry> set = new LinkedHashSet<MapEntry>(super.size());
@@ -1063,7 +1063,7 @@ public abstract class AbstractReplicated
}
return Collections.unmodifiableSet(set);
}
-
+
@Override
public Set<Object> keySet() {
//todo implement
@@ -1079,8 +1079,8 @@ public abstract class AbstractReplicated
return Collections.unmodifiableSet(set);
}
-
-
+
+
@Override
public int size() {
//todo, implement a counter variable instead
@@ -1096,12 +1096,12 @@ public abstract class AbstractReplicated
}
return counter;
}
-
+
@Override
public boolean isEmpty() {
return size()==0;
}
-
+
@Override
public Collection<Object> values() {
ArrayList<Object> values = new ArrayList<Object>();
@@ -1113,7 +1113,7 @@ public abstract class AbstractReplicated
}
return Collections.unmodifiableCollection(values);
}
-
+
//------------------------------------------------------------------------------
// Map Entry class
@@ -1129,21 +1129,21 @@ public abstract class AbstractReplicated
public MapEntry(Object key, Object value) {
setKey(key);
setValue(value);
-
+
}
-
+
public boolean isKeySerializable() {
return (key == null) || (key instanceof Serializable);
}
-
+
public boolean isValueSerializable() {
return (value==null) || (value instanceof Serializable);
}
-
+
public boolean isSerializable() {
return isKeySerializable() && isValueSerializable();
}
-
+
public boolean isBackup() {
return backup;
}
@@ -1163,7 +1163,7 @@ public abstract class AbstractReplicated
public boolean isActive() {
return !proxy;
}
-
+
public void setProxy(boolean proxy) {
this.proxy = proxy;
}
@@ -1180,11 +1180,11 @@ public abstract class AbstractReplicated
public Member[] getBackupNodes() {
return backupNodes;
}
-
+
public void setPrimary(Member m) {
primary = m;
}
-
+
public Member getPrimary() {
return primary;
}
@@ -1205,7 +1205,7 @@ public abstract class AbstractReplicated
public Object getKey() {
return key;
}
-
+
public Object setKey(Object key) {
Object old = this.key;
this.key = key;
@@ -1247,7 +1247,7 @@ public abstract class AbstractReplicated
value = XByteBuffer.deserialize(data, offset, length);
}
}
-
+
@Override
public String toString() {
StringBuilder buf = new StringBuilder("MapEntry[key:");
@@ -1288,7 +1288,7 @@ public abstract class AbstractReplicated
private byte[] diffvalue;
private Member[] nodes;
private Member primary;
-
+
@Override
public String toString() {
StringBuilder buf = new StringBuilder("MapMessage[context=");
@@ -1301,7 +1301,7 @@ public abstract class AbstractReplicated
buf.append(value);
return buf.toString();
}
-
+
public String getTypeDesc() {
switch (msgtype) {
case MSG_BACKUP: return "MSG_BACKUP";
@@ -1334,7 +1334,7 @@ public abstract class AbstractReplicated
setValue(value);
setKey(key);
}
-
+
public void deserialize(ClassLoader[] cls) throws IOException, ClassNotFoundException {
key(cls);
value(cls);
@@ -1364,11 +1364,11 @@ public abstract class AbstractReplicated
keydata = null;
return key;
}
-
+
public byte[] getKeyData() {
return keydata;
}
-
+
public Serializable getValue() {
try {
return value(null);
@@ -1385,7 +1385,7 @@ public abstract class AbstractReplicated
valuedata = null;
return value;
}
-
+
public byte[] getValueData() {
return valuedata;
}
@@ -1401,7 +1401,7 @@ public abstract class AbstractReplicated
public Member getPrimary() {
return primary;
}
-
+
private void setPrimary(Member m) {
primary = m;
}
@@ -1418,7 +1418,7 @@ public abstract class AbstractReplicated
throw new RuntimeException(x);
}
}
-
+
public void setKey(Serializable key) {
try {
if (key != null) keydata = XByteBuffer.serialize(key);
@@ -1427,7 +1427,7 @@ public abstract class AbstractReplicated
throw new RuntimeException(x);
}
}
-
+
protected Member[] readMembers(ObjectInput in) throws IOException {
int nodecount = in.readInt();
Member[] members = new Member[nodecount];
@@ -1438,7 +1438,7 @@ public abstract class AbstractReplicated
}
return members;
}
-
+
protected void writeMembers(ObjectOutput out,Member[] members) throws IOException {
if ( members == null ) members = new Member[0];
out.writeInt(members.length);
@@ -1450,8 +1450,8 @@ public abstract class AbstractReplicated
}
}
}
-
-
+
+
/**
* shallow clone
* @return Object
Modified: tomcat/trunk/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java Sat Oct 22 21:09:52 2011
@@ -27,7 +27,7 @@ import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
/**
- * A smart implementation of a stateful replicated map. uses primary/secondary backup strategy.
+ * A smart implementation of a stateful replicated map. uses primary/secondary backup strategy.
* One node is always the primary and one node is always the backup.
* This map is synchronized across a cluster, and only has one backup member.<br/>
* A perfect usage for this map would be a session map for a session manager in a clustered environment.<br/>
@@ -39,25 +39,25 @@ import org.apache.juli.logging.LogFactor
* These two methods are very important two understand. The map can work with two set of value objects:<br>
* 1. Serializable - the entire object gets serialized each time it is replicated<br>
* 2. ReplicatedMapEntry - this interface allows for a isDirty() flag and to replicate diffs if desired.<br>
- * Implementing the <code>ReplicatedMapEntry</code> interface allows you to decide what objects
+ * Implementing the <code>ReplicatedMapEntry</code> interface allows you to decide what objects
* get replicated and how much data gets replicated each time.<br>
* If you implement a smart AOP mechanism to detect changes in underlying objects, you can replicate
* only those changes by implementing the ReplicatedMapEntry interface, and return true when isDiffable()
* is invoked.<br><br>
- *
+ *
* This map implementation doesn't have a background thread running to replicate changes.
* If you do have changes without invoking put/remove then you need to invoke one of the following methods:
* <ul>
* <li><code>replicate(Object,boolean)</code> - replicates only the object that belongs to the key</li>
* <li><code>replicate(boolean)</code> - Scans the entire map for changes and replicates data</li>
* </ul>
- * the <code>boolean</code> value in the <code>replicate</code> method used to decide
+ * the <code>boolean</code> value in the <code>replicate</code> method used to decide
* whether to only replicate objects that implement the <code>ReplicatedMapEntry</code> interface
* or to replicate all objects. If an object doesn't implement the <code>ReplicatedMapEntry</code> interface
* each time the object gets replicated the entire object gets serialized, hence a call to <code>replicate(true)</code>
* will replicate all objects in this map that are using this node as primary.
- *
- * <br><br><b>REMBER TO CALL <code>breakdown()</code> or <code>finalize()</code> when you are done with the map to
+ *
+ * <br><br><b>REMBER TO CALL <code>breakdown()</code> or <code>finalize()</code> when you are done with the map to
* avoid memory leaks.<br><br>
* TODO implement periodic sync/transfer thread
* @author Filip Hanik
@@ -68,9 +68,9 @@ public class LazyReplicatedMap extends A
private static final Log log = LogFactory.getLog(LazyReplicatedMap.class);
-//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
// CONSTRUCTORS / DESTRUCTORS
-//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
/**
* Creates a new map
* @param channel The channel to use for communication
@@ -105,8 +105,8 @@ public class LazyReplicatedMap extends A
}
-//------------------------------------------------------------------------------
-// METHODS TO OVERRIDE
+//------------------------------------------------------------------------------
+// METHODS TO OVERRIDE
//------------------------------------------------------------------------------
@Override
protected int getStateMessageType() {
@@ -127,19 +127,19 @@ public class LazyReplicatedMap extends A
int firstIdx = getNextBackupIndex();
int nextIdx = firstIdx;
Member[] backup = new Member[0];
-
+
//there are no backups
if ( members.length == 0 || firstIdx == -1 ) return backup;
-
+
boolean success = false;
do {
//select a backup node
Member next = members[nextIdx];
-
+
//increment for the next round of back up selection
nextIdx = nextIdx + 1;
if ( nextIdx >= members.length ) nextIdx = 0;
-
+
if (next == null) {
continue;
}
@@ -149,7 +149,7 @@ public class LazyReplicatedMap extends A
//publish the backup data to one node
msg = new MapMessage(getMapContextName(), MapMessage.MSG_BACKUP, false,
(Serializable) key, (Serializable) value, null, channel.getLocalMember(false), backup);
- if ( log.isTraceEnabled() )
+ if ( log.isTraceEnabled() )
log.trace("Publishing backup data:"+msg+" to: "+next.getName());
UniqueId id = getChannel().send(backup, msg, getChannelSendOptions());
if ( log.isTraceEnabled() )
@@ -165,7 +165,7 @@ public class LazyReplicatedMap extends A
if (success && proxies.length > 0 ) {
msg = new MapMessage(getMapContextName(), MapMessage.MSG_PROXY, false,
(Serializable) key, null, null, channel.getLocalMember(false),backup);
- if ( log.isTraceEnabled() )
+ if ( log.isTraceEnabled() )
log.trace("Publishing proxy data:"+msg+" to: "+Arrays.toNameString(proxies));
getChannel().send(proxies, msg, getChannelSendOptions());
}
Modified: tomcat/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java Sat Oct 22 21:09:52 2011
@@ -23,7 +23,7 @@ import org.apache.catalina.tribes.Channe
import org.apache.catalina.tribes.Member;
/**
- * All-to-all replication for a hash map implementation. Each node in the cluster will carry an identical
+ * All-to-all replication for a hash map implementation. Each node in the cluster will carry an identical
* copy of the map.<br><br>
* This map implementation doesn't have a background thread running to replicate changes.
* If you do have changes without invoking put/remove then you need to invoke one of the following methods:
@@ -42,7 +42,7 @@ import org.apache.catalina.tribes.Member
* TODO implement periodic sync/transfer thread
* @author Filip Hanik
* @version 1.0
- *
+ *
* TODO memberDisappeared, should do nothing except change map membership
* by default it relocates the primary objects
*/
@@ -93,7 +93,7 @@ public class ReplicatedMap extends Abstr
protected int getStateMessageType() {
return AbstractReplicatedMap.MapMessage.MSG_STATE_COPY;
}
-
+
/**
* publish info about a map pair (key/value) to other nodes in the cluster
* @param key Object
Modified: tomcat/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMapEntry.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMapEntry.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMapEntry.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMapEntry.java Sat Oct 22 21:09:52 2011
@@ -20,7 +20,7 @@ import java.io.IOException;
import java.io.Serializable;
/**
- *
+ *
* For smarter replication, an object can implement this interface to replicate diffs<br>
* The replication logic will call the methods in the following order:<br>
* <code>
@@ -42,35 +42,35 @@ import java.io.Serializable;
* 2. if ( isBackup(entry)||isPrimary(entry) ) entry.setOwner(owner); <br>
* </code>
* <br>
- *
- *
+ *
+ *
* @author Filip Hanik
* @version 1.0
*/
public interface ReplicatedMapEntry extends Serializable {
-
+
/**
* Has the object changed since last replication
* and is not in a locked state
* @return boolean
*/
public boolean isDirty();
-
+
/**
* If this returns true, the map will extract the diff using getDiff()
* Otherwise it will serialize the entire object.
* @return boolean
*/
public boolean isDiffable();
-
+
/**
* Returns a diff and sets the dirty map to false
* @return byte[]
* @throws IOException
*/
public byte[] getDiff() throws IOException;
-
-
+
+
/**
* Applies a diff to an existing object.
* @param diff byte[]
@@ -79,31 +79,31 @@ public interface ReplicatedMapEntry exte
* @throws IOException
*/
public void applyDiff(byte[] diff, int offset, int length) throws IOException, ClassNotFoundException;
-
+
/**
* Resets the current diff state and resets the dirty flag
*/
public void resetDiff();
-
+
/**
* Lock during serialization
*/
public void lock();
-
+
/**
* Unlock after serialization
*/
public void unlock();
-
+
/**
- * This method is called after the object has been
+ * This method is called after the object has been
* created on a remote map. On this method,
- * the object can initialize itself for any data that wasn't
- *
+ * the object can initialize itself for any data that wasn't
+ *
* @param owner Object
*/
public void setOwner(Object owner);
-
+
/**
* For accuracy checking, a serialized attribute can contain a version number
* This number increases as modifications are made to the data.
@@ -111,7 +111,7 @@ public interface ReplicatedMapEntry exte
* @return long - the version number or -1 if the data is not versioned
*/
public long getVersion();
-
+
/**
* Forces a certain version to a replicated map entry<br>
* @param version long
Modified: tomcat/trunk/java/org/apache/catalina/tribes/tipis/Streamable.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/tipis/Streamable.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/tipis/Streamable.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/tipis/Streamable.java Sat Oct 22 21:09:52 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -33,13 +33,13 @@ import java.io.IOException;
* @version 1.0
*/
public interface Streamable {
-
+
/**
* returns true if the stream has reached its end
* @return boolean
*/
public boolean eof();
-
+
/**
* write data into the byte array starting at offset, maximum bytes read are (data.length-offset)
* @param data byte[] - the array to read data into
@@ -47,7 +47,7 @@ public interface Streamable {
* @return int - the number of bytes written into the data buffer
*/
public int write(byte[] data, int offset, int length) throws IOException;
-
+
/**
* read data into the byte array starting at offset
* @param data byte[] - the array to read data into
@@ -57,5 +57,5 @@ public interface Streamable {
*/
public int read(byte[] data, int offset, int length) throws IOException;
-
+
}
\ No newline at end of file
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/AbstractRxTask.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/AbstractRxTask.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/AbstractRxTask.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/AbstractRxTask.java Sat Oct 22 21:09:52 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,10 +25,10 @@ import org.apache.catalina.tribes.io.Lis
* @version $Id$
*/
public abstract class AbstractRxTask implements Runnable
-{
-
+{
+
public static final int OPTION_DIRECT_BUFFER = ReceiverBase.OPTION_DIRECT_BUFFER;
-
+
private ListenCallback callback;
private RxTaskPool pool;
private boolean doRun = true;
@@ -76,11 +76,11 @@ public abstract class AbstractRxTask imp
doRun = false;
notify();
}
-
+
public void setUseBufferPool(boolean usebufpool) {
useBufferPool = usebufpool;
}
-
+
public boolean getUseBufferPool() {
return useBufferPool;
}
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/Constants.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/Constants.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/Constants.java Sat Oct 22 21:09:52 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,7 +31,7 @@ import org.apache.catalina.tribes.io.XBy
public class Constants {
public static final String Package = "org.apache.catalina.tribes.transport";
-
+
/*
* Do not change any of these values!
*/
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/DataSender.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/DataSender.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/DataSender.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/DataSender.java Sat Oct 22 21:09:52 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,6 +40,6 @@ public interface DataSender {
public void setKeepAliveTime(long keepAliveTimeInMs);
public int getRequestCount();
public long getConnectTime();
-
-
+
+
}
\ No newline at end of file
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/LocalStrings.properties?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/LocalStrings.properties Sat Oct 22 21:09:52 2011
@@ -36,4 +36,4 @@ IDataSender.senderModes.Instantiate=Can'
IDataSender.senderModes.Missing=Can't configure a data replication sender for mode {0}
IDataSender.senderModes.Resources=Can't load data replication sender mapping list
IDataSender.stats=Send stats from [{0}:{1,number,integer}], Nr of bytes sent={2,number,integer} over {3} = {4,number,integer} bytes/request, processing time {5,number,integer} msec, avg processing time {6,number,integer} msec
-PooledSender.senderDisconnectFail=Failed to disconnect sender
+PooledSender.senderDisconnectFail=Failed to disconnect sender
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/MultiPointSender.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/MultiPointSender.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/MultiPointSender.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/MultiPointSender.java Sat Oct 22 21:09:52 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/PooledSender.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/PooledSender.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/PooledSender.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/PooledSender.java Sat Oct 22 21:09:52 2011
@@ -35,42 +35,42 @@ import org.apache.juli.logging.LogFactor
* @version 1.0
*/
public abstract class PooledSender extends AbstractSender implements MultiPointSender {
-
+
private static final Log log = LogFactory.getLog(PooledSender.class);
protected static final StringManager sm =
StringManager.getManager(Constants.Package);
-
+
private SenderQueue queue = null;
private int poolSize = 25;
public PooledSender() {
queue = new SenderQueue(this,poolSize);
}
-
+
public abstract DataSender getNewDataSender();
-
+
public DataSender getSender() {
return queue.getSender(getTimeout());
}
-
+
public void returnSender(DataSender sender) {
sender.keepalive();
queue.returnSender(sender);
}
-
+
@Override
public synchronized void connect() throws IOException {
//do nothing, happens in the socket sender itself
queue.open();
setConnected(true);
}
-
+
@Override
public synchronized void disconnect() {
queue.close();
setConnected(false);
}
-
-
+
+
public int getInPoolSize() {
return queue.getInPoolSize();
}
@@ -152,7 +152,7 @@ public abstract class PooledSender exten
public int getInPoolSize() {
return notinuse.size();
}
-
+
public synchronized boolean checkIdleKeepAlive() {
DataSender[] list = new DataSender[notinuse.size()];
notinuse.toArray(list);
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java Sat Oct 22 21:09:52 2011
@@ -84,7 +84,7 @@ public abstract class ReceiverBase imple
private boolean useBufferPool = true;
private boolean daemon = true;
private long maxIdleTime = 60000;
-
+
private ExecutorService executor;
@@ -604,6 +604,6 @@ public abstract class ReceiverBase imple
public void setMaxIdleTime(long maxIdleTime) {
this.maxIdleTime = maxIdleTime;
- }
-
+ }
+
}
\ No newline at end of file
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/ReplicationTransmitter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/ReplicationTransmitter.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/ReplicationTransmitter.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/ReplicationTransmitter.java Sat Oct 22 21:09:52 2011
@@ -27,8 +27,8 @@ import org.apache.catalina.tribes.util.S
/**
* Transmit message to other cluster members
* Actual senders are created based on the replicationMode
- * type
- *
+ * type
+ *
* @author Filip Hanik
* @version $Id$
*/
@@ -52,9 +52,9 @@ public class ReplicationTransmitter impl
public void setTransport(MultiPointSender transport) {
this.transport = transport;
}
-
+
// ------------------------------------------------------------- public
-
+
/**
* Send data to one member
* @see org.apache.catalina.tribes.ChannelSender#sendMessage(org.apache.catalina.tribes.ChannelMessage, org.apache.catalina.tribes.Member[])
@@ -64,11 +64,11 @@ public class ReplicationTransmitter impl
MultiPointSender sender = getTransport();
sender.sendMessage(destination,message);
}
-
-
+
+
/**
* start the sender and register transmitter mbean
- *
+ *
* @see org.apache.catalina.tribes.ChannelSender#start()
*/
@Override
@@ -78,7 +78,7 @@ public class ReplicationTransmitter impl
/**
* stop the sender and deregister mbeans (transmitter, senders)
- *
+ *
* @see org.apache.catalina.tribes.ChannelSender#stop()
*/
@Override
@@ -88,7 +88,7 @@ public class ReplicationTransmitter impl
/**
* Call transmitter to check for sender socket status
- *
+ *
* @see org.apache.catalina.ha.tcp.SimpleTcpCluster#backgroundProcess()
*/
@Override
@@ -99,7 +99,7 @@ public class ReplicationTransmitter impl
/**
* add new cluster member and create sender ( s. replicationMode) transfer
* current properties to sender
- *
+ *
* @see org.apache.catalina.tribes.ChannelSender#add(org.apache.catalina.tribes.Member)
*/
@Override
@@ -109,7 +109,7 @@ public class ReplicationTransmitter impl
/**
* remove sender from transmitter. ( deregister mbean and disconnect sender )
- *
+ *
* @see org.apache.catalina.tribes.ChannelSender#remove(org.apache.catalina.tribes.Member)
*/
@Override
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/RxTaskPool.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/RxTaskPool.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/RxTaskPool.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/RxTaskPool.java Sat Oct 22 21:09:52 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -35,23 +35,23 @@ public class RxTaskPool
List<AbstractRxTask> idle = new LinkedList<AbstractRxTask>();
List<AbstractRxTask> used = new LinkedList<AbstractRxTask>();
-
+
Object mutex = new Object();
boolean running = true;
-
+
private int maxTasks;
private int minTasks;
-
+
private TaskCreator creator = null;
-
+
public RxTaskPool (int maxTasks, int minTasks, TaskCreator creator) throws Exception {
// fill up the pool with worker threads
this.maxTasks = maxTasks;
this.minTasks = minTasks;
this.creator = creator;
}
-
+
protected void configureTask(AbstractRxTask task) {
synchronized (task) {
task.setTaskPool(this);
@@ -92,7 +92,7 @@ public class RxTaskPool
}
return (worker);
}
-
+
public int available() {
return idle.size();
}
@@ -150,7 +150,7 @@ public class RxTaskPool
public TaskCreator getTaskCreator() {
return this.creator;
}
-
+
public static interface TaskCreator {
public AbstractRxTask createRxTask();
}
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/SenderState.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/SenderState.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/SenderState.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/SenderState.java Sat Oct 22 21:09:52 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,20 +23,20 @@ import org.apache.catalina.tribes.Member
/**
- *
+ *
* @author Filip Hanik
* @version 1.0
* @since 5.5.16
*/
public class SenderState {
-
+
public static final int READY = 0;
public static final int SUSPECT = 1;
- public static final int FAILING = 2;
-
+ public static final int FAILING = 2;
+
protected static HashMap<Member, SenderState> memberStates = new HashMap<Member, SenderState>();
-
+
public static SenderState getSenderState(Member member) {
return getSenderState(member,true);
}
@@ -54,13 +54,13 @@ public class SenderState {
}
return state;
}
-
+
public static void removeSenderState(Member member) {
synchronized ( memberStates ) {
memberStates.remove(member);
}
}
-
+
// ----------------------------------------------------- Instance Variables
@@ -68,7 +68,7 @@ public class SenderState {
// ----------------------------------------------------- Constructor
-
+
private SenderState() {
this(READY);
}
@@ -76,9 +76,9 @@ public class SenderState {
private SenderState(int state) {
this.state = state;
}
-
+
/**
- *
+ *
* @return boolean
*/
public boolean isSuspect() {
@@ -88,23 +88,23 @@ public class SenderState {
public void setSuspect() {
state = SUSPECT;
}
-
+
public boolean isReady() {
return state == READY;
}
-
+
public void setReady() {
state = READY;
}
-
+
public boolean isFailing() {
return state == FAILING;
}
-
+
public void setFailing() {
state = FAILING;
}
-
+
// ----------------------------------------------------- Public Properties
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/BioReceiver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/BioReceiver.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/BioReceiver.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/BioReceiver.java Sat Oct 22 21:09:52 2011
@@ -64,12 +64,12 @@ public class BioReceiver extends Receive
else throw new IOException(x.getMessage());
}
}
-
+
@Override
public AbstractRxTask createRxTask() {
return getReplicationThread();
}
-
+
protected BioReplicationTask getReplicationThread() {
BioReplicationTask result = new BioReplicationTask(this);
result.setOptions(getWorkerThreadOptions());
@@ -108,7 +108,7 @@ public class BioReceiver extends Receive
log.error("Unable to run replication listener.", x);
}
}
-
+
public void listen() throws Exception {
if (doListen()) {
log.warn("ServerSocket already started");
@@ -150,6 +150,6 @@ public class BioReceiver extends Receive
getExecutor().execute(task);
}//while
}
-
+
}
\ No newline at end of file
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/BioReplicationTask.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/BioReplicationTask.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/BioReplicationTask.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/BioReplicationTask.java Sat Oct 22 21:09:52 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,19 +40,19 @@ import org.apache.juli.logging.LogFactor
* serviceChannel() method stores the key reference in the thread object then
* calls notify() to wake it up. When the channel has been drained, the worker
* thread returns itself to its parent pool.
- *
+ *
* @author Filip Hanik
- *
+ *
* @version $Id$
*/
public class BioReplicationTask extends AbstractRxTask {
private static final Log log = LogFactory.getLog( BioReplicationTask.class );
-
+
protected Socket socket;
protected ObjectReader reader;
-
+
public BioReplicationTask (ListenCallback callback) {
super(callback);
}
@@ -88,12 +88,12 @@ public class BioReplicationTask extends
if ( getTaskPool() != null ) getTaskPool().returnWorker (this);
}
-
+
public synchronized void serviceSocket(Socket socket, ObjectReader reader) {
this.socket = socket;
this.reader = reader;
}
-
+
protected void execute(ObjectReader reader) throws Exception{
int pkgcnt = reader.count();
@@ -101,7 +101,7 @@ public class BioReplicationTask extends
ChannelMessage[] msgs = reader.execute();
for ( int i=0; i<msgs.length; i++ ) {
/**
- * Use send ack here if you want to ack the request to the remote
+ * Use send ack here if you want to ack the request to the remote
* server before completing the request
* This is considered an asynchronized request
*/
@@ -123,10 +123,10 @@ public class BioReplicationTask extends
BufferPool.getBufferPool().returnBuffer(msgs[i].getMessage());
msgs[i].setMessage(null);
}
- }
+ }
}
-
+
}
/**
@@ -166,7 +166,7 @@ public class BioReplicationTask extends
log.warn("Unable to send ACK back through channel, channel disconnected?: "+x.getMessage());
}
}
-
+
@Override
public void close() {
setDoRun(false);
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/BioSender.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/BioSender.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/BioSender.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/BioSender.java Sat Oct 22 21:09:52 2011
@@ -34,7 +34,7 @@ import org.apache.catalina.tribes.util.S
/**
* Send cluster messages with only one socket. Ack and keep Alive Handling is
* supported
- *
+ *
* @author Peter Rossbach
* @author Filip Hanik
* @version $Id$
@@ -57,12 +57,12 @@ public class BioSender extends AbstractS
private Socket socket = null;
private OutputStream soOut = null;
private InputStream soIn = null;
-
+
protected XByteBuffer ackbuf = new XByteBuffer(Constants.ACK_COMMAND.length,true);
// ------------------------------------------------------------- Constructor
-
+
public BioSender() {
// NO-OP
}
@@ -71,7 +71,7 @@ public class BioSender extends AbstractS
// --------------------------------------------------------- Public Methods
/**
- * Connect other cluster member receiver
+ * Connect other cluster member receiver
* @see org.apache.catalina.tribes.transport.DataSender#connect()
*/
@Override
@@ -79,10 +79,10 @@ public class BioSender extends AbstractS
openSocket();
}
-
+
/**
* disconnect and close socket
- *
+ *
* @see org.apache.catalina.tribes.transport.DataSender#disconnect()
*/
@Override
@@ -93,7 +93,7 @@ public class BioSender extends AbstractS
if (log.isDebugEnabled())
log.debug(sm.getString("IDataSender.disconnect", getAddress().getHostAddress(), new Integer(getPort()), new Long(0)));
}
-
+
}
/**
@@ -127,7 +127,7 @@ public class BioSender extends AbstractS
}
}
-
+
/**
* Name of this SockerSender
*/
@@ -140,7 +140,7 @@ public class BioSender extends AbstractS
}
// --------------------------------------------------------- Protected Methods
-
+
/**
* open real socket and set time out when waitForAck is enabled
* is socket open return directly
@@ -173,12 +173,12 @@ public class BioSender extends AbstractS
log.debug(sm.getString("IDataSender.openSocket.failure",getAddress().getHostAddress(), new Integer(getPort()),new Long(0)), ex1);
throw (ex1);
}
-
+
}
/**
* Close socket.
- *
+ *
* @see #disconnect()
*/
protected void closeSocket() {
@@ -205,20 +205,20 @@ public class BioSender extends AbstractS
* Push messages with only one socket at a time
* Wait for ack is needed and make auto retry when write message is failed.
* After sending error close and reopen socket again.
- *
+ *
* After successful sending update stats
- *
+ *
* WARNING: Subclasses must be very careful that only one thread call this pushMessage at once!!!
- *
+ *
* @see #closeSocket()
* @see #openSocket()
* @see #sendMessage(byte[], boolean)
- *
+ *
* @param data
* data to send
* @since 5.5.10
*/
-
+
protected void pushMessage(byte[] data, boolean reconnect, boolean waitForAck) throws IOException {
keepalive();
if ( reconnect ) closeSocket();
@@ -229,7 +229,7 @@ public class BioSender extends AbstractS
SenderState.getSenderState(getDestination()).setReady();
}
-
+
/**
* Wait for Acknowledgement from other server.
* FIXME Please, not wait only for three characters, better control that the wait ack message is correct.
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/MultipointBioSender.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/MultipointBioSender.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/MultipointBioSender.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/MultipointBioSender.java Sat Oct 22 21:09:52 2011
@@ -40,8 +40,8 @@ public class MultipointBioSender extends
public MultipointBioSender() {
// NO-OP
}
-
- protected long selectTimeout = 1000;
+
+ protected long selectTimeout = 1000;
protected HashMap<Member, BioSender> bioSenders =
new HashMap<Member, BioSender>();
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/PooledMultiSender.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/PooledMultiSender.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/PooledMultiSender.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/PooledMultiSender.java Sat Oct 22 21:09:52 2011
@@ -35,12 +35,12 @@ import org.apache.catalina.tribes.transp
* @version 1.0
*/
public class PooledMultiSender extends PooledSender {
-
+
public PooledMultiSender() {
// NO-OP
}
-
+
@Override
public void sendMessage(Member[] destination, ChannelMessage msg) throws ChannelException {
MultiPointSender sender = null;
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/util/FastQueue.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/util/FastQueue.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/util/FastQueue.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/util/FastQueue.java Sat Oct 22 21:09:52 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,7 +26,7 @@ import org.apache.catalina.tribes.group.
/**
* A fast queue that remover thread lock the adder thread. <br/>Limit the queue
* length when you have strange producer thread problems.
- *
+ *
* FIXME add i18n support to log messages
* @author Rainer Jung
* @author Peter Rossbach
@@ -61,7 +61,7 @@ public class FastQueue {
*/
private boolean checkLock = false;
-
+
private boolean inAdd = false;
private boolean inRemove = false;
@@ -78,7 +78,7 @@ public class FastQueue {
*/
private long addWaitTimeout = 10000L;
-
+
/**
* removeWaitTimeout for consumer
*/
@@ -106,7 +106,7 @@ public class FastQueue {
/**
* get current add wait timeout
- *
+ *
* @return current wait timeout
*/
public long getAddWaitTimeout() {
@@ -116,7 +116,7 @@ public class FastQueue {
/**
* Set add wait timeout (default 10000 msec)
- *
+ *
* @param timeout
*/
public void setAddWaitTimeout(long timeout) {
@@ -126,7 +126,7 @@ public class FastQueue {
/**
* get current remove wait timeout
- *
+ *
* @return The timeout
*/
public long getRemoveWaitTimeout() {
@@ -136,7 +136,7 @@ public class FastQueue {
/**
* set remove wait timeout ( default 30000 msec)
- *
+ *
* @param timeout
*/
public void setRemoveWaitTimeout(long timeout) {
@@ -178,7 +178,7 @@ public class FastQueue {
this.checkLock = checkLock;
}
-
+
/**
* @return The max size
*/
@@ -193,16 +193,16 @@ public class FastQueue {
maxSize = size;
}
-
+
/**
- * unlock queue for next add
+ * unlock queue for next add
*/
public void unlockAdd() {
lock.unlockAdd(size > 0 ? true : false);
}
/**
- * unlock queue for next remove
+ * unlock queue for next remove
*/
public void unlockRemove() {
lock.unlockRemove();
@@ -232,7 +232,7 @@ public class FastQueue {
/**
* Add new data to the queue.
- *
+ *
* FIXME extract some method
*/
public boolean add(ChannelMessage msg, Member[] destination, InterceptorPayload payload) {
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/util/LinkObject.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/util/LinkObject.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/util/LinkObject.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/util/LinkObject.java Sat Oct 22 21:09:52 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -73,7 +73,7 @@ public class LinkObject {
public LinkObject next() {
return next;
}
-
+
public void setNext(LinkObject next) {
this.next = next;
}
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/util/SingleRemoveSynchronizedAddLock.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/util/SingleRemoveSynchronizedAddLock.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/util/SingleRemoveSynchronizedAddLock.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/util/SingleRemoveSynchronizedAddLock.java Sat Oct 22 21:09:52 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,7 +31,7 @@ package org.apache.catalina.tribes.trans
* but the queue is empty, it will block (poll)
* until an add threads adds an entry to the queue and
* releases the lock.
- *
+ *
* If the remove thread and add threads compete for
* the lock and an add thread releases the lock, then
* the remove thread will get the lock first.
@@ -48,17 +48,17 @@ package org.apache.catalina.tribes.trans
* @author Peter Rossbach
* @version 1.1
*/
-
+
public class SingleRemoveSynchronizedAddLock {
-
+
public SingleRemoveSynchronizedAddLock() {
// NO-OP
}
-
+
public SingleRemoveSynchronizedAddLock(boolean dataAvailable) {
this.dataAvailable=dataAvailable;
}
-
+
/**
* Time in milliseconds after which threads
* waiting for an add lock are woken up.
@@ -213,7 +213,7 @@ public class SingleRemoveSynchronizedAdd
}
if ( removeEnabled ) {
removeLocked=true;
- }
+ }
return removeLocked;
}
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/nio/NioSender.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/nio/NioSender.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/nio/NioSender.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/nio/NioSender.java Sat Oct 22 21:09:52 2011
@@ -236,7 +236,7 @@ public class NioSender extends AbstractS
dataChannel.connect(daddr);
completeConnect();
dataChannel.register(getSelector(),SelectionKey.OP_WRITE, this);
-
+
} else {
InetSocketAddress addr = new InetSocketAddress(getAddress(),getPort());
if ( socketChannel != null ) throw new IOException("Socket channel has already been established. Connection might be in progress.");
@@ -341,7 +341,7 @@ public class NioSender extends AbstractS
if ( writebuf != null ) writebuf.clear();
else writebuf = getBuffer(length);
if ( writebuf.capacity() < length ) writebuf = getBuffer(length);
-
+
//TODO use ByteBuffer.wrap to avoid copying the data.
writebuf.put(data,offset,length);
//writebuf.rewind();
Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java Sat Oct 22 21:09:52 2011
@@ -73,7 +73,7 @@ public class PooledParallelSender extend
throw new RuntimeException("Unable to open NIO selector.",x);
}
}
-
+
@Override
public synchronized void disconnect() {
this.connected = false;
@@ -85,5 +85,5 @@ public class PooledParallelSender extend
this.connected = true;
super.connect();
}
-
+
}
\ No newline at end of file
Modified: tomcat/trunk/java/org/apache/catalina/tribes/util/Arrays.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/util/Arrays.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/util/Arrays.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/util/Arrays.java Sat Oct 22 21:09:52 2011
@@ -35,7 +35,7 @@ import org.apache.catalina.tribes.member
public class Arrays {
private static final Charset CHARSET_ISO_8859_1 =
Charset.forName("ISO-8859-1");
-
+
public static boolean contains(byte[] source, int srcoffset, byte[] key, int keyoffset, int length) {
if ( srcoffset < 0 || srcoffset >= source.length) throw new ArrayIndexOutOfBoundsException("srcoffset is out of bounds.");
if ( keyoffset < 0 || keyoffset >= key.length) throw new ArrayIndexOutOfBoundsException("keyoffset is out of bounds.");
@@ -49,7 +49,7 @@ public class Arrays {
}
return match;
}
-
+
public static String toString(byte[] data) {
return toString(data,0,data!=null?data.length:0);
}
@@ -81,7 +81,7 @@ public class Arrays {
public static String toString(Object[] data) {
return toString(data,0,data!=null?data.length:0);
}
-
+
public static String toString(Object[] data, int offset, int length) {
StringBuilder buf = new StringBuilder("{");
if ( data != null && length > 0 ) {
@@ -93,11 +93,11 @@ public class Arrays {
buf.append("}");
return buf.toString();
}
-
+
public static String toNameString(Member[] data) {
return toNameString(data,0,data!=null?data.length:0);
}
-
+
public static String toNameString(Member[] data, int offset, int length) {
StringBuilder buf = new StringBuilder("{");
if ( data != null && length > 0 ) {
@@ -115,7 +115,7 @@ public class Arrays {
for (int i=0;i<data.length; i++ ) result += data[i];
return result;
}
-
+
public static UniqueId getUniqudId(ChannelMessage msg) {
return new UniqueId(msg.getUniqueId());
}
@@ -123,7 +123,7 @@ public class Arrays {
public static UniqueId getUniqudId(byte[] data) {
return new UniqueId(data);
}
-
+
public static boolean equals(byte[] o1, byte[] o2) {
return java.util.Arrays.equals(o1,o2);
}
@@ -133,13 +133,13 @@ public class Arrays {
if ( result ) for (int i=0; i<o1.length && result; i++ ) result = o1[i].equals(o2[i]);
return result;
}
-
+
public static boolean sameMembers(Member[] m1, Member[] m2) {
AbsoluteOrder.absoluteOrder(m1);
AbsoluteOrder.absoluteOrder(m2);
return equals(m1,m2);
}
-
+
public static Member[] merge(Member[] m1, Member[] m2) {
AbsoluteOrder.absoluteOrder(m1);
AbsoluteOrder.absoluteOrder(m2);
@@ -151,11 +151,11 @@ public class Arrays {
AbsoluteOrder.absoluteOrder(result);
return result;
}
-
+
public static void fill(Membership mbrship, Member[] m) {
for (int i=0; i<m.length; i++ ) mbrship.addMember((MemberImpl)m[i]);
}
-
+
public static Member[] diff(Membership complete, Membership local, MemberImpl ignore) {
ArrayList<Member> result = new ArrayList<Member>();
MemberImpl[] comp = complete.getMembers();
@@ -165,35 +165,35 @@ public class Arrays {
}
return result.toArray(new MemberImpl[result.size()]);
}
-
+
public static Member[] remove(Member[] all, Member remove) {
return extract(all,new Member[] {remove});
}
-
+
public static Member[] extract(Member[] all, Member[] remove) {
List<Member> alist = java.util.Arrays.asList(all);
ArrayList<Member> list = new ArrayList<Member>(alist);
for (int i=0; i<remove.length; i++ ) list.remove(remove[i]);
return list.toArray(new Member[list.size()]);
}
-
+
public static int indexOf(Member member, Member[] members) {
int result = -1;
- for (int i=0; (result==-1) && (i<members.length); i++ )
+ for (int i=0; (result==-1) && (i<members.length); i++ )
if ( member.equals(members[i]) ) result = i;
return result;
}
-
+
public static int nextIndex(Member member, Member[] members) {
int idx = indexOf(member,members)+1;
if (idx >= members.length ) idx = ((members.length>0)?0:-1);
-
+
//System.out.println("Next index:"+idx);
//System.out.println("Member:"+member.getName());
//System.out.println("Members:"+toNameString(members));
return idx;
}
-
+
public static int hashCode(byte a[]) {
if (a == null)
return 0;
@@ -205,8 +205,8 @@ public class Arrays {
}
return result;
}
-
- public static byte[] fromString(String value) {
+
+ public static byte[] fromString(String value) {
if ( value == null ) return null;
if ( !value.startsWith("{") ) throw new RuntimeException("byte arrays must be represented as {1,3,4,5,6}");
StringTokenizer t = new StringTokenizer(value,"{,}",false);
Modified: tomcat/trunk/java/org/apache/catalina/tribes/util/ExecutorFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/util/ExecutorFactory.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/util/ExecutorFactory.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/util/ExecutorFactory.java Sat Oct 22 21:09:52 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -38,7 +38,7 @@ public class ExecutorFactory {
taskqueue.setParent(service);
return service;
}
-
+
// ---------------------------------------------- TaskQueue Inner Class
private static class TaskQueue extends LinkedBlockingQueue<Runnable> {
private static final long serialVersionUID = 1L;
@@ -52,7 +52,7 @@ public class ExecutorFactory {
public void setParent(ThreadPoolExecutor tp) {
parent = tp;
}
-
+
@Override
public boolean offer(Runnable o) {
//we can't do any checks
Modified: tomcat/trunk/java/org/apache/catalina/tribes/util/Logs.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/util/Logs.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/util/Logs.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/util/Logs.java Sat Oct 22 21:09:52 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,7 +19,7 @@ package org.apache.catalina.tribes.util;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
/**
- *
+ *
* Simple class that holds references to global loggers
* @author Filip Hanik
* @version 1.0
Modified: tomcat/trunk/java/org/apache/catalina/tribes/util/StringManager.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/util/StringManager.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/util/StringManager.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/util/StringManager.java Sat Oct 22 21:09:52 2011
@@ -93,11 +93,11 @@ public class StringManager {
/**
Get a string from the underlying resource bundle or return
null if the String is not found.
-
+
@param key to desired resource String
@return resource String matching <i>key</i> from underlying
bundle or null if not found.
- @throws IllegalArgumentException if <i>key</i> is null.
+ @throws IllegalArgumentException if <i>key</i> is null.
*/
public String getString(String key) {
if(key == null){
Modified: tomcat/trunk/java/org/apache/catalina/tribes/util/TcclThreadFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/util/TcclThreadFactory.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/util/TcclThreadFactory.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/util/TcclThreadFactory.java Sat Oct 22 21:09:52 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,15 +29,15 @@ import java.util.concurrent.atomic.Atomi
* session replication.
*/
public class TcclThreadFactory implements ThreadFactory {
-
+
private static final AtomicInteger poolNumber = new AtomicInteger(1);
private static final boolean IS_SECURITY_ENABLED =
(System.getSecurityManager() != null);
-
+
private final ThreadGroup group;
private final AtomicInteger threadNumber = new AtomicInteger(1);
private final String namePrefix;
-
+
public TcclThreadFactory() {
SecurityManager s = System.getSecurityManager();
group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
@@ -48,7 +48,7 @@ public class TcclThreadFactory implement
public Thread newThread(Runnable r) {
final Thread t = new Thread(group, r, namePrefix +
threadNumber.getAndIncrement());
-
+
if (IS_SECURITY_ENABLED) {
AccessController.doPrivileged(new PrivilegedAction<Void>() {
@Override
Modified: tomcat/trunk/java/org/apache/catalina/tribes/util/UUIDGenerator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/util/UUIDGenerator.java?rev=1187789&r1=1187788&r2=1187789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/util/UUIDGenerator.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/util/UUIDGenerator.java Sat Oct 22 21:09:52 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,7 +23,7 @@ import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
/**
- * simple generation of a UUID
+ * simple generation of a UUID
* @author Filip Hanik
* @version 1.0
*/
@@ -36,10 +36,10 @@ public class UUIDGenerator {
public static final int UUID_VERSION = 4;
public static final int BYTES_PER_INT = 4;
public static final int BITS_PER_BYTE = 8;
-
+
protected static SecureRandom secrand = null;
protected static Random rand = new Random();
-
+
static {
long start = System.currentTimeMillis();
secrand = new SecureRandom();
@@ -51,7 +51,7 @@ public class UUIDGenerator {
secrand.getAlgorithm(), Long.valueOf(time)));
}
}
-
+
public static byte[] randomUUID(boolean secure) {
byte[] result = new byte[UUID_LENGTH];
return randomUUID(secure,result,0);
@@ -68,7 +68,7 @@ public class UUIDGenerator {
into[8+offset] |= 0x80; //1000 0000
return into;
}
-
+
/**
* Same as java.util.Random.nextBytes except this one we dont have to allocate a new byte array
* @param into byte[]
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org