Package org.jboss.ha.cachemanager

Examples of org.jboss.ha.cachemanager.CacheManager


   public void testPojoCacheIntegration() throws Exception
   {
      log.debug("+++ testPojoCacheIntegration()");
     
      CacheManager cacheManager = getCacheManager();

      // Register a cache
      Configuration config = new Configuration();
      // JBAS-4097 -- don't use a TransactionManagerLookup that will
      // bind DummyTransactionManager into JNDI, as that will screw
      // up other tests
      config.setTransactionManagerLookupClass(MockTransactionManagerLookup.class.getName());
      config.setCacheMode("REPL_SYNC");
      PojoCache pc = PojoCacheFactory.createCache(config, false);
     
      cacheManager.registerPojoCache(pc, ClusteredSingleSignOn.DEFAULT_CACHE_NAME);
     
      // Build up an SSO infrastructure based on LOCAL_ADDRESS        
      JBossCacheSSOClusterManager localSSOManager = new JBossCacheSSOClusterManager();
     
      MockSSOValve localValve = new MockSSOValve(mbeanServer);
View Full Code Here


   private void deadMemberCleanupTest(boolean usePool) throws Exception
   {      
      mbeanServer = usePool ? MBeanServerFactory.createMBeanServer("deadMemberTest")
                                        : null;

      CacheManager cacheManager = getCacheManager();
      // Register a cache
      Cache<Object, Object> delegate = new DefaultCacheFactory<Object, Object>().createCache(false);
      MockTreeCache cache = new MockTreeCache(delegate);
      // JBAS-4097 -- don't use a TransactionManagerLookup that will
      // bind DummyTransactionManager into JNDI, as that will screw
      // up other tests
      cache.getConfiguration().getRuntimeConfig().setTransactionManager(new BatchModeTransactionManager());
     
      cacheManager.registerCache(cache, ClusteredSingleSignOn.DEFAULT_CACHE_NAME);
     
      if (usePool)
      {
         BasicThreadPool pool = new BasicThreadPool();
         mbeanServer.registerMBean(pool, new ObjectName(JBossCacheSSOClusterManager.DEFAULT_THREAD_POOL_NAME));
View Full Code Here

    * but with the same session id are registered, the removal of one leaves
    * the SSO in the proper state.
    */
   public void testSameSessionId() throws Exception
   {
      CacheManager cacheManager = getCacheManager();
      // Register a cache
      Cache<Object, Object> delegate = new DefaultCacheFactory<Object, Object>().createCache(false);
      MockTreeCache cache = new MockTreeCache(delegate);
      // JBAS-4097 -- don't use a TransactionManagerLookup that will
      // bind DummyTransactionManager into JNDI, as that will screw
      // up other tests
      cache.getConfiguration().getRuntimeConfig().setTransactionManager(new BatchModeTransactionManager());
     
      cacheManager.registerCache(cache, ClusteredSingleSignOn.DEFAULT_CACHE_NAME);
     
      // Build up an SSO infrastructure based on LOCAL_ADDRESS 
      JBossCacheSSOClusterManager localSSOManager = new JBossCacheSSOClusterManager();
     
      MockSSOValve localValve = new MockSSOValve(mbeanServer);
View Full Code Here

   {
      if (cacheManager == null)
      {
         JChannelFactory channelFactory = new JChannelFactory();
         ConfigurationRegistry registry = new DependencyInjectedConfigurationRegistry();
         cacheManager = new CacheManager(registry, channelFactory);
         cacheManager.start();
      }
      return cacheManager;
   }
View Full Code Here

   {
      JChannelFactory cf = new JChannelFactory();
      cf.setMultiplexerConfig(DEFAULT_STACKS_FILE);
      cf.setExposeChannels(false);
      cf.start();
      CacheManager registry = new CacheManager(DEFAULT_CONFIGURATION_FILE, cf);
      registry.start();
     
      ConfigurationRegistry configRegistry = registry.getConfigurationRegistry();
     
      Set<String> configNames = registry.getConfigurationNames();
      assertEquals(7, configNames.size());
      Set<String> cacheNames = registry.getCacheNames();
      assertEquals(0, cacheNames.size());
     
      for (String configName : configNames)
      {
         assertNull(configName + " not created", registry.getCache(configName, false));
         Cache<Object, Object> cache = registry.getCache(configName, true);        
         caches.add(cache);
        
         // Cache shouldn't be started
         assertEquals(CacheStatus.INSTANTIATED, cache.getCacheStatus());
         cache.create();
         cache.start();
        
         // Config should be a clone
         Configuration rawConfig = configRegistry.getConfiguration(configName);
         Configuration realConfig = cache.getConfiguration();
         assertFalse(rawConfig == realConfig);
         assertEquals(rawConfig.getClusterName(), realConfig.getClusterName());
      }
     
      cacheNames = registry.getCacheNames();
      assertEquals(configNames, cacheNames);
     
      // Test basic releasing of caches
      for (String configName : configNames)
      {
         registry.releaseCache(configName);        
      }
     
      cacheNames = registry.getCacheNames();
      assertEquals(0, cacheNames.size());
     
      // We shouldn't have affected configuration set
      Set<String> configNames2 = registry.getConfigurationNames();
      assertEquals(configNames, configNames2);
     
      // Releasing only checkout of cache should have destroyed it
      for (Iterator<Cache<Object, Object>> it = caches.iterator(); it.hasNext();)
      {
         assertEquals(CacheStatus.DESTROYED, it.next().getCacheStatus());
         it.remove();
      }
     
      // Get cache w/o asking to create returns null
      String configName = configNames.iterator().next();
      assertNull(configName + " not created", registry.getCache(configName, false));
      // Get cache w/ asking to create returns cache
      Cache<Object, Object> cache = registry.getCache(configName, true);
      assertFalse(null == cache);
      caches.add(cache);
     
      cache.create();
      cache.start();
     
      // Test 2 checkouts of the same cache
      Cache<Object, Object> cache2 = registry.getCache(configName, true);     
      assertEquals(cache, cache2);
     
      registry.releaseCache(configName);
     
      // One release does not cause registry to stop cache
      assertEquals(CacheStatus.STARTED, cache.getCacheStatus());
     
      registry.stop();
     
      // Now it's stopped
      assertEquals(CacheStatus.DESTROYED, cache.getCacheStatus());
      caches.remove(cache);
     
      cacheNames = registry.getCacheNames();
      assertEquals(0, cacheNames.size());
      assertEquals(cacheNames, registry.getConfigurationNames());
   }
View Full Code Here

   {
      JChannelFactory cf = new JChannelFactory();
      cf.setMultiplexerConfig(DEFAULT_STACKS_FILE);
      cf.setExposeChannels(false);
      cf.start();
      CacheManager registry = new CacheManager(DEFAULT_CONFIGURATION_FILE, cf);
      registry.start();
     
      ConfigurationRegistry configRegistry = registry.getConfigurationRegistry();
     
      Set<String> configNames = registry.getConfigurationNames();
      assertEquals(7, configNames.size());
      Set<String> cacheNames = registry.getPojoCacheNames();
      assertEquals(0, cacheNames.size());
     
      for (String configName : configNames)
      {
         assertNull(configName + " not created", registry.getPojoCache(configName, false));
         PojoCache cache = registry.getPojoCache(configName, true);        
         pojoCaches.add(cache);
        
         // Cache shouldn't be started
         assertEquals(CacheStatus.INSTANTIATED, cache.getCache().getCacheStatus());
         cache.create();
         cache.start();
        
         // Config should be a clone
         Configuration rawConfig = configRegistry.getConfiguration(configName);
         Configuration realConfig = cache.getCache().getConfiguration();
         assertFalse(rawConfig == realConfig);
         assertEquals(rawConfig.getClusterName(), realConfig.getClusterName());
      }
     
      cacheNames = registry.getPojoCacheNames();
      assertEquals(configNames, cacheNames);
     
      // Test basic releasing of caches
      for (String configName : configNames)
      {
         registry.releaseCache(configName);        
      }
     
      cacheNames = registry.getPojoCacheNames();
      assertEquals(0, cacheNames.size());
     
      // We shouldn't have affected configuration set
      Set<String> configNames2 = registry.getConfigurationNames();
      assertEquals(configNames, configNames2);
     
      // Releasing only checkout of cache should have destroyed it
      for (Iterator<PojoCache> it = pojoCaches.iterator(); it.hasNext();)
      {
         assertEquals(CacheStatus.DESTROYED, it.next().getCache().getCacheStatus());
         it.remove();
      }
     
      // Get cache w/o asking to create returns null
      String configName = configNames.iterator().next();
      assertNull(configName + " not created", registry.getPojoCache(configName, false));
      // Get cache w/ asking to create returns cache
      PojoCache cache = registry.getPojoCache(configName, true);
      assertFalse(null == cache);
      pojoCaches.add(cache);
     
      cache.create();
      cache.start();
     
      // Test 2 checkouts of the same cache
      PojoCache cache2 = registry.getPojoCache(configName, true);     
      assertEquals(cache, cache2);
     
      registry.releaseCache(configName);
     
      // One release does not cause registry to stop cache
      assertEquals(CacheStatus.STARTED, cache.getCache().getCacheStatus());
     
      registry.stop();
     
      // Now it's stopped
      assertEquals(CacheStatus.DESTROYED, cache.getCache().getCacheStatus());
      caches.remove(cache);
     
      cacheNames = registry.getPojoCacheNames();
      assertEquals(0, cacheNames.size());
      assertEquals(cacheNames, registry.getConfigurationNames());
   }
View Full Code Here

   public void testNullConfigResource() throws Exception
   {
      JChannelFactory cf = new JChannelFactory();
      cf.setMultiplexerConfig(DEFAULT_STACKS_FILE);
      String configResource = null;
      CacheManager registry = new CacheManager(configResource, cf);
      registry.start();
     
      assertEquals("No configs", 0, registry.getConfigurationNames().size());
   }
View Full Code Here

   {
      JChannelFactory cf = new JChannelFactory();
      cf.setMultiplexerConfig(DEFAULT_STACKS_FILE);
      cf.setExposeChannels(false);
      cf.start();
      CacheManager registry = new CacheManager(DEFAULT_CONFIGURATION_FILE, cf);
      registry.start();

      Set<String> configNames = registry.getConfigurationNames();
      assertEquals(7, configNames.size());
     
      assertEquals(0, registry.getCacheNames().size());
     
      assertEquals(0, registry.getPojoCacheNames().size());
     
      Map<String, String> aliases = new HashMap<String, String>();
      aliases.put("alias", DEFAULT_STACK);
      registry.setConfigAliases(aliases);
     
      Map<String, String> registered = registry.getConfigAliases();
      assertEquals(1, registered.size());
      assertEquals(DEFAULT_STACK, registered.get("alias"));
     
      configNames = registry.getConfigurationNames();
      assertEquals(8, configNames.size());
      assertTrue(configNames.contains("alias"));
     
      Cache cache = registry.getCache("alias", true);
      assertNotNull(cache);
      Cache other = registry.getCache(DEFAULT_STACK, false);
      assertEquals(cache, other);
     
      assertEquals(1, registry.getCacheNames().size());
     
      registry.releaseCache(DEFAULT_STACK);
     
      assertEquals(1, registry.getCacheNames().size());
     
      registry.releaseCache("alias");
     
      assertEquals(0, registry.getCacheNames().size());
     
      PojoCache pcache = registry.getPojoCache("alias", true);
      assertNotNull(pcache);
      PojoCache otherPC = registry.getPojoCache(DEFAULT_STACK, false);
      assertEquals(pcache, otherPC);
     
      assertEquals(1, registry.getPojoCacheNames().size());
     
      registry.releaseCache(DEFAULT_STACK);
     
      assertEquals(1, registry.getPojoCacheNames().size());
     
      registry.releaseCache("alias");
     
      assertEquals(0, registry.getPojoCacheNames().size());     
   }
View Full Code Here

   {
      JChannelFactory cf = new JChannelFactory();
      cf.setMultiplexerConfig(DEFAULT_STACKS_FILE);
      cf.setExposeChannels(false);
      cf.start();
      CacheManager registry = new CacheManager(DEFAULT_CONFIGURATION_FILE, cf);
     
      Set<String> cores = new HashSet<String>();
      cores.add("test1");
      cores.add("test2");
      registry.setEagerStartCaches(cores);
      Set<String> pojos = new HashSet<String>();
      pojos.add("test5");
      pojos.add("test6");
      registry.setEagerStartPojoCaches(pojos);
     
      registry.start();
     
      assertEquals(cores, registry.getCacheNames());
      assertEquals(pojos, registry.getPojoCacheNames());
     
      Set<Cache> caches = new HashSet<Cache>();
     
      for (String name : cores)
      {
         Cache cache = registry.getCache(name, false);
         assertNotNull(cache);
         assertEquals(CacheStatus.STARTED, cache.getCacheStatus());
         caches.add(cache);
      }
     
      for (String name : pojos)
      {
         PojoCache pojocache = registry.getPojoCache(name, false);
         assertNotNull(pojocache);
         Cache cache = pojocache.getCache();
         assertEquals(CacheStatus.STARTED, cache.getCacheStatus());
         caches.add(cache);
      }
     
      for (String name : cores)
      {
         registry.releaseCache(name);
      }
     
      for (String name : pojos)
      {
         registry.releaseCache(name);
      }
     
      for (Cache cache : caches)
      {
         assertEquals(CacheStatus.STARTED, cache.getCacheStatus());        
      }
     
      registry.stop();
     
      for (Cache cache : caches)
      {
         assertEquals(CacheStatus.DESTROYED, cache.getCacheStatus());        
      }
View Full Code Here

         cacheConfig1.setCacheMode("REPL_SYNC");
        
         DependencyInjectedConfigurationRegistry registry1 = new DependencyInjectedConfigurationRegistry();
         registry1.registerConfiguration("config1", cacheConfig1);        
        
         CacheManager cacheManager1 = new CacheManager(registry1, factory1);
        
         HAPartitionCacheHandlerImpl cacheHandler1 = new HAPartitionCacheHandlerImpl();
         cacheHandler1.setCacheManager(cacheManager1);
         cacheHandler1.setCacheConfigName("config1");
        
         DistributedStateImpl ds1 = new DistributedStateImpl();
         ds1.setCacheHandler(cacheHandler1);
        
         partition1 = new ClusterPartition();
         partition1.setPartitionName(partitionName);
         partition1.setCacheHandler(cacheHandler1);
         partition1.setStateTransferTimeout(30000);
         partition1.setMethodCallTimeout(60000);
         partition1.setDistributedStateImpl(ds1);
         partition1.setBindIntoJndi(false);
        
         partition1.create();        
         partition1.start();

         DistributedReplicantManager drm1 = partition1.getDistributedReplicantManager();

         Thread.sleep(10000);
        
         // Use a different stack name with the same config to avoid singleton conflicts
         stackName = "tunnel2";
        
         JChannelFactory factory2 = new JChannelFactory();
         factory2.setMultiplexerConfig(muxFile);
         factory2.setNamingServicePort(1099);
         factory2.setNodeName("node2");
         factory2.setExposeChannels(false);
         factory2.setExposeProtocols(false);
         factory2.create();
         factory2.start();
        
         Configuration cacheConfig2 = new Configuration();
         cacheConfig2.setMultiplexerStack(stackName);
         cacheConfig2.setCacheMode("REPL_SYNC");
        
         DependencyInjectedConfigurationRegistry registry2 = new DependencyInjectedConfigurationRegistry();
         registry2.registerConfiguration("config2", cacheConfig2);        
        
         CacheManager cacheManager2 = new CacheManager(registry2, factory2);
        
         HAPartitionCacheHandlerImpl cacheHandler2 = new HAPartitionCacheHandlerImpl();
         cacheHandler2.setCacheManager(cacheManager2);
         cacheHandler2.setCacheConfigName("config2");
        
View Full Code Here

TOP

Related Classes of org.jboss.ha.cachemanager.CacheManager

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.