KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jboss.cache;
2
3 import org.apache.commons.logging.Log;
4 import org.apache.commons.logging.LogFactory;
5 import org.jboss.cache.buddyreplication.BuddyManager;
6 import org.jboss.cache.config.ConfigurationException;
7 import org.jboss.cache.config.EvictionConfig;
8 import org.jboss.cache.config.EvictionRegionConfig;
9 import org.jboss.cache.eviction.EvictionTimerTask;
10 import org.jboss.cache.eviction.RegionNameConflictException;
11 import org.jboss.cache.lock.NodeLock;
12 import org.jboss.cache.marshall.VersionAwareMarshaller;
13 import org.jgroups.Address;
14
15 import java.util.ArrayList JavaDoc;
16 import java.util.Collections JavaDoc;
17 import java.util.HashSet JavaDoc;
18 import java.util.Iterator JavaDoc;
19 import java.util.List JavaDoc;
20 import java.util.Map JavaDoc;
21 import java.util.Set JavaDoc;
22 import java.util.Vector JavaDoc;
23 import java.util.concurrent.ConcurrentHashMap JavaDoc;
24
25 /**
26  * Encapsulates the concept of a {@link Region}, and manages instances of such regions.
27  *
28  * @author <a HREF="mailto:manik@jboss.org">Manik Surtani</a>
29  * @since 2.0.0
30  */

