Java Doc for LazyReplicatedMap.java in  » Sevlet-Container » apache-tomcat-6.0.14 » org » apache » catalina » tribes » tipis » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Sevlet Container » apache tomcat 6.0.14 » org.apache.catalina.tribes.tipis 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.catalina.tribes.tipis.AbstractReplicatedMap
   org.apache.catalina.tribes.tipis.LazyReplicatedMap

LazyReplicatedMap
public class LazyReplicatedMap extends AbstractReplicatedMap implements RpcCallback,ChannelListener,MembershipListener(Code)
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.
A perfect usage for this map would be a session map for a session manager in a clustered environment.
The only way to modify this list is to use the put, putAll, remove methods. entrySet, entrySetFull, keySet, keySetFull, returns all non modifiable sets.

If objects (values) in the map change without invoking put() or remove() the data can be distributed using two different methods:
replicate(boolean) and replicate(Object, boolean)
These two methods are very important two understand. The map can work with two set of value objects:
1. Serializable - the entire object gets serialized each time it is replicated
2. ReplicatedMapEntry - this interface allows for a isDirty() flag and to replicate diffs if desired.
Implementing the ReplicatedMapEntry interface allows you to decide what objects get replicated and how much data gets replicated each time.
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.

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:
  • replicate(Object,boolean) - replicates only the object that belongs to the key
  • replicate(boolean) - Scans the entire map for changes and replicates data
the boolean value in the replicate method used to decide whether to only replicate objects that implement the ReplicatedMapEntry interface or to replicate all objects. If an object doesn't implement the ReplicatedMapEntry interface each time the object gets replicated the entire object gets serialized, hence a call to replicate(true) will replicate all objects in this map that are using this node as primary.

REMBER TO CALL breakdown() or finalize() when you are done with the map to avoid memory leaks.


author:
   Filip Hanik
version:
   1.0


Field Summary
protected static  org.apache.juli.logging.Loglog
    

Constructor Summary
public  LazyReplicatedMap(Object owner, Channel channel, long timeout, String mapContextName, int initialCapacity, float loadFactor, ClassLoader[] cls)
    
public  LazyReplicatedMap(Object owner, Channel channel, long timeout, String mapContextName, int initialCapacity, ClassLoader[] cls)
    
public  LazyReplicatedMap(Object owner, Channel channel, long timeout, String mapContextName, ClassLoader[] cls)
    

Method Summary
protected  intgetStateMessageType()
    
protected  Member[]publishEntryInfo(Object key, Object value)
    

Field Detail
log
protected static org.apache.juli.logging.Log log(Code)




Constructor Detail
LazyReplicatedMap
public LazyReplicatedMap(Object owner, Channel channel, long timeout, String mapContextName, int initialCapacity, float loadFactor, ClassLoader[] cls)(Code)
Creates a new map
Parameters:
  channel - The channel to use for communication
Parameters:
  timeout - long - timeout for RPC messags
Parameters:
  mapContextName - String - unique name for this map, to allow multiple maps per channel
Parameters:
  initialCapacity - int - the size of this map, see HashMap
Parameters:
  loadFactor - float - load factor, see HashMap



LazyReplicatedMap
public LazyReplicatedMap(Object owner, Channel channel, long timeout, String mapContextName, int initialCapacity, ClassLoader[] cls)(Code)
Creates a new map
Parameters:
  channel - The channel to use for communication
Parameters:
  timeout - long - timeout for RPC messags
Parameters:
  mapContextName - String - unique name for this map, to allow multiple maps per channel
Parameters:
  initialCapacity - int - the size of this map, see HashMap



LazyReplicatedMap
public LazyReplicatedMap(Object owner, Channel channel, long timeout, String mapContextName, ClassLoader[] cls)(Code)
Creates a new map
Parameters:
  channel - The channel to use for communication
Parameters:
  timeout - long - timeout for RPC messags
Parameters:
  mapContextName - String - unique name for this map, to allow multiple maps per channel




Method Detail
getStateMessageType
protected int getStateMessageType()(Code)



publishEntryInfo
protected Member[] publishEntryInfo(Object key, Object value) throws ChannelException(Code)
publish info about a map pair (key/value) to other nodes in the cluster
Parameters:
  key - Object
Parameters:
  value - Object Member - the backup node
throws:
  ChannelException -



Fields inherited from org.apache.catalina.tribes.tipis.AbstractReplicatedMap
final public static int DEFAULT_INITIAL_CAPACITY(Code)(Java Doc)
final public static float DEFAULT_LOAD_FACTOR(Code)(Java Doc)
protected transient long accessTimeout(Code)(Java Doc)
protected transient Channel channel(Code)(Java Doc)
protected transient int channelSendOptions(Code)(Java Doc)
final String chset(Code)(Java Doc)
protected transient int currentNode(Code)(Java Doc)
protected transient ClassLoader[] externalLoaders(Code)(Java Doc)
protected static Log log(Code)(Java Doc)
protected transient byte[] mapContextName(Code)(Java Doc)
protected transient HashMap mapMembers(Code)(Java Doc)
protected transient Object mapOwner(Code)(Java Doc)
protected transient String mapname(Code)(Java Doc)
protected transient RpcChannel rpcChannel(Code)(Java Doc)
protected transient long rpcTimeout(Code)(Java Doc)
protected transient Object stateMutex(Code)(Java Doc)
protected transient boolean stateTransferred(Code)(Java Doc)

