Package org.jboss.cache

Examples of org.jboss.cache.NodeSPI


      n.setDataLoaded(true);
   }

   private void loadIfNeeded(InvocationContext ctx, Fqn fqn, Object key, boolean allKeys, boolean initNode, boolean acquireWriteLock, boolean recursive, boolean isMove, boolean bypassLoadingData, boolean shouldLoadIfNodeIsNull) throws Throwable
   {
      NodeSPI n = helper.wrapNodeForReading(ctx, fqn, true);
      if (n instanceof NullMarkerNode)
      {
         ctx.getLookedUpNodes().remove(fqn);
         n = null;
      }
      boolean mustLoad = mustLoad(fqn, n, key, allKeys || isMove, shouldLoadIfNodeIsNull);

      if (trace) log.trace("load element " + fqn + " mustLoad=" + mustLoad);

      if (mustLoad)
      {
         if (acquireWriteLock || initNode)
         {
            boolean isNew = n == null;
            n = helper.wrapNodeForWriting(ctx, fqn, true, false, true, false, true); // won't create any nodes but will acquire locks.
            if (isNew && n != null) n.setDataLoaded(false);
         }

         // This is really convoluted
         if (n == null || !n.isDeleted())
         {
            boolean exists;
            Map nodeData = null;
            if (bypassLoadingData)
            {
               exists = loader.exists(fqn);
            }
            else
            {
               nodeData = loadData(ctx, fqn);
               exists = nodeData != null;
            }
            if (n == null && exists)
            {
               // just create a dummy node in memory
               n = helper.wrapNodeForWriting(ctx, fqn, true, true, true, false, false);
               n.setDataLoaded(false);
            }
            if (nodeData != null && n != null)
            {
               setNodeState(ctx, fqn, n, nodeData);
            }
         }
      }

      // The complete list of children aren't known without loading them
      if (recursive && n != null)
      {
         loadChildren(fqn, n.getDelegationTarget(), recursive, isMove, ctx);
      }
   }
View Full Code Here


      }

      // Create if node had not been created already
      if (node == null)
      {
         NodeSPI temp = helper.wrapNodeForWriting(ctxt, fqn, true, true, true, false, false);
         node = temp.getDelegationTarget();
      }

      // Create one DataNode per child, mark as UNINITIALIZED
      for (Object name : childrenNames)
      {
         Fqn childFqn = Fqn.fromRelativeElements(fqn, name);

         // create child if it didn't exist
         NodeSPI child = helper.wrapNodeForWriting(ctxt, childFqn, true, true, true, false, false);
         if (child.isCreated()) child.setDataLoaded(false);
         if ((isMove || isActivation) && recursive)
         {
            // load data for children as well!
            child.setInternalState(loadData(ctxt, child.getFqn()));
            child.setDataLoaded(true);
         }

         if (recursive)
         {
            loadChildren(child.getFqn(), child.getDelegationTarget(), true, isMove, ctxt);
         }
      }
      node.setChildrenLoaded(true);
   }
View Full Code Here

   }

   private void integrateTransientState(Fqn target, ObjectInputStream in) throws Exception
   {
      prepareContextOptions();
      NodeSPI targetNode = cache.getNode(target);
      for (Object childname : targetNode.getChildrenNames())
      {
         prepareContextOptions();
         targetNode.removeChild(childname);
      }

      // set these flags to false if we have persistent state!
      targetNode.setDataLoaded(false);
      targetNode.setChildrenLoaded(false);

      List<NodeData> list = readNodesAsList(in);
      if (list != null)
      {
         // if the list was null we read an EOF marker!!  So don't bother popping it off the stack later.
View Full Code Here

      if (canProvideState && (fetchPersistentState || fetchTransientState))
      {
         marshaller.objectToObjectStream(true, out);
         long startTime = System.currentTimeMillis();
         NodeSPI rootNode = cache.peek(fqn, false, false);

         try
         {
            if (log.isDebugEnabled())
            {
View Full Code Here

         for (Address a : toRemove)
         {
            if (log.isTraceEnabled()) log.trace("handleEnqueuedViewChange is removing: " + a);
            BuddyGroup bg = buddyGroupsIParticipateIn.remove(a);
            Fqn backupRootFqn = buddyFqnTransformer.getBackupRoot(bg.getDataOwner());
            NodeSPI backupRoot = cache.getNode(backupRootFqn);
            if (backupRoot != null)
            {
               // could be a race condition where the backup region has been removed because we have been removed
               // from the buddy group, but the buddyGroupsIParticipateIn map hasn't been updated.
               migrateDefunctData(backupRoot, bg.getDataOwner());
View Full Code Here

      return wrapNodeForReading(ctx, fqn, ctx.getOptionOverrides().isForceWriteLock(), putInContext);
   }

   @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);
      } else if ((n = ctx.lookUpNode(f)) == null) {
         if (trace) log.trace("Node " + f + " is not in context, fetching from container.");
View Full Code Here

            context.putLookedUpNode(fqn, n);
            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);
            n.setDataLoaded(true); // created here so we are loading it here
            context.putLookedUpNode(fqn, n);
            n.markForUpdate(dataContainer, writeSkewCheck);
         }
View Full Code Here

    * @throws InterruptedException if interrupted
    */
   @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

      Fqn fqn = node.getFqn();
      acquireLock(ctx, fqn); // lock node
      if (fqnList != null) fqnList.add(fqn);

      // now wrap and add to the context
      NodeSPI rcn = wrapNodeForWriting(ctx, node, parent);
      if (rcn != null) {
         rcn.markForUpdate(dataContainer, writeSkewCheck);
         Map<Object, InternalNode<?, ?>> children = node.getChildrenMap();
         for (InternalNode child : children.values()) lockForWritingRecursive(child, node, ctx, fqnList);
      }
   }
View Full Code Here

   public void setState(ObjectInputStream in, Fqn targetRoot) throws Exception
   {
      if (trace) log.trace("Setting state on Fqn root " + targetRoot);
      cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true);
      NodeSPI target = cache.getNode(targetRoot);
      if (target == null)
      {
         // Create the integration root, but do not replicate
         cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
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.