Examples of WorkspaceNode


Examples of org.jboss.cache.optimistic.WorkspaceNode

    }

    private void simpleValidate(Collection nodes)
        throws CacheException
    {
        WorkspaceNode workspaceNode;

        boolean trace = log.isTraceEnabled();
        for (Iterator it = nodes.iterator(); it.hasNext();)
        {
           workspaceNode = (WorkspaceNode) it.next();
           if (workspaceNode.isDirty())
           {
               Fqn fqn = workspaceNode.getFqn();
               if (trace) log.trace("Validating version for node [" + fqn + "]");
               OptimisticTreeNode realNode = (OptimisticTreeNode) cache._get(fqn);

               // if this is a newly created node then we expect the underlying node to be null.
               // also, if the node has been deleted in the WS and the underlying node is null, this *may* be ok ... will test again later when comparing versions
               // if not, we have a problem...
               if (realNode == null && !workspaceNode.isCreated() && !workspaceNode.isDeleted())
               {
                   throw new DataVersioningException("Real node for " + fqn + " is null, and this wasn't newly created in this tx!");
               }

              // needs to have been created AND modified - we allow concurrent creation if no data is put into the node
              if (realNode != null && workspaceNode.isCreated() && workspaceNode.isModified())
              {
                 throw new DataVersioningException("Tx attempted to create " + fqn + " anew.  It has already been created since this tx started by another (possibly remote) tx.");
              }

               if (!workspaceNode.isCreated() && (workspaceNode.isDeleted() || workspaceNode.isModified()))
               {
                  // if the real node is null, throw a DVE
                  if (realNode == null)
                  {
                     // but not if the WSN has also been deleted
                     if (!workspaceNode.isDeleted())
                        throw new DataVersioningException("Unable to compare versions since the underlying node has been deleted by a concurrent transaction!");
                     else
                        if (trace) log.trace("The data node ["+fqn+"] is null, but this is ok since the workspace node is marked as deleted as well");
                  }
                  else if (realNode.getVersion().newerThan( workspaceNode.getVersion() ))
                  {
                     // newerThan() will internally test if the DataVersion types being compared tally up, and will barf if
                     // necessary with an appropriate DataVersioningException.
                     // we have an out of date node here
                     throw new DataVersioningException("DataNode [" + fqn + "] version " + ((OptimisticTreeNode)workspaceNode.getNode()).getVersion() + " is newer than workspace node " + workspaceNode.getVersion());
                  }
               }
           }
           else
           {
               if (trace) log.trace("Node [" + workspaceNode.getFqn() + "] doesn't need validating as it isn't dirty");
           }
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.