Package org.jboss.cache

Examples of org.jboss.cache.NodeSPI


         Map attrs = nd.getAttributes();

         // We handle this NodeData.  Create a TreeNode and
         // integrate its data
         NodeSPI target;
         if (usePut)
         {
            cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
            cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true);
            cache.clearData(fqn);
View Full Code Here


   private void integrateRetainedNode(NodeSPI ancestor, Node descendant)
   {
      Fqn descFqn = descendant.getFqn();
      Fqn ancFqn = ancestor.getFqn();
      Object name = descFqn.get(ancFqn.size());
      NodeSPI child = (NodeSPI) ancestor.getChild(name);
      if (ancFqn.size() == descFqn.size() + 1)
      {
         if (child == null)
         {
            ancestor.addChild(name, descendant);
View Full Code Here

      if (commit)
      {
         while (it.hasPrevious())
         {
            Fqn f = it.previous();
            NodeSPI rcn = ctx.lookUpNode(f);
            // could be null with read-committed
            if (rcn != null) rcn.commitUpdate(ctx, dataContainer);
            // and then unlock
            if (trace) log.trace("Releasing lock on [" + f + "] for owner " + owner);
            lockManager.unlock(f, owner);
         }
      }
      else
      {
         while (it.hasPrevious())
         {
            Fqn f = it.previous();
            NodeSPI rcn = ctx.lookUpNode(f);
            // could be null with read-committed
            if (rcn != null) rcn.rollbackUpdate();
            // and then unlock
            if (trace) log.trace("Releasing lock on [" + f + "] for owner " + owner);
            lockManager.unlock(f, owner);
         }
      }
View Full Code Here

   }

   @SuppressWarnings("unchecked")
   private Long getExpiration(Fqn fqn)
   {
      NodeSPI n = cache.peek(fqn, false);
      if (n == null)
         return null;
      return (Long) n.getDirect(config.getExpirationKeyName());
   }
View Full Code Here

      public void run()
      {
         int op;
         Fqn fqn;
         Object key, val, retval;
         NodeSPI n;
         boolean flag;

         while (t != null && t.equals(Thread.currentThread()) && t.isAlive())
         {
            try
            {
               if (trace) log.trace("Reading next byte");
               op = input.readByte();
            }
            catch (IOException e)
            {
               log.debug("Client closed socket");
               close();
               break;
            }

            try
            {
               if (trace) log.trace("Resetting output");
               output.reset();
               switch (op)
               {
                  case TcpCacheOperations.GET_CHILDREN_NAMES:
                     fqn = (Fqn) input.readObject();
                     Node node = c.getRoot().getChild(fqn);
                     Set<Object> children = node == null ? Collections.emptySet() : node.getChildrenNames();
                     output.writeObject(children);
                     break;
                  case TcpCacheOperations.GET_KEY:
                     fqn = (Fqn) input.readObject();
                     key = input.readObject();
                     retval = c.get(fqn, key);
                     output.writeObject(retval);
                     break;
                  case TcpCacheOperations.GET:
                     fqn = (Fqn) input.readObject();
                     n = c.getNode(fqn);
                     if (n == null)
                     {
                        // node doesn't exist - return null
                        output.writeObject(null);
                        break;
                     }
                     Map map = n.getData();
                     if (map == null) map = new HashMap();
                     output.writeObject(map);
                     break;
                  case TcpCacheOperations.EXISTS:
                     fqn = (Fqn) input.readObject();
View Full Code Here

   {
      if ((ctx.isLockingSuppressed()) || configuration.getIsolationLevel() == IsolationLevel.NONE)
      {
         if (trace) log.trace("Suppressing locking, creating nodes if necessary");
         int treeNodeSize = command.getFqn().size();
         NodeSPI n = dataContainer.getRoot();
         for (int i = 0; i < treeNodeSize; i++)
         {
            Object childName = command.getFqn().get(i);
            Fqn childFqn = Fqn.fromElements(childName);
            NodeSPI childNode = n.getChildDirect(childFqn);
            if (childNode == null) childNode = n.addChildDirect(childFqn);
            LockUtil.manageReverseRemove(ctx, childNode, true, null, commandsFactory);
            n = childNode;
         }
      }
View Full Code Here

      Object retValue = invokeNextInterceptor(ctx, command);

      if (ctx.getTransaction() == null) // not transactional
      {
         // do a REAL remove here.
         NodeSPI n = dataContainer.peek(command.getFqn(), true, false);
         if (n != null) lockManager.unlockAll(n, Thread.currentThread());
      }

      return retValue;
   }
View Full Code Here

      if (ctx.getGlobalTransaction() == null)
      {
         for (NodeSPI nodeSPI : createdNodes) dataContainer.removeFromDataStructure(nodeSPI.getFqn(), true);
         dataContainer.removeFromDataStructure(command.getFqn(), true);

         NodeSPI n = dataContainer.peek(command.getFqn(), true, false);
         if (n != null) lockManager.unlockAll(n, Thread.currentThread());
      }
      // if this is a delete op and we had to create the node, return a FALSE as nothing *really* was deleted!
      return created ? false : retVal;
   }
View Full Code Here

    * AND it was found in the cache loader (nodeLoaded = true).
    * Then notify the listeners that the node has been activated.
    */
   private void removeNodeFromCacheLoader(Fqn fqn) throws Throwable
   {
      NodeSPI n;
      if (((n = dataContainer.peek(fqn, true, false)) != null) && n.isDataLoaded() && loader.exists(fqn))
      {
         // node not null and attributes have been loaded?
         if (!n.getChildrenDirect().isEmpty())
         {
            boolean result = childrenLoaded(n);
            if (result)
            {
               log.debug("children all initialized");
View Full Code Here

      private void handlePutCommand(InvocationContext ctx, Fqn fqn)
            throws Exception
      {
         if (fqn != null && dataContainer.peek(fqn, false, false) != null && loader.exists(fqn))
         {
            NodeSPI n = dataContainer.peek(fqn, true, false);// don't load
            // node not null and attributes have been loaded?
            if (n != null && n.isDataLoaded())
            {
               // has children?
               boolean result = childrenLoaded(n);
               if (!n.getChildrenDirect().isEmpty() && result)
               {
                  // children have been loaded, remove the node
                  addRemoveMod(ctx, cacheLoaderModifications, fqn, n.getDataDirect());
                  txActs++;
               }
               // doesn't have children, check the cache loader
               else if (loaderNoChildren(fqn))
               {
                  addRemoveMod(ctx, cacheLoaderModifications, fqn, n.getDataDirect());
                  txActs++;
               }
            }
         }
      }
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.