Package org.jboss.cache.pojo

Examples of org.jboss.cache.pojo.PojoCache


  
   public static PojoCache createCache(boolean local, String passivationDir,
         boolean totalReplication, boolean marshalling, Set<PojoCache> allCaches)
   {
      Configuration cfg = getConfiguration(local, passivationDir, totalReplication, marshalling);
      PojoCache cache = PojoCacheFactory.createCache(cfg, true);
     
      if (allCaches != null)
         allCaches.add(cache);
      return cache;
   }
View Full Code Here


   }
  
   public static Configuration getConfiguration(boolean local, String passivationDir,
         boolean totalReplication, boolean marshalling)
   {
      PojoCache temp = PojoCacheFactory.createCache(CONFIG_LOCATION, false);
      Configuration config = temp.getCache().getConfiguration();
      if (local)
         config.setCacheMode(CacheMode.LOCAL);
      if (passivationDir == null)
      {
         config.setCacheLoaderConfig(null);
View Full Code Here

   {
      log.info("Enter testUseJK");
     
      ++testCount;
      JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 5, true, null, false, false, null, caches);
      PojoCache cache = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
      JBossWebMetaData webMetaData = createWebMetaData(null, null, null, null, null);
      jbcm.init("test.war", webMetaData);     
      jbcm.start();

      assertFalse("With no config, not using JK", jbcm.getUseJK());
View Full Code Here

   {
      log.info("Enter testSnapshot");
     
      ++testCount;
      JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 5, true, null, false, false, null, caches);
      PojoCache cache = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
     
      JBossWebMetaData webMetaData = createWebMetaData(null, null, null, null, null);
      jbcm.init("test.war", webMetaData);     
      jbcm.start();
View Full Code Here

         throws Exception
   {
      ++testCount;
      String passDir = getPassivationDir(testCount, 1);
      JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 300, true, passDir, false, false, null, caches);
      PojoCache cache = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
     
      JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(2, true, 3, 1);
      jbcm.init("test.war", webMetaData);
     
      jbcm.start();
     
      assertTrue("Passivation is enabled", jbcm.isPassivationEnabled());
      assertEquals("Correct max active count", 2, jbcm.getMaxActiveAllowed());
      assertEquals("Correct max idle time", 3, jbcm.getPassivationMaxIdleTime());
      assertEquals("Correct min idle time", 1, jbcm.getPassivationMinIdleTime());
     
      // Set up a session
      createAndUseSession(jbcm, "1", true, true);
     
      assertEquals("Session count correct", 1, jbcm.getActiveSessionCount());
      assertEquals("Local session count correct", 1, jbcm.getLocalActiveSessionCount());
     
      // And a 2nd
      createAndUseSession(jbcm, "2", true, true);    
     
      assertEquals("Session count correct", 2, jbcm.getActiveSessionCount());
      assertEquals("Local session count correct", 2, jbcm.getLocalActiveSessionCount());    
      assertEquals("Created session count correct", 2, jbcm.getCreatedSessionCount());
      assertEquals("Expired session count correct", 0, jbcm.getExpiredSessionCount());

      //    Sleep past minIdleTime
      SessionTestUtil.sleepThread(1100);
     
      assertEquals("Passivated session count correct", 0, jbcm.getPassivatedSessionCount());
     
      createAndUseSession(jbcm, "3", true, true);     
     
      assertEquals("Session count correct", 2, jbcm.getActiveSessionCount());
      assertEquals("Local session count correct", 2, jbcm.getLocalActiveSessionCount());
      assertEquals("Created session count correct", 3, jbcm.getCreatedSessionCount());
      assertEquals("Expired session count correct", 0, jbcm.getExpiredSessionCount());
      assertEquals("Passivated session count correct", 1, jbcm.getPassivatedSessionCount());
     
      jbcm.stop();
     
      if (restartCache)
      {
         cache.stop();
         cache.destroy();
         caches.remove(cache);
        
         passDir = getPassivationDir(testCount, 1);
         jbcm = SessionTestUtil.createManager("test" + testCount, 5, true, passDir, false, false, null, caches);
      }
View Full Code Here

         throws Exception
   {
      ++testCount;
      String passDir = getPassivationDir(testCount, 1);
      JBossCacheManager jbcm = SessionTestUtil.createManager("test" + testCount, 300, false, passDir, totalReplication, marshalling, null, caches);
      PojoCache cache = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
     
      JBossWebMetaData webMetaData = SessionTestUtil.createWebMetaData(2, true, 30, 1);
      jbcm.init("test.war", webMetaData);
     
      jbcm.start();
     
      assertTrue("Passivation is enabled", jbcm.isPassivationEnabled());
      assertEquals("Correct max active count", 2, jbcm.getMaxActiveAllowed());
      assertEquals("Correct max idle time", 30, jbcm.getPassivationMaxIdleTime());
      assertEquals("Correct min idle time", 1, jbcm.getPassivationMinIdleTime());
     
      passDir = getPassivationDir(testCount, 2);
      JBossCacheManager jbcm1 = SessionTestUtil.createManager("test" + testCount, 300, false, passDir, totalReplication, marshalling, null, caches);
      PojoCache cache1 = SessionTestUtil.getDistributedCacheManagerFactoryPojoCache();
     
      jbcm1.init("test.war", webMetaData);
     
      jbcm1.start();
     
      SessionTestUtil.blockUntilViewsReceived(new Cache[]{ cache.getCache(), cache1.getCache()}, 10000);
     
      assertTrue("Passivation is enabled", jbcm1.isPassivationEnabled());
      assertEquals("Correct max active count", 2, jbcm1.getMaxActiveAllowed());
      assertEquals("Correct max idle time", 30, jbcm1.getPassivationMaxIdleTime());
      assertEquals("Correct min idle time", 1, jbcm1.getPassivationMinIdleTime());
     
      // Set up a session
      createAndUseSession(jbcm, "1", true, true);
     
      assertEquals("Session count correct", 1, jbcm.getActiveSessionCount());
      assertEquals("Local session count correct", 1, jbcm.getLocalActiveSessionCount());   
      assertEquals("Session count correct", 1, jbcm1.getActiveSessionCount());
      assertEquals("Local session count correct", 0, jbcm1.getLocalActiveSessionCount());
     
      // Create a 2nd
      createAndUseSession(jbcm1, "2", true, true);    
     
      assertEquals("Session count correct", 2, jbcm.getActiveSessionCount());
      assertEquals("Local session count correct", 1, jbcm.getLocalActiveSessionCount());    
      assertEquals("Created session count correct", 1, jbcm.getCreatedSessionCount());
      assertEquals("Expired session count correct", 0, jbcm.getExpiredSessionCount());
      assertEquals("Session count correct", 2, jbcm1.getActiveSessionCount());
      assertEquals("Local session count correct", 1, jbcm1.getLocalActiveSessionCount());    
      assertEquals("Created session count correct", 1, jbcm1.getCreatedSessionCount());
      assertEquals("Expired session count correct", 0, jbcm1.getExpiredSessionCount());

      //    Sleep past minIdleTime
      SessionTestUtil.sleepThread(1100);
     
      assertEquals("Passivated session count correct", 0, jbcm1.getPassivatedSessionCount());
     
      createAndUseSession(jbcm1, "3", true, true);     
     
      // jbcm has 3 active because receipt of repl doesn't trigger passivation
      assertEquals("Session count correct", 3, jbcm.getActiveSessionCount());
      assertEquals("Local session count correct", 1, jbcm.getLocalActiveSessionCount());
      assertEquals("Created session count correct", 1, jbcm.getCreatedSessionCount());
      assertEquals("Expired session count correct", 0, jbcm.getExpiredSessionCount());
      assertEquals("Passivated session count correct", 0, jbcm.getPassivatedSessionCount());
      // jbcm1 only has 2 active since it passivated one when it created 3rd
      assertEquals("Session count correct", 2, jbcm1.getActiveSessionCount());
      // Both active sessions are local, as the remote session is oldest so we passivate it first
      assertEquals("Local session count correct", 2, jbcm1.getLocalActiveSessionCount());
      assertEquals("Created session count correct", 2, jbcm1.getCreatedSessionCount());
      assertEquals("Expired session count correct", 0, jbcm1.getExpiredSessionCount());
      assertEquals("Passivated session count correct", 1, jbcm1.getPassivatedSessionCount());
     
      if (fullRestart)
      {
        jbcm1.stop();
        cache1.stop();
        cache1.destroy();
        caches.remove(cache1);
      }
     
      jbcm.stop();
     
View Full Code Here

{
   /** @ejb.interface-method */
   public void bind(String id) throws Exception
   {
      MBeanServer server = (MBeanServer)MBeanServerFactory.findMBeanServer(null).get(0);
      PojoCache cache = (PojoCache)server.getAttribute(new ObjectName("jboss.cache:service=testTreeCacheAop"),
              "PojoCache");
      cache.attach(new Fqn(new Object[] {"sessions", id}).toString(), new CacheObject(id));
   }
View Full Code Here

      // 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();
View Full Code Here

      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
View Full Code Here

     
      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);
View Full Code Here

TOP

Related Classes of org.jboss.cache.pojo.PojoCache

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.