31 public class RegionManager
32 {
33    /**
34     * The default region used in XML configuration files when defining eviction policies. Any
35     * eviction settings bound under this 'default' Fqn is appplied to {@link org.jboss.cache.Fqn#ROOT} internally so
36     * any region that is not explicitly defined comes under the settings defined for this default.
37     */

38    public static final Fqn DEFAULT_REGION = Fqn.fromString("/_default_");
39    /**
40     * A registry of regions that have been defined.
41     */

42    Map JavaDoc<Fqn, Region> regionsRegistry = new ConcurrentHashMap JavaDoc<Fqn, Region>();
43    boolean defaultInactive;
44    private Log log = LogFactory.getLog(RegionManager.class);
45    CacheImpl cache;
46    private boolean usingEvictions;
47    private EvictionConfig evictionConfig;
48    private EvictionTimerTask evictionTimerTask = new EvictionTimerTask();
49
50    protected final Set JavaDoc activationChangeNodes = Collections.synchronizedSet(new HashSet JavaDoc());
51
52
53    public RegionManager()
54    {
55    }
56
57    public boolean isUsingEvictions()
58    {
59       return usingEvictions;
60    }
61
62    public RegionManager(CacheImpl cache)
63    {
64       this.cache = cache;
65    }
66
67    public boolean isDefaultInactive()
68    {
69       return defaultInactive;
70    }
71
72    public void setDefaultInactive(boolean defaultInactive)
73    {
74       this.defaultInactive = defaultInactive;
75    }
76
77
78    /**
79     * Helper utility that checks for a classloader registered for the
80     * given Fqn, and if found sets it as the TCCL. If the given Fqn is
81     * under the _BUDDY_BACKUP_ region, the equivalent region in the main
82     * cache is used to find the classloader.
83     *
84     * @param fqn Fqn pointing to a region for which a special classloader
85     * may have been registered.
86     */

87    public void setContextClassLoaderAsCurrent(Fqn fqn)
88    {
89       if (fqn.isChildOf(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN))
90       {
91          if (fqn.size() <= 2)
92          {
93             fqn = Fqn.ROOT;
94          }
95          else
96          {
97             fqn = fqn.getFqnChild(2, fqn.size());
98          }
99       }
100       Region region = getRegion(fqn, false);
101       ClassLoader JavaDoc regionCL = (region == null) ? null : region.getClassLoader();
102       if (regionCL != null)
103       {
104          Thread.currentThread().setContextClassLoader(regionCL);
105       }
106
107    }
108
109    /**
110     * Overloaded form of {@link #setContextClassLoaderAsCurrent(Fqn)}
111     *
112     * @param fqn
113     * @see #setContextClassLoaderAsCurrent(Fqn)
114     */

115    public void setContextClassLoaderAsCurrent(String JavaDoc fqn)
116    {
117       setContextClassLoaderAsCurrent(Fqn.fromString(fqn));
118    }
119
120    public Region getRegion(Fqn fqn, boolean createIfAbsent)
121    {
122       return getRegion(fqn, Region.Type.ANY, createIfAbsent);
123    }
124
125    public Region getRegion(Fqn fqn, Region.Type type, boolean createIfAbsent)
126    {
127       Fqn fqnToUse = fqn;
128       if (DEFAULT_REGION.equals(fqnToUse)) fqnToUse = Fqn.ROOT;
129       // first see if a region for this specific Fqn exists
130
if (regionsRegistry.containsKey(fqnToUse))
131       {
132          Region r = regionsRegistry.get(fqnToUse);
133          if (type == Region.Type.ANY
134                  || (type == Region.Type.MARSHALLING && r.getClassLoader() != null)
135                  || (type == Region.Type.EVICTION && r.getEvictionPolicyConfig() != null))
136          {
137             return r;
138          }
139       }
140
141       // if not, attempt to create one ...
142
if (createIfAbsent)
143       {
144          Region r = new RegionImpl(fqnToUse, this);
145          regionsRegistry.put(fqnToUse, r);
146          return r;
147       }
148       else
149       {
150          // first test if the default region has been defined. If not, and if eviction regions
151
// are in use, throw an exception since it is required.
152
if (isUsingEvictions() && !regionsRegistry.containsKey(Fqn.ROOT))
153          {
154             throw new RuntimeException JavaDoc("No default eviction region defined!");
155          }
156       }
157
158       // else try and find a parent which has a defined region, may return null if nothing is defined.
159
Region nextBestThing = null;
160       Fqn nextFqn = fqnToUse;
161
162       while (nextBestThing == null)
163       {
164          nextFqn = nextFqn.getParent();
165          if (regionsRegistry.containsKey(nextFqn))
166          {
167             Region r = regionsRegistry.get(nextFqn);
168
169             if (type == Region.Type.ANY
170                     || (type == Region.Type.MARSHALLING && r.getClassLoader() != null)
171                     || (type == Region.Type.EVICTION && r.getEvictionPolicyConfig() != null))
172             {
173                nextBestThing = r;
174             }
175          }
176          if (nextFqn.isRoot()) break;
177       }
178
179       return nextBestThing;
180    }
181
182    /**
183     * Overloaded form of {@link #getRegion(Fqn,boolean)}
184     *
185     * @param fqn
186     * @param createIfAbsent
187     * @see #getRegion(Fqn,boolean)
188     */

189    public Region getRegion(String JavaDoc fqn, boolean createIfAbsent)
190    {
191       return getRegion(Fqn.fromString(fqn), createIfAbsent);
192    }
193
194    public void registerClassLoader(Fqn fqn, ClassLoader JavaDoc cl)
195    {
196       Region existing = getRegion(fqn, false);
197       if (existing == null)
198       {
199          existing = getRegion(fqn, true);
200       }
201       existing.registerContextClassLoader(cl);
202    }
203
204    /**
205     * Overloaded form of {@link #registerClassLoader(Fqn,ClassLoader)}
206     *
207     * @param fqn
208     * @see #registerClassLoader(Fqn,ClassLoader)
209     */

210    public void registerClassLoader(String JavaDoc fqn, ClassLoader JavaDoc cl)
211    {
212       registerClassLoader(Fqn.fromString(fqn), cl);
213    }
214
215    /**
216     * Overloaded form of {@link #unregisterClassLoader(Fqn)}
217     *
218     * @param fqn
219     * @see #unregisterClassLoader(Fqn)
220     */

221    public void unregisterClassLoader(Fqn fqn)
222    {
223       Region region = getRegion(fqn, false);
224       if (region != null) region.unregisterContextClassLoader();
225    }
226
227
228    public void unregisterClassLoader(String JavaDoc fqn)
229    {
230       unregisterClassLoader(Fqn.fromString(fqn));
231    }
232
233    public void removeRegion(Fqn fqn)
234    {
235       Region r = regionsRegistry.remove(fqn);
236       if (isUsingEvictions() && r.getEvictionPolicy() != null)
237       {
238          evictionTimerTask.removeRegionToProcess(r);
239       }
240    }
241
242    /**
243     * @return the eviction timer task object associated with this Region Manager.
244     */

245    protected EvictionTimerTask getEvictionTimerTask()
246    {
247       return evictionTimerTask;
248    }
249
250
251    /**
252     * Overloaded form of {@link #removeRegion(Fqn)}
253     *
254     * @param fqn
255     * @see #removeRegion(Fqn)
256     */

257    public void removeRegion(String JavaDoc fqn)
258    {
259       removeRegion(Fqn.fromString(fqn));
260    }
261
262    /**
263     * Activates unmarshalling of replication messages for the region
264     * rooted in the given Fqn.
265     *
266     * @param fqn
267     */

268    public void activate(Fqn fqn)
269    {
270       try
271       {
272          if (log.isTraceEnabled()) log.trace("Activating region " + fqn);
273          Region r = getRegion(fqn, false);
274          if (r != null)
275          {
276             if (!defaultInactive && r.getClassLoader() == null)
277             {
278                // This region's state will no match that of a non-existent one
279
// So, there is no reason to keep this region any more
280

281                // (Brian) We shouldn't do this anymore; now outside code
282
// can have a ref to the region!!
283
removeRegion(fqn);
284             }
285             else
286             {
287                //r.activate();
288
r.setActive(true);
289                // FIXME - persistent state transfer counts too!
290
if (cache.getConfiguration().isFetchInMemoryState())
291                {
292                   activateRegion(r.getFqn().toString());
293                }
294             }
295          }
296          else if (defaultInactive)
297          {
298             // "Active" region is not the default, so create a region
299
r = getRegion(fqn, true);
300             r.setActive(true);
301             // FIXME - persistent state transfer counts too!
302
if (cache.getConfiguration().isFetchInMemoryState())
303             {
304                activateRegion(r.getFqn().toString());
305             }
306          }
307       }
308       catch (Exception JavaDoc e)
309       {
310          throw new RuntimeException JavaDoc(e);
311       }
312    }
313
314    /**
315     * Causes the cache to transfer state for the subtree rooted at
316     * <code>subtreeFqn</code> and to begin accepting replication messages
317     * for that subtree.
318     * <p/>
319     * <strong>NOTE:</strong> This method will cause the creation of a node
320     * in the local cache at <code>subtreeFqn</code> whether or not that
321     * node exists anywhere else in the cluster. If the node does not exist
322     * elsewhere, the local node will be empty. The creation of this node will
323     * not be replicated.
324     *
325     * @param subtreeFqn Fqn string indicating the uppermost node in the
326     * portion of the cache that should be activated.
327     * @throws RegionNotEmptyException if the node <code>subtreeFqn</code>
328     * exists and has either data or children
329     */

330    public void activateRegion(String JavaDoc subtreeFqn) throws CacheException
331    {
332       Fqn fqn = Fqn.fromString(subtreeFqn);
333
334       // Check whether the node already exists and has data
335
Node subtreeRoot = cache.findNode(fqn);
336
337       /*
338        * Commented out on Nov 16,2006 Manik&Vladimir
339        *
340        * if (!(cache.isNodeEmpty(subtreeRoot)))
341       {
342          throw new RegionNotEmptyException("Node " + subtreeRoot.getFqn() + " already exists and is not empty");
343       }*/

344
345       if (isActivatingDeactivating(fqn))
346       {
347          throw new CacheException("Region " + subtreeRoot.getFqn() + " is already being activated/deactivated");
348       }
349
350       if (log.isDebugEnabled())
351       {
352          log.debug("activating " + fqn);
353       }
354
355       try
356       {
357
358          // Add this fqn to the set of those we are activating
359
// so calls to _getState for the fqn can return quickly
360
activationChangeNodes.add(fqn);
361
362          Region region = getRegion(fqn, true);
363
364          // If a classloader is registered for the node's region, use it
365
ClassLoader JavaDoc cl = region.getClassLoader();
366
367          BuddyManager buddyManager = cache.getBuddyManager();
368          // Request partial state from the cluster and integrate it
369
if (buddyManager == null)
370          {
371             // Get the state from any node that has it and put it
372
// in the main cache
373
if (subtreeRoot == null)
374             {
375                // We'll update this node with the state we receive
376
subtreeRoot = cache.createSubtreeRootNode(fqn);
377             }
378
379             Address[] groupMembers = null;
380             Vector JavaDoc<Address> members = cache.getMembers();
381             synchronized (members)
382             {
383                groupMembers = members.toArray(new Address[members.size()]);
384             }
385             if (groupMembers.length < 2)
386             {
387                if (log.isDebugEnabled())
388                {
389                   log.debug("No nodes able to give state");
390                }
391             }
392             else
393             {
394                cache.fetchPartialState(groupMembers, subtreeRoot.getFqn());
395             }
396          }
397          else
398          {
399             // Get the state from each DataOwner and integrate in their
400
// respective buddy backup cache
401
List JavaDoc buddies = buddyManager.getBuddyAddresses();
402             for (Iterator JavaDoc it = buddies.iterator(); it.hasNext();)
403             {
404                Address buddy = (Address) it.next();
405                Object JavaDoc sources[] = new Object JavaDoc[]{buddy};
406                Fqn base = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyManager.getGroupNameFromAddress(buddy));
407                Fqn buddyRoot = new Fqn(base, fqn);
408                subtreeRoot = cache.findNode(buddyRoot);
409                if (subtreeRoot == null)
410                {
411                   // We'll update this node with the state we receive
412
subtreeRoot = cache.createSubtreeRootNode(buddyRoot);
413                }
414                cache.fetchPartialState(sources, subtreeRoot.getFqn());
415             }
416          }
417       }
418       catch (Throwable JavaDoc t)
419       {
420          log.error("failed to activate " + subtreeFqn, t);
421
422          // "Re-deactivate" the region
423
try
424          {
425             inactivateRegion(subtreeFqn);
426          }
427          catch (Exception JavaDoc e)
428          {
429             log.error("failed inactivating " + subtreeFqn, e);
430             // just swallow this one and throw the first one
431
}
432
433          // Throw the exception on, wrapping if necessary
434
if (t instanceof RegionNotEmptyException)
435          {
436             throw (RegionNotEmptyException) t;
437          }
438          else if (t instanceof CacheException)
439          {
440             throw (CacheException) t;
441          }
442          else
443          {
444             throw new CacheException(t.getClass().getName() + " " +
445                     t.getLocalizedMessage(), t);
446          }
447       }
448       finally
449       {
450          activationChangeNodes.remove(fqn);
451       }
452    }
453
454    /**
455     * Causes the cache to stop accepting replication events for the subtree
456     * rooted at <code>subtreeFqn</code> and evict all nodes in that subtree.
457     *
458     * @param subtreeFqn Fqn string indicating the uppermost node in the
459     * portion of the cache that should be activated.
460     * @throws RegionNameConflictException if <code>subtreeFqn</code> indicates
461     * a node that is part of another
462     * subtree that is being specially
463     * managed (either by activate/inactiveRegion()
464     * or by registerClassLoader())
465     * @throws CacheException if there is a problem evicting nodes
466     * @throws IllegalStateException if {@link org.jboss.cache.config.Configuration#isUseRegionBasedMarshalling()} is <code>false</code>
467     */