Methods inherited from org.apache.catalina.tribes.tipis.AbstractReplicatedMap
public boolean accept(Serializable msg, Member sender)(Code)(Java Doc)
public void breakdown()(Code)(Java Doc)
protected void broadcast(int msgtype, boolean rpc) throws ChannelException(Code)(Java Doc)
public void clear()(Code)(Java Doc)
public void clear(boolean notify)(Code)(Java Doc)
public Object clone()(Code)(Java Doc)
public boolean containsKey(Object key)(Code)(Java Doc)
public boolean containsValue(Object value)(Code)(Java Doc)
public Set entrySet()(Code)(Java Doc)
public Set entrySetFull()(Code)(Java Doc)
public boolean equals(Object o)(Code)(Java Doc)
public Member[] excludeFromSet(Member[] mbrs, Member[] set)(Code)(Java Doc)
public void finalize()(Code)(Java Doc)
public Object get(Object key)(Code)(Java Doc)
public long getAccessTimeout()(Code)(Java Doc)
public Channel getChannel()(Code)(Java Doc)
public int getChannelSendOptions()(Code)(Java Doc)
public ClassLoader[] getExternalLoaders()(Code)(Java Doc)
public MapEntry getInternal(Object key)(Code)(Java Doc)
public byte[] getMapContextName()(Code)(Java Doc)
public Member[] getMapMembers(HashMap members)(Code)(Java Doc)
public Member[] getMapMembers()(Code)(Java Doc)
public Member[] getMapMembersExcl(Member[] exclude)(Code)(Java Doc)
public Object getMapOwner()(Code)(Java Doc)
public int getNextBackupIndex()(Code)(Java Doc)
public Member getNextBackupNode()(Code)(Java Doc)
public RpcChannel getRpcChannel()(Code)(Java Doc)
public long getRpcTimeout()(Code)(Java Doc)
abstract protected int getStateMessageType()(Code)(Java Doc)
public Object getStateMutex()(Code)(Java Doc)
public int hashCode()(Code)(Java Doc)
public void heartbeat()(Code)(Java Doc)
public boolean inSet(Member m, Member[] set)(Code)(Java Doc)
protected void init(Object owner, Channel channel, String mapContextName, long timeout, int channelSendOptions, ClassLoader[] cls)(Code)(Java Doc)
public boolean isEmpty()(Code)(Java Doc)
public boolean isStateTransferred()(Code)(Java Doc)
public Set keySet()(Code)(Java Doc)
public Set keySetFull()(Code)(Java Doc)
public void leftOver(Serializable msg, Member sender)(Code)(Java Doc)
public void mapMemberAdded(Member member)(Code)(Java Doc)
public void memberAdded(Member member)(Code)(Java Doc)
protected void memberAlive(Member member)(Code)(Java Doc)
public void memberDisappeared(Member member)(Code)(Java Doc)
public void messageReceived(Serializable msg, Member sender)(Code)(Java Doc)
protected void ping(long timeout) throws ChannelException(Code)(Java Doc)
protected void printMap(String header)(Code)(Java Doc)
abstract protected Member[] publishEntryInfo(Object key, Object value) throws ChannelException(Code)(Java Doc)
public Object put(Object key, Object value)(Code)(Java Doc)
public Object put(Object key, Object value, boolean notify)(Code)(Java Doc)
public void putAll(Map m)(Code)(Java Doc)
public Object remove(Object key)(Code)(Java Doc)
public Object remove(Object key, boolean notify)(Code)(Java Doc)
protected boolean removeEldestEntry(Map.Entry eldest)(Code)(Java Doc)
public void replicate(Object key, boolean complete)(Code)(Java Doc)
public void replicate(boolean complete)(Code)(Java Doc)
public Serializable replyRequest(Serializable msg, Member sender)(Code)(Java Doc)
public void setAccessTimeout(long accessTimeout)(Code)(Java Doc)
public void setChannelSendOptions(int channelSendOptions)(Code)(Java Doc)
public void setExternalLoaders(ClassLoader[] externalLoaders)(Code)(Java Doc)
public void setMapOwner(Object mapOwner)(Code)(Java Doc)
public int size()(Code)(Java Doc)
public int sizeFull()(Code)(Java Doc)
public void transferState()(Code)(Java Doc)
public Collection values()(Code)(Java Doc)
protected Member[] wrap(Member m)(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.