Package org.jboss.cache.optimistic

Examples of org.jboss.cache.optimistic.TransactionWorkspace


   }

   @Override
   public Object visitGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
   {
      TransactionWorkspace workspace = getTransactionWorkspace(ctx);
      Object result;
      WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, false, false);
      if (workspaceNode == null)
      {
         if (trace) log.trace("Unable to find node " + command.getFqn() + " in workspace.");
         result = null;
      }
      else
      {
         notifier.notifyNodeVisited(command.getFqn(), true, ctx);
         Object nameSet = workspaceNode.getChildrenNames();
         workspace.addNode(workspaceNode);
         notifier.notifyNodeVisited(command.getFqn(), false, ctx);
         result = nameSet;
      }
      return result;
   }
View Full Code Here


   }

   @Override
   public Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
   {
      TransactionWorkspace workspace = getTransactionWorkspace(ctx);
      Object result;
      WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, false, false);
      if (workspaceNode == null)
      {
         if (trace) log.trace("Unable to find node " + command.getFqn() + " in workspace.");
         result = null;
      }
      else if (workspaceNode.isRemoved())
      {
         if (trace) log.trace("Attempted to retrieve node " + command.getFqn() + " but it has been deleted!");
         result = null;
      }
      else
      {
         notifier.notifyNodeVisited(command.getFqn(), true, ctx);
         workspace.addNode(workspaceNode);
         notifier.notifyNodeVisited(command.getFqn(), false, ctx);
         result = workspaceNode.getNode();
      }
      return result;
   }
View Full Code Here

   }

   @Override
   public Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
   {
      TransactionWorkspace workspace = getTransactionWorkspace(ctx);

      // There is no guarantee that this collection is in any order!
      Collection<WorkspaceNode> nodes = workspace.getNodes().values();

      //we ought to have all necessary locks here so lets try and validate
      if (log.isDebugEnabled()) log.debug("Validating " + nodes.size() + " nodes.");
      for (WorkspaceNode workspaceNode : nodes)
      {
View Full Code Here

   @SuppressWarnings("unchecked")
   private void commitTransaction(InvocationContext ctx)
   {
      GlobalTransaction gtx = getGlobalTransaction(ctx);
      TransactionWorkspace workspace;
      workspace = getTransactionWorkspace(ctx);

      if (log.isDebugEnabled()) log.debug("Commiting successfully validated changes for GlobalTransaction " + gtx);
      Collection<WorkspaceNode> workspaceNodes = workspace.getNodes().values();
      for (WorkspaceNode workspaceNode : workspaceNodes)
      {
         NodeSPI underlyingNode = workspaceNode.getNode();
         // short circuit if this node is deleted?
         if (workspaceNode.isRemoved())
         {
            if (trace) log.trace("Workspace node " + workspaceNode.getFqn() + " deleted; removing");

            if (underlyingNode.getFqn().isRoot())
            {
               throw new CacheException("An illegal attempt to delete the root node!");
            }
            else
            {
               // mark it as invalid so any direct references are marked as such
               underlyingNode.setValid(false, true);
               // we need to update versions here, too
               performVersionUpdate(underlyingNode, workspaceNode);

               if (!useTombstones)
               {
                  // don't retain the tombstone
                  NodeSPI parent = underlyingNode.getParentDirect();
                  if (parent == null)
                  {
                     throw new CacheException("Underlying node " + underlyingNode + " has no parent");
                  }

                  parent.removeChildDirect(underlyingNode.getFqn().getLastElement());
               }
            }
         }
         else
         {
            boolean updateVersion = false;
            if (workspaceNode.isChildrenModified() || workspaceNode.isResurrected()) // if it is newly created make sure we remove all underlying children that may exist, to solve a remove-and-create-in-tx condition
            {
               if (trace) log.trace("Updating children since node has modified children");
               // merge children.
               List<Set<Fqn>> deltas = workspaceNode.getMergedChildren();

               if (trace) log.trace("Applying children deltas to parent node " + underlyingNode.getFqn());

               if (workspaceNode.isResurrected())
               {
                  // mark it as invalid so any direct references are marked as such
                  Map childNode = underlyingNode.getChildrenMapDirect();
                  for (Object o : childNode.values())
                  {
                     NodeSPI cn = (NodeSPI) o;
                     cn.setValid(false, true);
                     if (!useTombstones) underlyingNode.removeChildDirect(cn.getFqn().getLastElement());
                  }
               }

               for (Fqn child : deltas.get(0))
               {
                  NodeSPI childNode = workspace.getNode(child).getNode();
                  underlyingNode.addChildDirect(childNode);
                  childNode.setValid(true, false);
               }

               for (Fqn child : deltas.get(1))
View Full Code Here

   }

   @Override
   public Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
   {
      TransactionWorkspace workspace;
      workspace = getTransactionWorkspace(ctx);
      workspace.clearNodes();
      return invokeNextInterceptor(ctx, command);
   }
View Full Code Here

         }
         else
         {
            try
            {
               TransactionWorkspace workspace = optimistic ? getWorkspace(ctx) : null;
               for (Fqn fqn : filterVisitor.result) invalidateAcrossCluster(fqn, workspace, defaultSynchronous, ctx);
            }
            catch (Throwable t)
            {
               log.warn("Unable to broadcast evicts as a part of the prepare phase.  Rolling back.", t);
View Full Code Here

         otc = (OptimisticTransactionContext) gtx2ContextMap.get(gtx);
      }

      if (otc == null) throw new NullPointerException("No transaction context available!");

      TransactionWorkspace workspace = otc.getTransactionWorkSpace();
      // scan workspaces for this node
      assertNotNull("node " + fqn + " should be in transaction workspace", workspace.getNode(fqn));
   }
View Full Code Here

   }

   @Override
   public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
   {
      TransactionWorkspace workspace = getTransactionWorkspace(ctx);
      WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, false, true);
      if (workspaceNode != null)
      {
         setVersioning(ctx, workspace, workspaceNode);
      }
View Full Code Here

   }

   @Override
   public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
   {
      TransactionWorkspace workspace = getTransactionWorkspace(ctx);
      WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, true, true);
      if (workspaceNode != null)
      {
         setVersioning(ctx, workspace, workspaceNode);
      }
View Full Code Here

   }

   @Override
   public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
   {
      TransactionWorkspace workspace = getTransactionWorkspace(ctx);
      WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, true, true);
      if (workspaceNode != null)
      {
         setVersioning(ctx, workspace, workspaceNode);
      }
View Full Code Here

TOP

Related Classes of org.jboss.cache.optimistic.TransactionWorkspace

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.