468    public void inactivateRegion(String JavaDoc subtreeFqn) throws CacheException
469    {
470       Fqn fqn = Fqn.fromString(subtreeFqn);
471       if (isActivatingDeactivating(fqn))
472       {
473          throw new CacheException("Region " + subtreeFqn + " is already being activated/deactivated");
474       }
475
476       NodeSPI parent = null;
477       NodeSPI subtreeRoot = null;
478       boolean parentLocked = false;
479       boolean subtreeLocked = false;
480       NodeLock parentLock = null;
481       NodeLock subtreeLock = null;
482
483       try
484       {
485          // Record that this fqn is in status change, so can't provide state
486
activationChangeNodes.add(fqn);
487
488          VersionAwareMarshaller marshaller = cache.getMarshaller();
489          boolean inactive = marshaller.isInactive(subtreeFqn);
490          if (!inactive)
491          {
492             deactivate(subtreeFqn);
493          }
494
495          // Create a list with the Fqn in the main cache and any buddy backup trees
496
BuddyManager buddyManager = cache.getBuddyManager();
497          ArrayList JavaDoc list = new ArrayList JavaDoc();
498          list.add(fqn);
499
500          if (buddyManager != null)
501          {
502             Set JavaDoc buddies = cache.getChildrenNames(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
503             if (buddies != null)
504             {
505                for (Iterator JavaDoc it = buddies.iterator(); it.hasNext();)
506                {
507                   Fqn base = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, it.next());
508                   list.add(new Fqn(base, fqn));
509                }
510             }
511          }
512
513          long stateFetchTimeout = cache.getConfiguration().getLockAcquisitionTimeout() + 5000;
514          // Remove the subtree from the main cache and any buddy backup trees
515
for (Iterator JavaDoc it = list.iterator(); it.hasNext();)
516          {
517             Fqn subtree = (Fqn) it.next();
518             subtreeRoot = cache.findNode(subtree);
519             if (subtreeRoot != null)
520             {
521                // Acquire locks
522
Object JavaDoc owner = cache.getOwnerForLock();
523                subtreeLock = subtreeRoot.getLock();
524                subtreeLock.acquireAll(owner, stateFetchTimeout, NodeLock.LockType.WRITE);
525                subtreeLocked = true;
526
527                // Lock the parent, as we're about to write to it
528
parent = subtreeRoot.getParent();
529                if (parent != null)
530                {
531                   parentLock = parent.getLock();
532                   parentLock.acquire(owner, stateFetchTimeout, NodeLock.LockType.WRITE);
533                   parentLocked = true;
534                }
535
536                // Remove the subtree
537
cache._evictSubtree(subtree);
538
539                // Release locks
540
if (parent != null)
541                {
542                   log.debug("forcing release of locks in parent");
543                   parentLock.releaseAll();
544                }
545
546                parentLocked = false;
547
548                log.debug("forcing release of all locks in subtree");
549                subtreeLock.releaseAll();
550                subtreeLocked = false;
551             }
552          }
553       }
554       catch (InterruptedException JavaDoc ie)
555       {
556          throw new CacheException("Interrupted while acquiring lock", ie);
557       }
558       finally
559       {
560          // If we didn't succeed, undo the marshalling change
561
// NO. Since we inactivated, we may have missed changes
562
//if (!success && !inactive)
563
// marshaller_.activate(subtreeFqn);
564

565          // If necessary, release locks
566
if (parentLocked)
567          {
568             log.debug("forcing release of locks in parent");
569             try
570             {
571                parentLock.releaseAll();
572             }
573             catch (Throwable JavaDoc t)
574             {
575                log.error("failed releasing locks", t);
576             }
577          }
578          if (subtreeLocked)
579          {
580             log.debug("forcing release of all locks in subtree");
581             try
582             {
583                subtreeLock.releaseAll();
584             }
585             catch (Throwable JavaDoc t)
586             {
587                log.error("failed releasing locks", t);
588             }
589          }
590
591          activationChangeNodes.remove(fqn);
592       }
593    }
594
595    public boolean isActivatingDeactivating(Fqn fqn)
596    {
597       return activationChangeNodes.contains(fqn);
598    }
599
600    /**
601     * Overloaded form of {@link #activate(Fqn)}
602     *
603     * @param fqn
604     * @see #activate(Fqn)
605     */

