0 Replies Latest reply on Feb 19, 2006 8:48 AM by srivathsak

    Problem in removing a node from the cache...

    srivathsak

      I am having a problem in removing a node from the existing cache.Actualy while making use of the cache Framework I did not understand the Functionality of Region and RegionManager in total. And the code marked in Red is posing a problem.Please do resolve this to me as fast as possible.
      And if possible send me a document that explains the functionality of Region and regionManager very clearly.

      public void nodeRemoved(){
      Fqn fqn;
      for (int i = 0; i < 10; i++) {
      String _str = rootStr + i + "/" + i;
      fqn = Fqn.fromString(_str);
      try {
      cache1_.put(fqn, _str, _str);
      } catch (Exception e) {
      System.out.println(e.getMessage());
      }
      }
      int period = (wakeupIntervalMillis_ / 50);
      _sleep(period); // it really depends the eviction thread time.
      String _str1 = rootStr + "3/3";
      Fqn _fqn1 = Fqn.fromString(_str1);
      String _str2 = rootStr + "7/7";
      Fqn _fqn2 = Fqn.fromString(_str2);
      try {
      cache1_.get(_fqn1, _str1); // just to keep it fresh
      cache1_.get(_fqn2, _str2); // just to keep it fresh
      _sleep(period); // it really depends the eviction thread time.
      cache1_.get(_fqn1, _str1); // just to keep it fresh
      cache1_.get(_fqn2, _str2); // just to keep it fresh
      _sleep(period); // it really depends the eviction thread time.
      cache1_.get(_fqn1, _str1); // just to keep it fresh
      cache1_.get(_fqn2, _str2); // just to keep it fresh
      String val = (String) cache1_.get(rootStr + "7/7", rootStr + "7/7");
      System.out.println("val is :"+val);
      System.out.println("cache before removing is:\n" + cache1_.toString(true));
      System.out.println("Before instantiating the RegionManager");
      DummyEvictionPolicy _policy = new DummyEvictionPolicy();
      RegionManager _regionManager = new RegionManager(_policy);
      algo_ = new LRUAlgorithm();
      _regionManager.createRegion(_fqn1.toString(),algo_);
      _regionManager.createRegion(_fqn2.toString(),algo_);
      Region region = _regionManager.getRegion("a/b/c");
      System.out.println("step1");
      fqn = Fqn.fromString("a/b/c/7/7");
      System.out.println("step1.1");
      region.setAddedNode(fqn);
      EvictedEventNode eventNode = (EvictedEventNode)region.takeLastEventNode();
      System.out.println("cache after removing is:\n" + cache1_.toString(true));
      } catch (Exception e) {
      System.out.println(e.getMessage());
      }
      }


      Thanks and Regards ,
      Srivathsa