Package org.jboss.cache

Examples of org.jboss.cache.TreeCache$TransactionLockStatus


      throws Exception
   {
      if (caches.get(cacheID) != null)
         throw new IllegalStateException(cacheID + " already created");
     
      TreeCacheMBean tree=new TreeCache();
      PropertyConfigurator config=new PropertyConfigurator();
      String configFile = sync ? "META-INF/replSync-service.xml"
                               : "META-INF/replAsync-service.xml";
      config.configure(tree, configFile); // read in generic replAsync xml
      tree.setClusterName("VersionedTestBase");
      tree.setReplicationVersion(getReplicationVersion());
      // Use a long timeout to facilitate setting debugger breakpoints
      tree.setInitialStateRetrievalTimeout(60000);
      if (useMarshalling) {
         tree.setUseRegionBasedMarshalling(true);
         tree.setInactiveOnStartup(true);
      }
      if (useCacheLoader) {
         configureCacheLoader(tree, cacheID, useMarshalling, cacheLoaderAsync);
      }
     
View Full Code Here


*/
public class OptimisticAsyncInvalidationTest extends OptimisticSyncInvalidationTest
{
   protected TreeCache createCache() throws Exception
   {
      TreeCache c = new TreeCache();
      c.setCacheMode(TreeCache.INVALIDATION_ASYNC); // only use sync.
      c.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
      c.setNodeLockingScheme("OPTIMISTIC");
      c.startService();
      return c;
   }
View Full Code Here

        super(name);
    }

    public void testConcurrentReadsLocal() throws Exception
    {
        TreeCache cache = createCacheUnstarted();
        cache.setCacheMode("INVALIDATION_ASYNC");
        cache.startService();
       
        Processor[] processors = new Processor[NUM_THREADS];
        for (int i=0; i<NUM_THREADS; i++)
        {
            processors[i] = new Processor(cache, "Processor-" + i);
            processors[i].start();
        }

        cache.put(FQN, "key", "value");
        latch.release();

        for (int i=0; i<NUM_THREADS; i++)
            processors[i].join();
View Full Code Here

   private static final int serverPort = 7500;
   private static final String serverHost = "127.0.0.1";

   protected void setUp() throws Exception
   {
      cache = new TreeCache();
      cache.setCacheLoaderConfiguration(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.tcp.TcpDelegatingCacheLoader", "port=" + serverPort + "\nhost=" + serverHost, false, false, false));
   }
View Full Code Here

    private static Log log = LogFactory.getLog(InvalidationInterceptorTest.class);

    public void testPessimisticNonTransactional() throws Exception
    {
        TreeCache cache1 = createCache(false);
        TreeCache cache2 = createCache(false);

        Fqn fqn = Fqn.fromString("/a/b");
        cache1.put(fqn, "key", "value");

        // test that this has NOT replicated, but rather has been invalidated:
        Assert.assertEquals("value", cache1.get(fqn, "key"));
        Assert.assertNull("Should NOT have replicated!", cache2.get(fqn));

        log.info("***** Node not replicated, as expected.");

        // now make sure cache2 is in sync with cache1:
        cache2.put(fqn, "key", "value");
        Assert.assertNull("Should be null", cache1.get(fqn));
        Assert.assertEquals("value", cache2.get(fqn, "key"));

        // now test the invalidation:
        cache1.put(fqn, "key2", "value2");
        Assert.assertEquals("value2", cache1.get(fqn, "key2"));
        Assert.assertNull("Should have been invalidated!", cache2.get(fqn));

        // clean up.
        cache1.stopService();
        cache2.stopService();
        cache1 = null;
        cache2 = null;
    }
View Full Code Here

        cache2 = null;
    }

    public void testUnnecessaryEvictions() throws Exception
    {
        TreeCache cache1 = createCache(false);
        TreeCache cache2 = createCache(false);

        Fqn fqn1 = Fqn.fromString("/a/b/c");
        Fqn fqn2 = Fqn.fromString("/a/b/d");

        cache1.put(fqn1, "hello", "world");

        assertEquals("world", cache1.get(fqn1, "hello"));
        assertNull(cache2.get(fqn1, "hello"));

        cache2.put(fqn2, "hello", "world");
        assertEquals("world", cache1.get(fqn1, "hello"));
        assertNull(cache2.get(fqn1, "hello"));
        assertEquals("world", cache2.get(fqn2, "hello"));
        assertNull(cache1.get(fqn2, "hello"));

        cache2.put(fqn1, "hello", "world");
        assertEquals("world", cache2.get(fqn1, "hello"));
        assertEquals("world", cache2.get(fqn2, "hello"));
        assertNull(cache1.get(fqn1, "hello"));
        assertNull(cache1.get(fqn2, "hello"));

        cache1.stopService();
        cache2.stopService();
        cache1 = null;
        cache2 = null;

    }
View Full Code Here

*/
public class BuddyReplicationConfigTest extends TestCase
{
    public void testNullConfig() throws Exception
    {
        TreeCache cache = new TreeCache();
        cache.setBuddyReplicationConfig(null);
        assertNull(cache.getBuddyManager());
    }
View Full Code Here

    public void testDisabledConfig() throws Exception
    {
        String xmlConfig = "<config><buddyReplicationEnabled>false</buddyReplicationEnabled></config>";
        Element config = XmlHelper.stringToElement(xmlConfig);
        TreeCache cache = new TreeCache();
        cache.setBuddyReplicationConfig(config);
        assertNull(cache.getBuddyManager());
    }
View Full Code Here



    public void testPessimisticNonTransactionalAsync() throws Exception
    {
        TreeCache cache1 = createUnstartedCache( false );
        TreeCache cache2 = createUnstartedCache( false );
        cache1.setCacheMode(TreeCache.INVALIDATION_ASYNC);
        cache2.setCacheMode(TreeCache.INVALIDATION_ASYNC);
        cache1.startService();
        cache2.startService();

        Fqn fqn = Fqn.fromString("/a/b");
        cache1.put(fqn, "key", "value");
        TestingUtil.sleepThread(500)// give it time to broadcast the evict call
        // test that this has NOT replicated, but rather has been invalidated:
        Assert.assertEquals("value", cache1.get(fqn, "key"));
        Assert.assertNull("Should NOT have replicated!", cache2.get(fqn));

        log.info("***** Node not replicated, as expected.");

        // now make sure cache2 is in sync with cache1:
        cache2.put(fqn, "key", "value");
        TestingUtil.sleepThread(500)// give it time to broadcast the evict call
        Assert.assertNull("Should be null", cache1.get(fqn));
        Assert.assertEquals("value", cache2.get(fqn, "key"));

        // now test the invalidation:
        cache1.put(fqn, "key2", "value2");
        Assert.assertEquals("value2", cache1.get(fqn, "key2"));
        TestingUtil.sleepThread(500)// give it time to broadcast the evict call
        Assert.assertNull("Should have been invalidated!", cache2.get(fqn));

        // clean up.
        cache1.stopService();
        cache2.stopService();
        cache1 = null;
        cache2 = null;
    }
View Full Code Here

    public void testBasicConfig() throws Exception
    {
        String xmlConfig = "<config><buddyReplicationEnabled>true</buddyReplicationEnabled></config>";
        Element config = XmlHelper.stringToElement(xmlConfig);
        TreeCache cache = new TreeCache();
        cache.setBuddyReplicationConfig(config);
        assertNotNull(cache.getBuddyManager());
        BuddyManager mgr = cache.getBuddyManager();
        assertTrue(mgr.isEnabled());
        assertNull(mgr.getBuddyPoolName());
        assertEquals(NextMemberBuddyLocator.class, mgr.buddyLocator.getClass());
        assertEquals(1, ((NextMemberBuddyLocator)mgr.buddyLocator).numBuddies);
        assertTrue(((NextMemberBuddyLocator)mgr.buddyLocator).ignoreColocatedBuddies);
View Full Code Here

TOP

Related Classes of org.jboss.cache.TreeCache$TransactionLockStatus

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.