Package org.jboss.cache

Examples of org.jboss.cache.NodeSPI


      {
         if (log.isDebugEnabled()) log.debug("Attempting to move " + fqn + " onto itself.  Nothing to do.");
         return null;
      }

      NodeSPI node = ctx.lookUpNode(fqn);

      if (node == null || node.isDeleted())
      {
         if (trace) log.trace("Node " + fqn + " does not exist when attempting to move node!  Not doing anything.");
         return null;
      }

      if (trace) log.trace("Moving " + fqn + " to sit under " + to);

      // the actual move algorithm.
      NodeSPI newNode = ctx.lookUpNode(Fqn.fromRelativeElements(to, fqn.getLastElement()));
      Fqn newNodeFqn = newNode.getFqn();

      // at this stage all child node objects we need have been created and are available in the ctx.
      // we just need to mark old ones as deleted, new ones as created, and move data across.
      notifier.notifyNodeMoved(fqn, newNodeFqn, true, ctx);
      moveRecursively(node, newNode, ctx);
View Full Code Here


    * @throws org.jboss.cache.optimistic.DataVersioningException
    *          if there is a version mismatch
    */
   protected NodeSPI peekVersioned(InvocationContext ctx)
   {
      NodeSPI n = ctx.lookUpNode(fqn);
      if (n != null && isVersioned() && n.getVersion().newerThan(dataVersion))
      {
         String errMsg = new StringBuilder("Node found, but version is not equal to or less than the expected [").append(dataVersion).append("].  Is [").append(n.getVersion()).append("] instead!").toString();
         throw new DataVersioningException(errMsg);
      }
      return n;
   }
View Full Code Here

    */
   public Object perform(InvocationContext ctx)
   {
      if (trace) log.trace("Perform('" + globalTransaction + "', '" + fqn + "', k='" + key + "', v='" + value + "')");

      NodeSPI n = ctx.lookUpNode(fqn);
      if (n == null) throw new NodeNotExistsException("Node " + fqn + " does not exist!");


      if (notifier.shouldNotifyOnNodeModified())
      {
         notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.PUT_DATA, n.getDataDirect(), ctx);
      }
      Object oldValue = n.putDirect(key, value);

      if (trace) log.trace("Old value is " + oldValue + ", dataLoaded=" + n.isDataLoaded());

      if (notifier.shouldNotifyOnNodeModified())
      {
         Map newData = Collections.singletonMap(key, value);
         notifier.notifyNodeModified(fqn, false, NodeModifiedEvent.ModificationType.PUT_DATA, newData, ctx);
View Full Code Here

      if (trace)
      {
         log.trace("perform(" + globalTransaction + ", \"" + fqn + "\", " + data + ")");
      }
//      NodeSPI nodeSPI = dataContainer.peekStrict(globalTransaction, fqn, false);
      NodeSPI nodeSPI = ctx.lookUpNode(fqn);
      if (nodeSPI == null) throw new NodeNotExistsException("Node " + fqn + " does not exist!");
      Map existingData = nodeSPI.getDataDirect();

      if (notifier.shouldNotifyOnNodeModified())
      {
         notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.PUT_MAP, existingData == null ? Collections.emptyMap() : existingData, ctx);
      }

      nodeSPI.putAllDirect(data);
      if (notifier.shouldNotifyOnNodeModified())
      {
         notifier.notifyNodeModified(fqn, false, NodeModifiedEvent.ModificationType.PUT_MAP, nodeSPI.getDataDirect(), ctx);
      }
      return null;
   }
View Full Code Here

      assertTrue("Data should be loaded for node " + f, cache.peek(f, false).isDataLoaded());
   }

   protected void assertDataNotLoaded(Fqn f)
   {
      NodeSPI n = cache.peek(f, true);
      assertFalse("Data should not be loaded for node " + f, n != null && n.isDataLoaded());
   }
View Full Code Here

   {
      if (parent != null) return parent;

      InternalNode retval;
      Fqn parentFqn = fqn.getParent();
      NodeSPI parent = ctx.lookUpNode(parentFqn);
      // first check if the parent is cached in the context.
      if (parent != null)
      {
         retval = parent.getDelegationTarget();
      }
      else
      {
         // if not, get it from the data container.  No need to wrap here, we're just going to update the parent's child map.
         retval = container.peekInternalNode(parentFqn, false);
View Full Code Here

      return cn;
   }

   public Map<Object, Object> get(Fqn name) throws Exception
   {
      NodeSPI n = (NodeSPI) delegate.getRoot().getChild(name);
      if (n == null) return null;
      // after this stage we know that the node exists.  So never return a null - at worst, an empty map.
      Map<Object, Object> m = n.getData();
      if (m == null) m = Collections.emptyMap();
      return m;
   }
View Full Code Here

   }

   @SuppressWarnings("unchecked")
   private NodeSPI wrapNodeForReading(InvocationContext ctx, Fqn f, boolean writeLockForced, boolean putInContext) throws InterruptedException
   {
      NodeSPI n;
      if (writeLockForced)
      {
         if (trace) log.trace("Forcing lock on reading node " + f);
         return wrapNodeForWriting(ctx, f, true, false, false, false, false);
      }
View Full Code Here

            if (needToCopy) n.markForUpdate(dataContainer, writeSkewCheck);
         }
         else if (createIfAbsent) // else, do we need to create one?
         {
            parentFqn = fqn.getParent();
            NodeSPI parent = wrapNodeForWriting(context, parentFqn, false, createIfAbsent, false, false, false);
            // do we need to lock the parent to create children?
            boolean parentLockNeeded = isParentLockNeeded(parent.getDelegationTarget());
            // get a lock on the parent.
            if (parentLockNeeded && acquireLock(context, parentFqn))
            {
               ReadCommittedNode parentRCN = (ReadCommittedNode) context.lookUpNode(parentFqn);
               parentRCN.markForUpdate(dataContainer, writeSkewCheck);
            }

            // now to lock and create the node.  Lock first to prevent concurrent creation!
            acquireLock(context, fqn);
            in = nodeFactory.createChildNode(fqn, null, context, false);

            n = nodeFactory.createWrappedNode(in, parent.getDelegationTarget());
            n.setCreated(true);
            context.putLookedUpNode(fqn, n);
            n.markForUpdate(dataContainer, writeSkewCheck);
         }
      }
View Full Code Here

    */
   @SuppressWarnings("unchecked")
   public NodeSPI wrapNodeForWriting(InvocationContext context, InternalNode node, InternalNode parent) throws InterruptedException
   {
      Fqn fqn = node.getFqn();
      NodeSPI n = context.lookUpNode(fqn);
      if (n != null) // exists in context!  Just acquire lock if needed, and wrap.
      {
         // acquire lock if needed
         if (acquireLock(context, fqn))
         {
            // create a copy of the underlying node
            n.markForUpdate(dataContainer, writeSkewCheck);
         }
         if (trace) log.trace("Retrieving wrapped node " + fqn);
      }
      else
      {
         // exists in cache!  Just acquire lock if needed, and wrap.
         // do we need a lock?
         boolean needToCopy = false;
         if (acquireLock(context, fqn))
         {
            needToCopy = true;
         }
         n = nodeFactory.createWrappedNode(node, parent);
         context.putLookedUpNode(fqn, n);
         if (needToCopy) n.markForUpdate(dataContainer, writeSkewCheck);
      }

      return n;
   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.NodeSPI

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.