Package org.jboss.cache

Examples of org.jboss.cache.DataNode


                    // get the version passed in, if we need to use explicit versioning.
                    DataVersion versionToPassIn = null;
                    if (isTargetFqn && !workspace.isVersioningImplicit()) versionToPassIn = version;

                    DataNode tempNode = (DataNode) workspaceNode.createChild(childName, copy, workspaceNode.getNode(), cache, versionToPassIn);

                    childWorkspaceNode = NodeFactory.getInstance().createWorkspaceNode(tempNode, workspace);
                   childWorkspaceNode.setVersioningImplicit(versionToPassIn == null || !isTargetFqn);
                   if (log.isTraceEnabled()) log.trace("setting versioning of " + childWorkspaceNode.getFqn() + " to be " + (childWorkspaceNode.isVersioningImplicit() ? "implicit" : "explicit"));
View Full Code Here


        //see if in the the transaction map
        WorkspaceNode wrapper = workspace.getNode((Fqn) fqn);
        if (wrapper == null)
        {
            DataNode temp = (DataNode) optimisticChildNodeMap.get(fqn);
            if (temp != null)
            {
                wrapper = new WorkspaceNodeImpl(temp, workspace);
                workspace.addNode(wrapper);
                // childrenInWorkspace.add( wrapper );
View Full Code Here

    */
   private void lock(Fqn fqn, GlobalTransaction gtx, int lock_type, boolean recursive,
                     long lock_timeout, boolean createIfNotExists, boolean isRemoveNodeOperation, boolean isRemoveDataOperation)
           throws TimeoutException, LockingException, InterruptedException
   {
      DataNode n;
      DataNode child_node;
      Object child_name;
      Thread currentThread = Thread.currentThread();
      Object owner = (gtx != null) ? (Object) gtx : currentThread;
      int treeNodeSize;
      int currentLockType;


      if (log.isTraceEnabled()) log.trace("Attempting to lock node " + fqn + " for owner " + owner);

      if (fqn == null)
      {
         log.error("fqn is null - this should not be the case");
         return;
      }

      if ((treeNodeSize = fqn.size()) == 0)
         return;

      if (cache.getIsolationLevelClass() == IsolationLevel.NONE)
         lock_type = DataNode.LOCK_TYPE_NONE;

      n = cache.getRoot();
      for (int i = -1; i < treeNodeSize; i++)
      {
         if (i == -1)
         {
            child_name = Fqn.ROOT.getName();
            child_node = cache.getRoot();
         }
         else
         {
            child_name = fqn.get(i);
            child_node = (DataNode) n.getOrCreateChild(child_name, gtx, createIfNotExists);
         }

         if (child_node == null)
         {
            if (log.isTraceEnabled())
               log.trace("failed to find or create child " + child_name + " of node " + n.getFqn());
            return;
         }

         if (lock_type == DataNode.LOCK_TYPE_NONE)
         {
            // acquired=false;
            n = child_node;
            continue;
         }
         else
         {
            if (writeLockNeeded(lock_type, i, treeNodeSize, isRemoveNodeOperation, createIfNotExists, isRemoveDataOperation, fqn, child_node.getFqn()))
            {
               currentLockType = DataNode.LOCK_TYPE_WRITE;
            }
            else
            {
               currentLockType = DataNode.LOCK_TYPE_READ;
            }
         }

         // reverse the "remove" if the node has been previously removed in the same tx, if this operation is a put()
         if (gtx != null && needToReverseRemove(child_node, tx_table.get(gtx), lock_type, isRemoveNodeOperation, createIfNotExists))
         {
            reverseRemove(child_node);
         }


         // Try to acquire the lock; recording that we did if successful
         acquireNodeLock(child_node, owner, gtx, currentLockType, lock_timeout);

         // BES 2007/12/12 -- Revert JBCACHE-1165 fix as it causes endless loop
         // in TransactionTest.testDoubleNodeRemoval, plus another failure
         // in that test
//         // make sure the lock we acquired isn't on a deleted node/is an orphan!!
//         DataNode repeek = cache.peek(child_node.getFqn());
//         if (repeek != null && child_node != repeek)
//         {
//            log.trace("Was waiting for and obtained a lock on a node that doesn't exist anymore!  Attempting lock acquisition again.");
//            // we have an orphan!! Lose the unnecessary lock and re-acquire the lock (and potentially recreate the node).
//            child_node.getLock().release(owner);
//
//            // do the loop again, but don't assign child_node to n so that child_node is processed again.
//            i--;
//            continue;
//         }

         if (recursive && isTargetNode(i, treeNodeSize))
         {
            {
               Set acquired_locks = child_node.acquireAll(owner, lock_timeout, lock_type);
               if (acquired_locks.size() > 0)
               {
                  if (gtx != null)
                  {
                     cache.getTransactionTable().addLocks(gtx, acquired_locks);
View Full Code Here

   private void createNodes(Fqn fqn, GlobalTransaction gtx)
   {
      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);
         // test if this node needs to be 'undeleted'
         // reverse the "remove" if the node has been previously removed in the same tx, if this operation is a put()
         if (gtx != null && needToReverseRemove(child_node, tx_table.get(gtx), DataNode.LOCK_TYPE_WRITE, false, true))
         {
            reverseRemove(child_node);
View Full Code Here

      TransactionWorkspace w = getTransactionWorkspace(getInvocationContext().getGlobalTransaction());
      Map nodeMap = w.getNodes();
      for (Iterator i = nodeMap.keySet().iterator(); i.hasNext();)
      {
         WorkspaceNode wn = (WorkspaceNode) nodeMap.get(i.next());
         DataNode n = wn.getNode();
         IdentityLock lock = n.getLock();
         if (lock.isLocked())
         {
            actual.put(n.getFqn(), lock.isReadLocked() ? READ : WRITE);
         }
      }

      return super.invoke(call);
   }
View Full Code Here

        Collection nodes = workspace.getNodes().values();

        for (Iterator it = nodes.iterator(); it.hasNext();)
        {
            WorkspaceNode workspaceNode = (WorkspaceNode) it.next();
            DataNode node = workspaceNode.getNode();

            boolean writeLock = workspaceNode.isDirty() || workspaceNode.isCreated() || workspaceNode.isDeleted() || (workspaceNode.isChildrenModified() && cache.getLockParentForChildInsertRemove());

            boolean acquired = node.acquire(gtx, lockAcquisitionTimeout, writeLock ? DataNode.LOCK_TYPE_WRITE : DataNode.LOCK_TYPE_READ);
            if (acquired)
            {
                if (log.isTraceEnabled()) log.trace("acquired lock on node " + node.getName());
                te.addLock(node.getLock());
            }
            else
            {
                throw new CacheException("unable to acquire lock on node " + node.getName());
            }
        }
    }
View Full Code Here

      if (log.isTraceEnabled()) log.trace("Attempting to get node " + fqn + " into the workspace");
      WorkspaceNode workspaceNode = workspace.getNode(fqn);
      // if we do not have the node then we need to add it to the workspace
      if (workspaceNode == null)
      {
         DataNode node = cache.peek(fqn);
         if (node == null)
         {
            workspaceNode = null; // seems to happen quite a bit
         }
         else
View Full Code Here

   }

   boolean isAopNode(Fqn fqn)
   {
      // Use this API so it doesn't go thru the interceptor.
      DataNode node = null;
      node = cache.peek(fqn);

      if( node.get(AOPInstance.KEY) != null )
         return true;
      else
         return false;
   }
View Full Code Here

            if (wrappedNode.isDeleted())
            {
                // handle notifications

                if (trace) log.trace("Node's been deleted; removing");
                DataNode dNode = wrappedNode.getNode();
                cache.notifyNodeRemove(dNode.getFqn(), true);

                if (dNode.getFqn().isRoot())
                {
                    log.warn("Attempted to delete the root node");
                }
                else
                {
                    DataNode parent = (DataNode) dNode.getParent();
                    parent.removeChild( dNode.getName() );
                }
                cache.notifyNodeRemoved(dNode.getFqn());
                cache.notifyNodeRemove(dNode.getFqn(), false);
            }
            else
View Full Code Here

      if (log.isTraceEnabled()) log.trace("Attempting to get node " + fqn + " into the workspace");
      WorkspaceNode workspaceNode = workspace.getNode(fqn);
      // if we do not have the node then we need to add it to the workspace
      if (workspaceNode == null)
      {
         DataNode node = cache.peek(fqn);
         if (node == null)
         {
            workspaceNode = null; // seems to happen quite a bit
         }
         else
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.