606    public void activate(String JavaDoc fqn)
607    {
608       activate(Fqn.fromString(fqn));
609    }
610
611
612    public boolean hasRegion(Fqn fqn)
613    {
614       return regionsRegistry.containsKey(fqn);
615    }
616
617    /**
618     * Overloaded form of {@link #hasRegion(Fqn)}
619     *
620     * @param fqn
621     * @see #hasRegion(Fqn)
622     */

623    public boolean hasRegion(String JavaDoc fqn)
624    {
625       return hasRegion(Fqn.fromString(fqn));
626    }
627
628    /**
629     * Disables unmarshalling of replication messages for the region
630     * rooted in the given Fqn.
631     *
632     * @param fqn
633     */

634    public void deactivate(Fqn fqn)
635    {
636       try
637       {
638          Region region = getRegion(fqn, false);
639
640          if (region != null)
641          {
642             if (defaultInactive && region.getClassLoader() == null)
643             {
644                // This region's state will no match that of a non-existent one
645
// So, there is no reason to keep this region any more
646

647                // FIXME (Brian) We shouldn't do this anymore; now outside code
648
// can have a ref to the region!!
649
removeRegion(fqn);
650             }
651             else
652             {
653                //region.deactivate();
654
region.setActive(false);
655                // FIXME - we should always clean up; otherwise stale data
656
// is in memory!
657
if (cache.getConfiguration().isFetchInMemoryState())
658                {
659                   inactivateRegion(fqn.toString());
660                }
661             }
662          }
663          else if (!defaultInactive)
664          {
665             region = getRegion(fqn, true);
666             region.setActive(false);
667             // FIXME - we should always clean up; otherwise stale data
668
// is in memory!
669
if (cache.getConfiguration().isFetchInMemoryState())
670             {
671                inactivateRegion(fqn.toString());
672             }
673          }
674       }
675       catch (Exception JavaDoc e)
676       {
677          throw new RuntimeException JavaDoc(e);
678       }
679    }
680
681    /**
682     * Overloaded form of {@link #deactivate(Fqn)}
683     *
684     * @param fqn
685     * @see #deactivate(Fqn)
686     */

