KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > TreeCacheMBean


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.cache;
8
9 /**
10  * MBean interface.
11  * @author Bela Ban
12  * @author Ben Wang
13  */

14 public interface TreeCacheMBean extends org.jboss.system.ServiceMBean
15 {
16
17    java.lang.Object JavaDoc getLocalAddress();
18
19    java.util.Vector JavaDoc getMembers();
20
21    boolean isCoordinator();
22
23    /**
24     * Get the name of the replication group
25     */

26    java.lang.String JavaDoc getClusterName();
27
28    /**
29     * Set the name of the replication group
30     */

31    void setClusterName(java.lang.String JavaDoc name);
32
33    /**
34     * Get the cluster properties (e.g. the protocol stack specification in case of JGroups)
35     */

36    java.lang.String JavaDoc getClusterProperties();
37
38    /**
39     * Set the cluster properties. If the cache is to use the new properties, it has to be redeployed
40     * @param cluster_props The properties for the cluster (JGroups)
41     */

42    void setClusterProperties(java.lang.String JavaDoc cluster_props);
43
44    /**
45     * Dumps the contents of the TransactionTable
46     * @return
47     */

48    java.lang.String JavaDoc dumpTransactionTable();
49
50    boolean getDeadlockDetection();
51
52    void setDeadlockDetection(boolean dt);
53
54    java.lang.String JavaDoc getInterceptorChain();
55
56    java.util.List JavaDoc getInterceptors();
57
58    java.lang.String JavaDoc getCacheLoaderClass();
59
60    void setCacheLoaderClass(java.lang.String JavaDoc cache_loader_class);
61
62    java.util.Properties JavaDoc getCacheLoaderConfig();
63
64    void setCacheLoaderConfig(java.util.Properties JavaDoc cache_loader_config);
65
66    org.jboss.cache.loader.CacheLoader getCacheLoader();
67
68    void setCacheLoader(org.jboss.cache.loader.CacheLoader cache_loader);
69
70    boolean getCacheLoaderShared();
71
72    void setCacheLoaderShared(boolean shared);
73
74    void setCacheLoaderPreload(java.lang.String JavaDoc list);
75
76    java.lang.String JavaDoc getCacheLoaderPreload();
77
78    void setCacheLoaderFetchPersistentState(boolean flag);
79
80    boolean getCacheLoaderFetchPersistentState();
81
82    void setCacheLoaderFetchTransientState(boolean flag);
83
84    boolean getCacheLoaderFetchTransientState();
85
86    boolean getSyncCommitPhase();
87
88    void setSyncCommitPhase(boolean sync_commit_phase);
89
90    boolean getSyncRollbackPhase();
91
92    void setSyncRollbackPhase(boolean sync_rollback_phase);
93
94    /**
95     * Setup eviction policy configuration
96     */

97    void setEvictionPolicyConfig(org.w3c.dom.Element JavaDoc config);
98
99    /**
100     * Convert a list of elements to the JG property string
101     */

102    void setClusterConfig(org.w3c.dom.Element JavaDoc config);
103
104    /**
105     * Get the max time to wait until the initial state is retrieved. This is used in a replicating cache: when a new cache joins the cluster, it needs to acquire the (replicated) state of the other members to initialize itself. If no state has been received within <tt>timeout</tt> milliseconds, the map will be empty.
106     * @return long Number of milliseconds to wait for the state. 0 means to wait forever.
107     */

108    long getInitialStateRetrievalTimeout();
109
110    /**
111     * Set the initial state transfer timeout (see {@link #getInitialStateRetrievalTimeout()})
112     */

113    void setInitialStateRetrievalTimeout(long timeout);
114
115    /**
116     * Returns the current caching mode. Valid values are <ul> <li>LOCAL <li>REPL_ASYNC <li>REPL_SYNC <ul>
117     * @return String The caching mode
118     */

119    java.lang.String JavaDoc getCacheMode();
120
121    /**
122     * Sets the default caching mode)
123     */

124    void setCacheMode(java.lang.String JavaDoc mode) throws java.lang.Exception JavaDoc;
125
126    /**
127     * Returns the default max timeout after which synchronous replication calls return.
128     * @return long Number of milliseconds after which a sync repl call must return. 0 means to wait forever
129     */

130    long getSyncReplTimeout();
131
132    /**
133     * Sets the default maximum wait time for synchronous replication to receive all results
134     */

135    void setSyncReplTimeout(long timeout);
136
137    boolean getUseReplQueue();
138
139    void setUseReplQueue(boolean flag);
140
141    long getReplQueueInterval();
142
143    void setReplQueueInterval(long interval);
144
145    int getReplQueueMaxElements();
146
147    void setReplQueueMaxElements(int max_elements);
148
149    /**
150     * Returns the transaction isolation level.
151     */

152    java.lang.String JavaDoc getIsolationLevel();
153
154    /**
155     * Set the transaction isolation level. This determines the locking strategy to be used
156     */

157    void setIsolationLevel(java.lang.String JavaDoc level);
158
159    boolean getFetchStateOnStartup();
160
161    void setFetchStateOnStartup(boolean flag);
162
163    /**
164     * Default max time to wait for a lock. If the lock cannot be acquired within this time, a LockingException will be thrown.
165     * @return long Max number of milliseconds to wait for a lock to be acquired
166     */

167    long getLockAcquisitionTimeout();
168
169    /**
170     * Set the max time for lock acquisition. A value of 0 means to wait forever (not recomended). Note that lock acquisition timeouts may be removed in the future when we have deadlock detection.
171     * @param timeout
172     */

173    void setLockAcquisitionTimeout(long timeout);
174
175    /**
176     * Returns the name of the cache eviction policy (must be an implementation of EvictionPolicy)
177     * @return Fully qualified name of a class implementing the EvictionPolicy interface
178     */

179    java.lang.String JavaDoc getEvictionPolicyClass();
180
181    /**
182     * Sets the classname of the eviction policy
183     */

184    void setEvictionPolicyClass(java.lang.String JavaDoc eviction_policy_class);
185
186    /**
187     * Obtain eviction thread (if any) wake up interval in seconds
188     */

189    int getEvictionThreadWakeupIntervalSeconds();
190
191    /**
192     * Sets the TransactionManagerLookup object
193     * @param l
194     */

195    void setTransactionManagerLookup(org.jboss.cache.TransactionManagerLookup l);
196
197    java.lang.String JavaDoc getTransactionManagerLookupClass();
198
199    /**
200     * Sets the class of the TransactionManagerLookup impl. This will attempt to create an instance, and will throw an exception if this fails.
201     * @param cl
202     * @throws Exception
203     */

204    void setTransactionManagerLookupClass(java.lang.String JavaDoc cl) throws java.lang.Exception JavaDoc;
205
206    javax.transaction.TransactionManager JavaDoc getTransactionManager();
207
208    org.jboss.cache.TreeCache getInstance();
209
210    /**
211     * Fetch the group state from the current coordinator. If successful, this will trigger setState().
212     */

213    void fetchState(long timeout) throws org.jgroups.ChannelClosedException, org.jgroups.ChannelNotConnectedException;
214
215    void addTreeCacheListener(org.jboss.cache.TreeCacheListener listener);
216
217    void removeTreeCacheListener(org.jboss.cache.TreeCacheListener listener);
218
219    void createService() throws java.lang.Exception JavaDoc;
220
221    void destroyService();
222
223    void startService() throws java.lang.Exception JavaDoc;
224
225    /**
226     * Loads the indicated Fqn, plus all parents recursively from the CacheLoader. If no CacheLoader is present, this is a no-op
227     * @param fqn
228     * @throws Exception
229     */

230    void load(java.lang.String JavaDoc fqn) throws java.lang.Exception JavaDoc;
231
232    void stopService();
233
234    java.util.Set JavaDoc getKeys(java.lang.String JavaDoc fqn) throws org.jboss.cache.CacheException;
235
236    java.util.Set JavaDoc getKeys(org.jboss.cache.Fqn fqn) throws org.jboss.cache.CacheException;
237
238    /**
239     * Finds a node given its name and returns the value associated with a given key in its <code>data</code> map. Returns null if the node was not found in the tree or the key was not found in the hashmap.
240     * @param fqn The fully qualified name of the node.
241     * @param key The key.
242     */

243    java.lang.Object JavaDoc get(java.lang.String JavaDoc fqn, java.lang.Object JavaDoc key) throws org.jboss.cache.CacheException;
244
245    /**
246     * Finds a node given its name and returns the value associated with a given key in its <code>data</code> map. Returns null if the node was not found in the tree or the key was not found in the hashmap.
247     * @param fqn The fully qualified name of the node.
248     * @param key The key.
249     */

250    java.lang.Object JavaDoc get(org.jboss.cache.Fqn fqn, java.lang.Object JavaDoc key) throws org.jboss.cache.CacheException;
251
252    /**
253     * Checks whether a given node exists in the tree
254     * @param fqn The fully qualified name of the node
255     * @return boolean Whether or not the node exists
256     */

257    boolean exists(java.lang.String JavaDoc fqn);
258
259    /**
260     * Checks whether a given node exists in the tree. Does not acquire any locks in doing so (result may be dirty read)
261     * @param fqn The fully qualified name of the node
262     * @return boolean Whether or not the node exists
263     */

264    boolean exists(org.jboss.cache.Fqn fqn);
265
266    boolean exists(java.lang.String JavaDoc fqn, java.lang.Object JavaDoc key);
267
268    /**
269     * Checks whether a given key exists in the given node. Does not interact with CacheLoader, so the behavior is different from {@link #get(Fqn,Object)}
270     * @param fqn The fully qualified name of the node
271     * @param key
272     * @return boolean Whether or not the node exists
273     */

274    boolean exists(org.jboss.cache.Fqn fqn, java.lang.Object JavaDoc key);
275
276    /**
277     * Adds a new node to the tree and sets its data. If the node doesn not yet exist, it will be created. Also, parent nodes will be created if not existent. If the node already has data, then the new data will override the old one. If the node already existed, a nodeModified() notification will be generated. Otherwise a nodeCreated() motification will be emitted.
278     * @param fqn The fully qualified name of the new node
279     * @param data The new data. May be null if no data should be set in the node.
280     */

281    void put(java.lang.String JavaDoc fqn, java.util.Map JavaDoc data) throws org.jboss.cache.CacheException;
282
283    /**
284     * Adds a new node to the tree and sets its data. If the node doesn not yet exist, it will be created. Also, parent nodes will be created if not existent. If the node already has data, then the new data will override the old one. If the node already existed, a nodeModified() notification will be generated. Otherwise a nodeCreated() motification will be emitted.
285     * @param fqn The fully qualified name of the new node
286     * @param data The new data. May be null if no data should be set in the node.
287     */

288    void put(org.jboss.cache.Fqn fqn, java.util.Map JavaDoc data) throws org.jboss.cache.CacheException;
289
290    /**
291     * Adds a key and value to a given node. If the node doesn't exist, it will be created. If the node already existed, a nodeModified() notification will be generated. Otherwise a nodeCreated() motification will be emitted.
292     * @param fqn The fully qualified name of the node
293     * @param key The key
294     * @param value The value
295     * @return Object The previous value (if any), if node was present
296     */

297    java.lang.Object JavaDoc put(java.lang.String JavaDoc fqn, java.lang.Object JavaDoc key, java.lang.Object JavaDoc value)
298          throws org.jboss.cache.CacheException;
299
300    /**
301     * Adds a key and value to a given node. If the node doesn't exist, it will be created. If the node already existed, a nodeModified() notification will be generated. Otherwise a nodeCreated() motification will be emitted.
302     * @param fqn The fully qualified name of the node
303     * @param key The key
304     * @param value The value
305     * @return Object The previous value (if any), if node was present
306     */

307    java.lang.Object JavaDoc put(org.jboss.cache.Fqn fqn, java.lang.Object JavaDoc key, java.lang.Object JavaDoc value)
308          throws org.jboss.cache.CacheException;
309
310    /**
311     * Removes the node from the tree.
312     * @param fqn The fully qualified name of the node.
313     */

314    void remove(java.lang.String JavaDoc fqn) throws org.jboss.cache.CacheException;
315
316    /**
317     * Removes the node from the tree.
318     * @param fqn The fully qualified name of the node.
319     */

320    void remove(org.jboss.cache.Fqn fqn) throws org.jboss.cache.CacheException;
321
322    /**
323     * Called by eviction policy provider. Note that eviction is done only in local mode, that is, it doesn't replicate the node removal. This is will cause the replcation nodes not synchronizing, but it is ok since user is supposed to add the node again when get is null. After that, the contents will be in sync.
324     * @param fqn Will remove everythign assoicated with this fqn.
325     * @throws CacheException
326     */

327    void evict(org.jboss.cache.Fqn fqn) throws org.jboss.cache.CacheException;
328
329    /**
330     * Removes <code>key</code> from the node's hashmap
331     * @param fqn The fullly qualified name of the node
332     * @param key The key to be removed
333     * @return The previous value, or null if none was associated with the given key
334     */

335    java.lang.Object JavaDoc remove(java.lang.String JavaDoc fqn, java.lang.Object JavaDoc key) throws org.jboss.cache.CacheException;
336
337    /**
338     * Removes <code>key</code> from the node's hashmap
339     * @param fqn The fullly qualified name of the node
340     * @param key The key to be removed
341     * @return The previous value, or null if none was associated with the given key
342     */

343    java.lang.Object JavaDoc remove(org.jboss.cache.Fqn fqn, java.lang.Object JavaDoc key) throws org.jboss.cache.CacheException;
344
345    void removeData(java.lang.String JavaDoc fqn) throws org.jboss.cache.CacheException;
346
347    void removeData(org.jboss.cache.Fqn fqn) throws org.jboss.cache.CacheException;
348
349    /**
350     * Force-releases all locks in this node and the entire subtree
351     * @param fqn
352     */

353    void releaseAllLocks(java.lang.String JavaDoc fqn);
354
355    /**
356     * Force-releases all locks in this node and the entire subtree
357     * @param fqn
358     */

359    void releaseAllLocks(org.jboss.cache.Fqn fqn);
360
361    /**
362     * Prints a representation of the node defined by <code>fqn</code>. Output includes name, fqn and data.
363     */

364    java.lang.String JavaDoc print(java.lang.String JavaDoc fqn);
365
366    /**
367     * Prints a representation of the node defined by <code>fqn</code>. Output includes name, fqn and data.
368     */

369    java.lang.String JavaDoc print(org.jboss.cache.Fqn fqn);
370
371    /**
372     * Returns all children of a given node
373     * @param fqn The fully qualified name of the node
374     * @return Set A list of child names (as Strings)
375     */

376    java.util.Set JavaDoc getChildrenNames(java.lang.String JavaDoc fqn) throws org.jboss.cache.CacheException;
377
378    /**
379     * Returns all children of a given node
380     * @param fqn The fully qualified name of the node
381     * @return Set A list of child names (as Objects). Must <em>not</em> be modified because this would modify the underlying node directly (will throw an exception if modification is attempted). Returns null of the parent node was not found, or if there are no children
382     */

383    java.util.Set JavaDoc getChildrenNames(org.jboss.cache.Fqn fqn) throws org.jboss.cache.CacheException;
384
385    java.lang.String JavaDoc toString();
386
387    java.lang.String JavaDoc toString(boolean details);
388
389    java.lang.String JavaDoc printDetails();
390
391    java.lang.String JavaDoc printLockInfo();
392
393    /**
394     * Gets the number of read or write locks held across the entire tree
395     * @return
396     */

397    int getNumberOfLocksHeld();
398
399    /**
400     * Returns an <em>approximation</em> of the total number of nodes in the tree. Since this method doesn't acquire any locks, the number might be incorrect, or the method might even throw a ConcurrentModificationException
401     * @return
402     */

403    int getNumberOfNodes();
404
405    /**
406     * Returns an <em>approximation</em> of the total number of attributes in the tree. Since this method doesn't acquire any locks, the number might be incorrect, or the method might even throw a ConcurrentModificationException
407     * @return
408     */

409    int getNumberOfAttributes();
410
411    java.util.List JavaDoc callRemoteMethods(java.util.Vector JavaDoc members, java.lang.reflect.Method JavaDoc method, java.lang.Object JavaDoc[] args,
412          boolean synchronous, boolean exclude_self, long timeout) throws java.lang.Exception JavaDoc;
413
414    java.util.List JavaDoc callRemoteMethods(java.util.Vector JavaDoc members, java.lang.String JavaDoc method_name, java.lang.Class JavaDoc[] types,
415          java.lang.Object JavaDoc[] args, boolean synchronous, boolean exclude_self, long timeout) throws java.lang.Exception JavaDoc;
416
417    /**
418     * Does the real work. Needs to acquire locks if accessing nodes, depending on the value of <tt>locking</tt>. If run inside a transaction, needs to (a) add newly acquired locks to {@link TransactionEntry}'s lock list, (b) add nodes that were created to {@link TransactionEntry}'s node list and (c) create {@link Modification}s and add them to {@link TransactionEntry}'s modification list and (d) create compensating modifications to undo the changes in case of a rollback
419     * @param fqn
420     * @param data
421     * @param create_undo_ops If true, undo operations will be created (default is true). Otherwise they will not be created (used by rollback()).
422     */

423    void _put(org.jboss.cache.GlobalTransaction tx, java.lang.String JavaDoc fqn, java.util.Map JavaDoc data, boolean create_undo_ops)
424          throws org.jboss.cache.CacheException;
425
426    /**
427     * Does the real work. Needs to acquire locks if accessing nodes, depending on the value of <tt>locking</tt>. If run inside a transaction, needs to (a) add newly acquired locks to {@link TransactionEntry}'s lock list, (b) add nodes that were created to {@link TransactionEntry}'s node list and (c) create {@link Modification}s and add them to {@link TransactionEntry}'s modification list and (d) create compensating modifications to undo the changes in case of a rollback
428     * @param fqn
429     * @param data
430     * @param create_undo_ops If true, undo operations will be created (default is true). Otherwise they will not be created (used by rollback()).
431     */

432    void _put(org.jboss.cache.GlobalTransaction tx, org.jboss.cache.Fqn fqn, java.util.Map JavaDoc data, boolean create_undo_ops)
433          throws org.jboss.cache.CacheException;
434
435    /**
436     * Does the real work. Needs to acquire locks if accessing nodes, depending on the value of <tt>locking</tt>. If run inside a transaction, needs to (a) add newly acquired locks to {@link TransactionEntry}'s lock list, (b) add nodes that were created to {@link TransactionEntry}'s node list and (c) create {@link Modification}s and add them to {@link TransactionEntry}'s modification list and (d) create compensating modifications to undo the changes in case of a rollback
437     * @param fqn
438     * @param data
439     * @param create_undo_ops If true, undo operations will be created (default is true).
440     * @param erase_contents Clear the existing hashmap before putting the new data into it Otherwise they will not be created (used by rollback()).
441     */

442    void _put(org.jboss.cache.GlobalTransaction tx, org.jboss.cache.Fqn fqn, java.util.Map JavaDoc data,
443          boolean create_undo_ops, boolean erase_contents) throws org.jboss.cache.CacheException;
444
445    java.lang.Object JavaDoc _put(org.jboss.cache.GlobalTransaction tx, java.lang.String JavaDoc fqn, java.lang.Object JavaDoc key,
446          java.lang.Object JavaDoc value, boolean create_undo_ops) throws org.jboss.cache.CacheException;
447
448    java.lang.Object JavaDoc _put(org.jboss.cache.GlobalTransaction tx, org.jboss.cache.Fqn fqn, java.lang.Object JavaDoc key,
449          java.lang.Object JavaDoc value, boolean create_undo_ops) throws org.jboss.cache.CacheException;
450
451    void _remove(org.jboss.cache.GlobalTransaction tx, java.lang.String JavaDoc fqn, boolean create_undo_ops)
452          throws org.jboss.cache.CacheException;
453
454    void _remove(org.jboss.cache.GlobalTransaction tx, org.jboss.cache.Fqn fqn, boolean create_undo_ops)
455          throws org.jboss.cache.CacheException;
456
457    java.lang.Object JavaDoc _remove(org.jboss.cache.GlobalTransaction tx, java.lang.String JavaDoc fqn, java.lang.Object JavaDoc key,
458          boolean create_undo_ops) throws org.jboss.cache.CacheException;
459
460    java.lang.Object JavaDoc _remove(org.jboss.cache.GlobalTransaction tx, org.jboss.cache.Fqn fqn, java.lang.Object JavaDoc key,
461          boolean create_undo_ops) throws org.jboss.cache.CacheException;
462
463 }
464
Popular Tags