Package org.jboss.cache.optimistic

Examples of org.jboss.cache.optimistic.DataVersion


    *
    * @throws Exception
    */
   public void testCompatibleVersionTypesOutDatedVersion2() throws Exception
   {
      DataVersion version = new DefaultDataVersion(200);
      option.setDataVersion(version);
      cache[0].put(fqn, key, "value", option); // TestVersion-99 should be on both caches now

      TransactionManager mgr = cache[0].getTransactionManager();
      mgr.begin();
View Full Code Here


        }
    }

    public void testSimplePut() throws Exception
    {
        DataVersion version = new TestVersion("99");
        option.setDataVersion( version );
        cache.put(fqn, key, "value", option);

        //now retrieve the data from the cache.
        Assert.assertEquals("value", cache.get(fqn,key));

        // get a hold of the node
        OptimisticTreeNode node = (OptimisticTreeNode) cache.get(fqn);
        DataVersion versionFromCache = node.getVersion();

        Assert.assertEquals(TestVersion.class, versionFromCache.getClass());
        Assert.assertEquals("99", ((TestVersion) versionFromCache).getInternalVersion());
    }
View Full Code Here

        Assert.assertEquals("99", ((TestVersion) versionFromCache).getInternalVersion());
    }

    public void testFailingPut() throws Exception
    {
        DataVersion version = new TestVersion("99");
        option.setDataVersion(version);
        cache.put(fqn, key, "value", option);

        version = new TestVersion("25");
        option.setDataVersion(version);
View Full Code Here

        }
    }

    public void testIncompatibleVersionTypes() throws Exception
    {
        DataVersion version = new TestVersion("99");
        option.setDataVersion(version);
        cache.put(fqn, key, "value", option);
        TransactionManager mgr = cache.getTransactionManager();
        mgr.begin();
        option.setDataVersion(new DefaultDataVersion(777));
View Full Code Here

        // try and get the root from the transaction
        TransactionWorkspace workspace = transactionEntry.getTransactionWorkSpace();

        synchronized( workspace )
        {
            DataVersion version = null;
            if (ctx.getOptionOverrides() != null && ctx.getOptionOverrides().getDataVersion() != null)
            {
                version = ctx.getOptionOverrides().getDataVersion();
                workspace.setVersioningImplicit( false );
            }

            if (log.isDebugEnabled()) log.debug(" Getting root fqn from workspace  for gtx " + gtx);
            workspaceNode = workspace.getNode(cache.getRoot().getFqn());

            // we do not have the root so lets wrap it in case we need to add it
            // to the transaction
            if (workspaceNode == null)
            {
                workspaceNode = NodeFactory.getInstance().createWorkspaceNode(cache.getRoot(), workspace);
                workspace.addNode(workspaceNode);
                if (log.isDebugEnabled()) log.debug(" created root node " + workspaceNode + " in workspace " + gtx);
            }
            else
            {
                if (log.isDebugEnabled()) log.debug(" Already found root node " + workspaceNode + " in workspace " + gtx);
            }

            // we will always have one root node here, by this stage
            Fqn tmpFqn = Fqn.ROOT;
            Fqn copy;
            for (int i = 0; i < treeNodeSize; i++)
            {
                boolean isTargetFqn = (i == (treeNodeSize - 1));
                childName = fqn.get(i);

                // build up intermediate node fqn from original Fqn
                tmpFqn = new Fqn(tmpFqn, childName);

                // current workspace node canot be null.
                // try and get the child of current node

                if (log.isTraceEnabled()) log.trace(" Entering synchronized nodewrapper access  for gtx " + gtx);
                TreeNode tempChildNode = workspaceNode.getChild(childName);

//                if (log.isDebugEnabled()) log.debug(" Entered synchronized workspaceNode " + workspaceNode + " access  for gtx " + gtx);

                // no child exists with this name
                if (tempChildNode == null)
                {
                    if (log.isTraceEnabled()) log.trace("Child node "+childName+" doesn't exist.  Creating new node.");
                    // we put the parent node into the workspace as we are changing it's children
                    WorkspaceNode tempCheckWrapper = workspace.getNode(workspaceNode.getFqn());
                    if (tempCheckWrapper == null || tempCheckWrapper.isDeleted())
                    {
                        //add a new one or overwrite an existing one that has been deleted
                        if (log.isTraceEnabled()) log.trace("Parent node "+workspaceNode.getFqn()+" doesn't exist in workspace or has been deleted.  Adding to workspace in gtx " + gtx);
                        workspace.addNode(workspaceNode);
                    }
                    else
                    {
                        if (log.isTraceEnabled()) log.trace(" Parent node " + workspaceNode.getFqn() + " exists in workspace " + gtx);
                    }
                    copy = (Fqn) tmpFqn.clone();
                    // this does not add it into the real child nodes - but in its
                    // local child map for the transaction

                    // get the version passed in, if we need to use explicit versioning.
                    DataVersion versionToPassIn = null;
                    if (isTargetFqn && !workspace.isVersioningImplicit()) versionToPassIn = version;

                    DataNode tempNode = (DataNode) workspaceNode.createChild(childName, copy, workspaceNode.getNode(), cache, versionToPassIn);

                    childWorkspaceNode = NodeFactory.getInstance().createWorkspaceNode(tempNode, workspace);
View Full Code Here

            // get the data version associated with this orig call.

            // since these are all crud methods the Fqn is at arg subscript 1.
            Fqn fqn = (Fqn) origArgs[1];
            // now get a hold of the data version for this specific modification
            DataVersion versionToBroadcast = getVersionToBroadcast(w, fqn);

            // build up the new arguments list for the new call.  Identical to the original lis except that it has the
            // data version tacked on to the end.
            Object[] newArgs = new Object[origArgs.length + 1];
            for (int i=0; i<origArgs.length; i++) newArgs[i] = origArgs[i];
View Full Code Here

         {
            // use explicit versioning
            if (ctx.getOptionOverrides() != null && ctx.getOptionOverrides().getDataVersion() != null)
            {
               workspace.setVersioningImplicit(false);
               DataVersion version = ctx.getOptionOverrides().getDataVersion();

               workspaceNode.setVersion(version);
               if (log.isTraceEnabled()) log.trace("Setting versioning for node " + workspaceNode.getFqn() + " to explicit");
               workspaceNode.setVersioningImplicit(false);
            }
View Full Code Here

//            }
           
            regionRoot = jbcCache.getRoot().getChild( regionFqn );
            if (regionRoot == null || !regionRoot.isValid()) {
               // Establish the region root node with a non-locking data version
               DataVersion version = optimistic ? NonLockingDataVersion.INSTANCE : null;
               regionRoot = CacheHelper.addNode(jbcCache, regionFqn, true, true, version);
            }
            else if (optimistic && regionRoot instanceof NodeSPI) {
                // FIXME Hacky workaround to JBCACHE-1202
                if ( !( ( ( NodeSPI ) regionRoot ).getVersion() instanceof NonLockingDataVersion ) ) {
View Full Code Here

                 // Make sure the root node for the region exists and
                 // has a DataVersion that never complains
                 newRoot = jbcCache.getRoot().getChild( regionFqn );
                 if (newRoot == null || !newRoot.isValid()) {               
                     // Establish the region root node with a non-locking data version
                     DataVersion version = optimistic ? NonLockingDataVersion.INSTANCE : null;
                     newRoot = CacheHelper.addNode(jbcCache, regionFqn, true, true, version);   
                 }
                 else if (newRoot instanceof NodeSPI) {
                     // FIXME Hacky workaround to JBCACHE-1202
                     if ( !( ( ( NodeSPI ) newRoot ).getVersion() instanceof NonLockingDataVersion ) ) {
View Full Code Here

    {
       synchronized (currentView) {
          Transaction tx = suspend();
          try {
             for (Object member : currentView) {
                DataVersion version = optimistic ? NonLockingDataVersion.INSTANCE : null;
                Fqn f = Fqn.fromRelativeElements(internalFqn, member);
                CacheHelper.addNode(jbcCache, f, true, false, version);
             }
          }
          finally {
View Full Code Here

TOP

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

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.