687    public void deactivate(String JavaDoc fqn)
688    {
689       deactivate(Fqn.fromString(fqn));
690    }
691
692    /**
693     * Resets the region manager's regions registry
694     */

695    public void reset()
696    {
697       regionsRegistry.clear();
698    }
699
700    /**
701     * Note that the ordered list returned is sorted according to the natural order defined in the {@link Comparable} interface, which {@link org.jboss.cache.Region} extends.
702     *
703     * @return an ordered list of all active regions with registered context class loaders.
704     */

705    public List JavaDoc<Region> getAllMarshallingRegions()
706    {
707       List JavaDoc<Region> regions = new ArrayList JavaDoc<Region>();
708
709       for (Region r : regionsRegistry.values()) if (r.isActive() && r.getClassLoader() != null) regions.add(r);
710
711       Collections.sort(regions);
712
713       return regions;
714    }
715
716    /**
717     * Note that the ordered list returned is sorted according to the natural order defined in the {@link Comparable} interface, which {@link org.jboss.cache.Region} extends.
718     *
719     * @return an ordered list of all active regions which have defined eviction policies.
720     */

721    public List JavaDoc<Region> getAllEvictionRegions()
722    {
723       List JavaDoc<Region> regions = new ArrayList JavaDoc<Region>();
724
725       for (Region r : regionsRegistry.values())
726       {
727          if (r.getEvictionPolicy() != null && evictionTimerTask.isRegionRegisteredForProcessing(r)) regions.add(r);
728       }
729
730       Collections.sort(regions);
731
732       return regions;
733    }
734
735    /**
736     * Note that the ordered list returned is sorted according to the natural order defined in the {@link Comparable} interface, which {@link org.jboss.cache.Region} extends.
737     *
738     * @return an ordered list of all regions, regardless of whether they are active, have eviction policies defined or have class loaders set.
739     */

