Package org.jboss.cache

Examples of org.jboss.cache.DataNode


      option.setCacheModeLocal(true);
     
      Fqn backup = Fqn.fromString(BuddyManager.BUDDY_BACKUP_SUBTREE);
      backup = new Fqn(backup, "a");
      cache1.put(backup, null, option);
      DataNode target = cache1.get(backup);
     
      Fqn abc = Fqn.fromString("/a/b/c");
      cache2.put(abc, "name", JOE, option);
      Fqn ad = Fqn.fromString("/a/d");
      cache2.put(ad, "name", JANE, option);
View Full Code Here


   private void createNodes(GlobalTransaction gtx, Fqn fqn, Map data) throws CacheException
   {
      int treeNodeSize;
      if ((treeNodeSize = fqn.size()) == 0) return;
      DataNode n = cache.getRoot();
      for (int i = 0; i < treeNodeSize; i++)
      {
         Object child_name = fqn.get(i);
         DataNode child_node = (DataNode) n.getOrCreateChild(child_name, gtx, true);
         if (child_node == null)
         {
            if (log.isTraceEnabled())
               log.trace("failed to find or create child " + child_name + " of node " + n.getFqn());
            return;
View Full Code Here

      Iterator backupRoots = getBackupRootIterator();
      boolean exists = false;

      while (backupRoots.hasNext())
      {
         DataNode node = (DataNode) backupRoots.next();
         Fqn newSearchFqn = new Fqn(node.getFqn(), fqn);
         exists = cache.exists(newSearchFqn);
         if (exists) break;
      }

      return exists;
View Full Code Here

      return data;
   }

   private Iterator getBackupRootIterator()
   {
      DataNode backupRoot = cache.peek(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
      return backupRoot == null ? Collections.EMPTY_SET.iterator() : backupRoot.getChildren().values().iterator();
   }
View Full Code Here

      }
   }


   public void testAcquireAll() throws Exception {
      DataNode root;
      Object owner=Thread.currentThread();

      cache=createCache(TreeCache.LOCAL, IsolationLevel.SERIALIZABLE);
      cache.put("/a/b/c", null);
      cache.put("/1/2/3", null);

      root=cache.getRoot();


      root.acquireAll(owner, 2000, DataNode.LOCK_TYPE_READ);
      root.releaseAll(owner);

      assertEquals(0, cache.getNumberOfLocksHeld());

      root.acquireAll(owner, 2000, DataNode.LOCK_TYPE_WRITE);
      root.releaseAll(owner);

      assertEquals(0, cache.getNumberOfLocksHeld());
   }
View Full Code Here

      assertEquals(0, cache.getNumberOfLocksHeld());
   }


   public void testAcquireAllReplicated() throws Exception {
      DataNode root;
      Object owner=Thread.currentThread();

      cache2=createCache(TreeCache.REPL_ASYNC, IsolationLevel.SERIALIZABLE);
      cache2.put("/a/b/c", null);
      cache2.put("/1/2/3", null);

      cache=createCache(TreeCache.REPL_ASYNC, IsolationLevel.SERIALIZABLE);
      root=cache.getRoot();

      root.acquireAll(owner, 2000, DataNode.LOCK_TYPE_READ);
      root.releaseAll(owner);

      assertEquals(0, cache.getNumberOfLocksHeld());

      root.acquireAll(owner, 2000, DataNode.LOCK_TYPE_WRITE);
      root.releaseAll(owner);

      assertEquals(0, cache.getNumberOfLocksHeld());
   }
View Full Code Here

       TreeCache cache = null;
       try
       {
          cache = new TreeCache();
          cache.startService();
          final DataNode root = cache.getRoot();
          final List exceptions = new ArrayList();
          final List timeouts = new ArrayList();


          // get a hold of the WL first
          root.acquire(Thread.currentThread(), 10, DataNode.LOCK_TYPE_WRITE);

          Thread[] t = new Thread[threads];

          for (int i=0; i<t.length; i++)
          {
             t[i] = new Thread()
             {
                public void run()
                {
                   for (int i=0; i<loops; i++)
                   {
                      try
                      {
                         root.acquire(Thread.currentThread(), 10, DataNode.LOCK_TYPE_WRITE);
                      }
                      catch (TimeoutException te)
                      {
                         // expected
                         timeouts.add( te );
                      }
                      catch (Exception ex)
                      {
                         ex.printStackTrace();
                         exceptions.add(ex);
                      }
                   }
                }
             };

             t[i].start();
          }

          for (int i=0; i<t.length; i++) t[i].join();
          root.releaseAll(Thread.currentThread());

          // we should have 0 exceptions
          assertEquals(0, exceptions.size());
       }
       finally
View Full Code Here

       try
       {
          cache = new TreeCache();
          cache.startService();
          cache.put("/test/node", null);
          final DataNode node = cache.get("/test/node");
          final List exceptions = new ArrayList();
          final List timeouts = new ArrayList();


          // get a hold of the WL first
          node.acquire(Thread.currentThread(), 10, DataNode.LOCK_TYPE_WRITE);

          Thread[] t = new Thread[threads];

          for (int i=0; i<t.length; i++)
          {
             t[i] = new Thread()
             {
                public void run()
                {
                   for (int i=0; i<loops; i++)
                   {
                      try
                      {
                         node.acquire(Thread.currentThread(), 10, DataNode.LOCK_TYPE_WRITE);
                      }
                      catch (TimeoutException te)
                      {
                         // expected
                         timeouts.add( te );
                      }
                      catch (Exception ex)
                      {
                         ex.printStackTrace();
                         exceptions.add(ex);
                      }
                   }
                }
             };

             t[i].start();
          }

          for (int i=0; i<t.length; i++) t[i].join();
          node.releaseAll(Thread.currentThread());

          // we should have 0 exceptions
          assertEquals(0, exceptions.size());
       }
       finally
View Full Code Here

  
   private void integrateAssociatedState() throws Exception
   {
      if (associatedSize > 0 && cache instanceof PojoCache) {
        
         DataNode refMapNode = cache.get(InternalDelegate.JBOSS_INTERNAL_MAP);

         ByteArrayInputStream in_stream=new ByteArrayInputStream(state, HEADER_LENGTH + transientSize, associatedSize);
         MarshalledValueInputStream in=new MarshalledValueInputStream(in_stream);
        
         try {
            Object[] nameValue;
            while ((nameValue = (Object[]) in.readObject()) != null) {
               TreeNode target = refMapNode.getChild(nameValue[0]);
              
               if (target == null) {
                  // Create the node
                  Fqn fqn = new Fqn(InternalDelegate.JBOSS_INTERNAL_MAP, nameValue[0]);
                  target = factory.createDataNode(nodeType,
                                                  nameValue[0],
                                                  fqn,
                                                  refMapNode,
                                                  null,
                                                  true,
                                                  cache);
                  refMapNode.addChild(nameValue[0], target);
               }
              
               target.put(nameValue[0], nameValue[1]);
            }
         }
View Full Code Here

           
            Map attrs = nd.getAttributes();
           
            // We handle this NodeData.  Create a DataNode and
            // integrate its data           
            DataNode target = factory.createDataNode(nodeType,
                                                     name,
                                                     fqn,
                                                     parent,
                                                     attrs,
                                                     true,
View Full Code Here

TOP

Related Classes of org.jboss.cache.DataNode

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.