Package org.jboss.cache

Examples of org.jboss.cache.Fqn


      String rootStr = "/test/testdata";

      for (int i = 0; i < 10; i++)
      {
         String str = rootStr + i;
         Fqn fqn = Fqn.fromString(str);
         cache.put(fqn, str, str);
      }

      // wait for an eviction
      TestingUtil.sleepThread(2 * (wakeupIntervalMillis + testRegionTTLMillis));

      String val = (String) cache.get(rootStr + "3", rootStr + "3");
      assertNull("Node should be empty ", val);

      // reinsert the elements
      for (int i = 0; i < 10; i++)
      {
         String str = rootStr + i;
         Fqn fqn = Fqn.fromString(str);
         cache.put(fqn, str, str);
      }

      // clear the root
      cache.removeNode(Fqn.ROOT);


      EvictionWatcher ew = new EvictionWatcher(cache, Fqn.fromString("/base/1"));

      for (int i = 1; i < baseRegionMaxNodes + 2; i++)
      {
         Fqn f = Fqn.fromString("/base/" + i);
         cache.put(f, "key", "base" + i);
      }

      new EvictionController(cache).startEviction();
      assert ew.waitForEviction(30, TimeUnit.SECONDS);

      String rootStr = "/programmatic/";
      for (int i = 0; i < 10; i++)
      {
         String str = rootStr + i;
         Fqn fqn = Fqn.fromString(str);
         cache.put(fqn, str, str);
      }

      String val = (String) cache.get(rootStr + "3", rootStr + "3");
      assertNotNull("DataNode should be empty ", val);

      String rootStr = "programmatic";
      for (int i = 0; i < 10; i++)
      {
         String str = rootStr;
         Integer in = i;
         Fqn fqn = Fqn.fromElements(rootStr, in);
         try
         {
            cache.put(fqn, str, str);
         }
         catch (Exception e)
         {
            fail("Failed to insert data" + e);
            e.printStackTrace();
         }
      }

      Integer in = 3;
      Fqn fqn = Fqn.fromElements(rootStr, in);
      try
      {
         String val = (String) cache.get(fqn, in);
         assertNull("DataNode should be empty ", val);
      }

   public void testObjectBasedFqnEviction2() throws Exception
   {
      addObjectBasedRegion();

      Fqn rootfqn = Fqn.fromElements((Integer) 1);
      for (int i = 0; i < 10; i++)
      {
         Fqn fqn = Fqn.fromRelativeElements(rootfqn, i);
         try
         {
            cache.put(fqn, i, i);
         }
         catch (Exception e)
         {
            fail("Failed to insert data" + e);
            e.printStackTrace();
         }
      }

      try
      {
         Integer in = 3;
         Fqn fqn = Fqn.fromRelativeElements(rootfqn, in);
         Object val = cache.get(fqn, in);
         assertNotNull("DataNode should not be empty ", val);
      }
      catch (Exception e)
      {
         e.printStackTrace();
         fail("Failed to get" + e);
      }

      Integer in = 3;
      Fqn fqn = Fqn.fromRelativeElements(rootfqn, in);
      Thread.sleep(1500);//max age is 1000, so this should expire
      evController.startEviction();

      try
      {

    @NodeRemoved
    public void nodeRemoved(NodeRemovedEvent event) {
        if (event.isPre())
            return;

        Fqn fqn = event.getFqn();
        Fqn regFqn = getRegionFqn();
        if (fqn.size() == regFqn.size() + 1 && fqn.isChildOf(regFqn)) {
            Object key = fqn.get(regFqn.size());
            localCache.remove(key);
        }
        else if (fqn.equals(regFqn)) {
            localCache.clear();
        }

    @NodeModified
    public void nodeModified(NodeModifiedEvent event) {
      
        if (!handleEvictAllModification(event) && !event.isPre()) {
  
           Fqn fqn = event.getFqn();
           Fqn regFqn = getRegionFqn();
           if (fqn.size() == regFqn.size() + 1 && fqn.isChildOf(regFqn)) {
               Object key = fqn.get(regFqn.size());
               localCache.put(key, event.getData().get(ITEM));
           }
        }
    }

  
   public void testIsBuddyFqn()
   {
      assertFalse("ROOT is not buddy", CacheListenerBase.isBuddyFqn(Fqn.ROOT));
     
      Fqn test = Fqn.fromElements(new Object[]{"random", BuddyManager.BUDDY_BACKUP_SUBTREE});
      assertFalse("Random is not buddy", CacheListenerBase.isBuddyFqn(test));
     
      test = BASE;
      assertFalse("Normal is not buddy", CacheListenerBase.isBuddyFqn(test));
     

      }
      if (fqn.size() != 4)
      {
         return result;
      }
      Fqn parentFqn = fqn.getParent();
      try
      {
         if (parentFqn.get(1).equals(JBossCacheWorkspaceStorageCache.CHILD_NODES)
            || parentFqn.get(1).equals(JBossCacheWorkspaceStorageCache.CHILD_PROPS)
            || parentFqn.get(1).equals(JBossCacheWorkspaceStorageCache.CHILD_NODES_BY_PATTERN_LIST)
            || parentFqn.get(1).equals(JBossCacheWorkspaceStorageCache.CHILD_PROPS_BY_PATTERN_LIST))
         {
            // The expected data structure is of type ${ws-id}/$CHILD_NODES/${node-id}/${sub-node-name} or
            // ${ws-id}/$CHILD_PROPS/${node-id}/${sub-property-name} or
            // ${ws-id}/$CHILD_NODES_BY_PATTERN_LIST/${node-id}/${pattern-QPathEntry} or
            // ${ws-id}/$CHILD_PROPS_BY_PATTERN_LIST/${node-id}/${pattern-QPathEntry}

       synchronized (currentView) {
          Transaction tx = suspend();
          try {
             for (Object member : currentView) {
                DataVersion version = optimistic ? NonLockingDataVersion.INSTANCE : null;
                Fqn f = Fqn.fromRelativeElements(internalFqn, member);
                CacheHelper.addNode(jbcCache, f, true, false, version);
             }
          }
          finally {
             resume(tx);

TOP

Related Classes of org.jboss.cache.Fqn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.