740    public List JavaDoc<Region> getAllRegions()
741    {
742       List JavaDoc<Region> regions = new ArrayList JavaDoc<Region>(regionsRegistry.values());
743
744       Collections.sort(regions);
745
746       return regions;
747    }
748
749    public void setUsingEvictions(boolean usingEvictions)
750    {
751       this.usingEvictions = usingEvictions;
752    }
753
754    public void setEvictionConfig(EvictionConfig evictionConfig)
755    {
756       this.evictionConfig = evictionConfig;
757       boolean setDefault = false;
758       // create regions for the regions defined in the evictionConfig.
759
for (EvictionRegionConfig erc : evictionConfig.getEvictionRegionConfigs())
760       {
761          Fqn fqn = erc.getRegionFqn();
762          if (log.isTraceEnabled()) log.trace("Creating eviction region " + fqn);
763
764          if (fqn.equals(DEFAULT_REGION))
765          {
766             if (setDefault)
767             {
768                throw new ConfigurationException("A default region for evictions has already been set for this cache");
769             }
770             if (log.isTraceEnabled()) log.trace("Applying settings for " + DEFAULT_REGION + " to Fqn.ROOT");
771             fqn = Fqn.ROOT;
772             setDefault = true;
773          }
774          Region r = getRegion(fqn, true);
775          r.setEvictionPolicy(erc.getEvictionPolicyConfig());
776       }
777    }
778
779    public void startEvictionThread()
780    {
781       evictionTimerTask.init(evictionConfig.getWakeupIntervalSeconds(), cache.getNotifier());
782    }
783
784    /**
785     * Debug Method
786     */

787    public String JavaDoc dumpRegions()
788    {
789       StringBuilder JavaDoc sb = new StringBuilder JavaDoc();
790       for (Region r : regionsRegistry.values())
791       {
792          sb.append("\tRegion " + r);
793          sb.append("\n");
794       }
795       return sb.toString();
796    }
797
798    public String JavaDoc toString()
799    {
800       return "RegionManager " + dumpRegions();
801    }
802 }
803
Popular Tags