Java Doc for DistributedCachePeer.java in  » Groupware » hipergate » com » knowgate » cache » 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 » Groupware » hipergate » com.knowgate.cache 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.knowgate.cache.DistributedCachePeer

DistributedCachePeer
final public class DistributedCachePeer (Code)

Distributed Cache Local Peer

Each distributed cache peer holds its own local copy of cached data.

On the simplest scenenario there is only one client cache peer witch stores data localy for faster access and reduce network bandwitch consumption.

As data is kept localy at each peer, when more than one client peer concurrently access the same data, a cache coordinator becomes necessary.

The cache coordinator is an EJB that must be installed at an application server such as JBoss or BEA Weblogic. See cache.DistributedCacheCoordinatorBean for more information about the cache coordinator.


Distributed Cache Tokens and Policies

A cache peer is essentially a named set of objects. Each object name is called a "cache token". Cache Token associate a String (the object name) with the actual cached object.

Token have an usage count and a last usage date, each time a token is requested its usage count and last usage dates are updated at the cache peer.

The cache peer the applies a customizable Policy for discarding objects as cache becomes full.

Currently only a Least Recently Used Cache Policy is provided.

By default the cache has a maximum of 400 objects slots.

There is no checking of memory consumption for the cache peer, it is the programmer's responsability not to cache objects that are too large.

It is also the programmer's task to remove tokens from the cache peer when the cached data has been changed.

Comunnication between client cache peers and the cache coordinator

The cache coordinator is a single object instance that coordinates data cached by multiple cache peers, at a given time a cache peer may change data that is already cache at another peer. When doing so the last usage date for the token of cached data will be updated and the cache coordinator will be notified of this last usage change.

Each cache peer holds its own copy of data, and the cache coordinator keeps a record of all last usage timestamp for every object at every cache peer. In this way, cached data is not be shared among peers, but it is kept synchronized by discarding all tokens witch timestamp at the peer is older than the one at the cache coordinator.

UML


author:
   Sergio Montoro Ten
version:
   1.1
version:
  



Constructor Summary
public  DistributedCachePeer()
    

Create a local cache peer.

The cache peer may be initialized to work in single-peer mode or in multi-peer mode with a cache coordinator.

Initializacion properties for connecting with the cache coordinator when working in multi-peer mode are passed in appserver.cnf properties file.


Method Summary
public  voidexpire(String sTokenKey)
     Removes an Object from the cache and notify other cache peers that the objects with the given token should no longer be considered valid.

If Object with given token was not present at cache no error is raised.
public  voidexpireAll()
    
public  Objectget(String sTokenKey)
     Get an object from the cache peer.
public  BooleangetBoolean(String sTokenKey)
    
public  DBSubsetgetDBSubset(String sTokenKey)
    
public  StringgetString(String sTokenKey)
    
public  java.util.SetkeySet()
    
public  voidput(String sTokenKey, Object oObj)
    
public  voidputDBSubset(String sTableName, String sTokenKey, DBSubset oDBSS)
    
public  intsize()
    


Constructor Detail
DistributedCachePeer
public DistributedCachePeer() throws InstantiationException, RemoteException(Code)

Create a local cache peer.

The cache peer may be initialized to work in single-peer mode or in multi-peer mode with a cache coordinator.

Initializacion properties for connecting with the cache coordinator when working in multi-peer mode are passed in appserver.cnf properties file. The appserver.cnf file is read using the singleton Environment object at com.knowgate.misc package.

An example of a configuration file for JBoss may be as follows:

#DistributedCachePeer JBoss configuration file

#set this entry to "disabled" is working in single-peer mode
threetiers=enabled

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://127.1.0.0:1099/
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
jnp.socketFactory=org.jnp.interfaces.TimedSocketFactory

An example of a configuration file for Tomcat may be as follows:

#DistributedCachePeer Tomcat configuration file

#set this entry to "disabled" is working in single-peer mode
threetiers=enabled

java.naming.factory.initial=
java.naming.provider.url=http://www.remotehost.com:1099/cache/server.jsp
java.naming.factory.url.pkgs=
jnp.socketFactory=

throws:
  InstantiationException -
throws:
  RemoteException -
See Also:   Environment




Method Detail
expire
public void expire(String sTokenKey) throws IllegalArgumentException, RemoteException(Code)
Removes an Object from the cache and notify other cache peers that the objects with the given token should no longer be considered valid.

If Object with given token was not present at cache no error is raised.
Parameters:
  sTokenKey - Token of object to be removed from local cache.
throws:
  RemoteException -
throws:
  IllegalArgumentException - If sTkeney is null.
throws:
  IllegalStateException - If local cache is empty.



expireAll
public void expireAll() throws RemoteException(Code)

Remove all objects from local cache and expire then and cache coordinator.


throws:
  RemoteException -



get
public Object get(String sTokenKey) throws RemoteException, NullPointerException(Code)
Get an object from the cache peer.
Parameters:
  sTokenKey - Token of object to be retrieved Reference to the requested object or null if object is not present at the local cache or it was modified by another cache peer.
throws:
  RemoteException -



getBoolean
public Boolean getBoolean(String sTokenKey) throws RemoteException, ClassCastException(Code)

Parameters:
  sTokenKey - Token of object to be retrieved
throws:
  ClassCastException -



getDBSubset
public DBSubset getDBSubset(String sTokenKey) throws RemoteException, ClassCastException(Code)
Same as DistributedCachePeer.get() but cast returned object to a DBSubset.
throws:
  ClassCastException -



getString
public String getString(String sTokenKey) throws RemoteException, ClassCastException(Code)

Parameters:
  sTokenKey - Token of object to be retrieved Same as DistributedCachePeer.get() but cast returned object to a String.
throws:
  ClassCastException -



keySet
public java.util.Set keySet()(Code)
Return keys for entries in cache Set of keys (Strings)



put
public void put(String sTokenKey, Object oObj) throws IllegalStateException, IllegalArgumentException, RemoteException(Code)

Puts an Object into local cache.


Parameters:
  sTokenKey - Token for object
Parameters:
  oObj - Object to be stored.
throws:
  RemoteException -
throws:
  IllegalArgumentException - If either sTokenKey or oObj is null.
throws:
  IllegalStateException - If object with given token is already present at local cache.



putDBSubset
public void putDBSubset(String sTableName, String sTokenKey, DBSubset oDBSS) throws RemoteException(Code)

Puts a DBSubset into local cache.


Parameters:
  sTokenKey - Token for object
Parameters:
  oObj - Object to be stored.
throws:
  RemoteException -
throws:
  IllegalArgumentException - If either sTokenKey or oObj is null.
throws:
  IllegalStateException - If object with given token is already present at local cache.



size
public int size()(Code)

Number of entries in cache




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(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.