Examples of PojoCache


Examples of org.jboss.cache.pojo.PojoCache

         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

Examples of org.jboss.cache.pojo.PojoCache

{
   /** @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

Examples of org.jboss.cache.pojo.PojoCache

      // 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

Examples of org.jboss.cache.pojo.PojoCache

      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

Examples of org.jboss.cache.pojo.PojoCache

     
      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

Examples of org.jboss.cache.pojo.PojoCache

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

Examples of org.jboss.cache.pojo.PojoCache

      {
         for (int i = 0; i < pojoCaches.length; i++)
         {
            try
            {  
               PojoCache pc = pojoCaches[i];
               pojoCaches[i] = null;
               pc.stop();
               pc.destroy();
            }
            catch (Exception ex)
            {
               log.error("Failed stopping cache " + i);
            }
View Full Code Here

Examples of org.jboss.cache.pojo.PojoCache

   public PojoCache getPojoCache(String configName, boolean create) throws Exception
   {
      // Check if there's an alias involved
      configName = resolveAlias(configName);
     
      PojoCache cache = null;
      synchronized (pojoCaches)
      {
         if (getCacheNames().contains(configName))
            throw new IllegalStateException("Cannot create PojoCache: plain cache already created for config " + configName);
        
View Full Code Here

Examples of org.jboss.cache.pojo.PojoCache

         if (create && pojoCaches.containsKey(configName))
         {
            log.debug("Plain cache requested for config " + configName +
                      " but a PojoCache is already registered; returning " +
                      " the PojoCache's underlying plain cache");
            PojoCache pc = getPojoCache(configName, false);
            if (pc != null)
               return wrapCache(pc.getCache());
         }
        
         return wrapCache(super.getCache(configName, create));
      }
   }
View Full Code Here

Examples of org.jboss.cache.pojo.PojoCache

      {
         if (pojoCaches.containsKey(configName))
         {
            if (decrementPojoCacheCheckout(configName) == 0)
            {
               PojoCache cache = pojoCaches.remove(configName);
               destroyPojoCache(configName, cache);
            }           
         }
         else
         {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.