Package org.jboss.cache.optimistic

Examples of org.jboss.cache.optimistic.DataVersion


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

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


      TransactionManager mgr = cache[0].getTransactionManager();
      mgr.begin();

      // explicitly set data version
      DataVersion version = new TestVersion("99");
      cache[1].getInvocationContext().getOptionOverrides().setDataVersion(version);

      try
      {
         cache[1].put(fqn, key, "value2");
View Full Code Here

      cache[0].put(fqn, key, "value");// TestVersion-99 should be on both caches now

      TransactionManager mgr = cache[0].getTransactionManager();
      mgr.begin();

      DataVersion version = new DefaultDataVersion(300);
      cache[1].getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache[1].put(fqn, key, "value2");
      mgr.commit();
   }
View Full Code Here

    *
    * @throws Exception
    */
   public void testCompatibleVersionTypesOutDatedVersion2() throws Exception
   {
      DataVersion version = new DefaultDataVersion(200);
      cache[0].getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache[0].put(fqn, key, "value");// 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");
      cache.getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache.put(fqn, key, "value");

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

      // get a hold of the node
      NodeSPI<String, String> node = cache.getNode(fqn);
      DataVersion versionFromCache = node.getVersion();

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

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

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

      version = new TestVersion("25");
      cache.getInvocationContext().getOptionOverrides().setDataVersion(version);
View Full Code Here

      }
   }

   public void testIncompatibleVersionTypes() throws Exception
   {
      DataVersion version = new TestVersion("99");
      cache.getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache.put(fqn, key, "value");
      TransactionManager mgr = cache.getTransactionManager();
      mgr.begin();
      cache.getInvocationContext().getOptionOverrides().setDataVersion(new DefaultDataVersion(777));
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

        return true;
    }

    private Option getDataVersionOption(Object currentVersion, Object previousVersion) {
       
        DataVersion dv = (dataDescription != null && dataDescription.isVersioned()) ? new DataVersionAdapter(
                currentVersion, previousVersion, dataDescription.getVersionComparator(), dataDescription.toString())
                : NonLockingDataVersion.INSTANCE;
        Option opt = new Option();
        opt.setDataVersion(dv);
        return opt;
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.