Package org.infinispan

Examples of org.infinispan.Cache


               .mBeanServerLookup(new PerThreadMBeanServerLookup());

         EmbeddedCacheManager cm = TestCacheManagerFactory
               .createClusteredCacheManager(holder, true);
         registerCacheManager(cm);
         Cache cache = cm.getCache();
         caches.add(cache);
      }
      waitForClusterToForm(neededCacheNames);
   }
View Full Code Here


   private Cache createCache(String cacheName) {
      boolean trace = log.isTraceEnabled();
      LogFactory.pushNDC(cacheName, trace);
      try {
         Cache cache = wireCache(cacheName);
         // a null return value means the cache was created by someone else before we got the lock
         if (cache == null)
            return caches.get(cacheName).getCache();

         // start the cache-level components
         try {
            cache.start();
         } finally {
            // allow other threads to access the cache
            caches.get(cacheName).latch.countDown();
         }
View Full Code Here

         setConfigurationName(cacheName, c);

         c.setGlobalConfiguration(globalConfiguration);
         c.accept(configurationValidator);
         c.assertValid();
         Cache cache = new InternalCacheFactory().createCache(c, globalComponentRegistry, cacheName, reflectionCache);
         CacheWrapper cw = new CacheWrapper(cache);
         existingCache = caches.put(cacheName, cw);
         if (existingCache != null) {
            throw new IllegalStateException("attempt to initialize the cache twice");
         }
View Full Code Here

            // and any other calls by other threads are ignored.
            if (!stopping) {
               log.debugf("Stopping cache manager %s on %s", globalConfiguration.getClusterName(), getAddress());
               stopping = true;
               // make sure we stop the default cache LAST!
               Cache defaultCache = null;
               for (Map.Entry<String, CacheWrapper> entry : caches.entrySet()) {
                  if (entry.getKey().equals(DEFAULT_CACHE_NAME)) {
                     defaultCache = entry.getValue().cache;
                  } else {
                     Cache c = entry.getValue().cache;
                     if (c != null) {
                        unregisterCacheMBean(c);
                        c.stop();
                     }
                  }
               }

               if (defaultCache != null) {
View Full Code Here

   @ManagedAttribute(description = "The total number of running caches, including the default cache.")
   @Metric(displayName = "Number of running caches", displayType = DisplayType.SUMMARY)
   public String getRunningCacheCount() {
      int running = 0;
      for (CacheWrapper cachew : caches.values()) {
         Cache cache = cachew.cache;
         if (cache != null && cache.getStatus() == ComponentStatus.RUNNING)
            running++;
      }
      return String.valueOf(running);
   }
View Full Code Here

               .persistence()
                  .addStore(JpaStoreConfigurationBuilder.class)
                     .persistenceUnitName("org.infinispan.persistence.jpa")
                     .entityClass(KeyValueEntity.class)
                     .create();
      Cache cache = getCache();
      cache.getAdvancedCache().getComponentRegistry().getGlobalComponentRegistry()
            .registerComponent(new EntityManagerFactoryRegistry(), EntityManagerFactoryRegistry.class);
      store.init(new DummyInitializationContext(configuration, cache, getMarshaller(), new ByteBufferFactoryImpl(),
            new MarshalledEntryFactoryImpl(getMarshaller())));
      store.start();
      return store;
View Full Code Here

      else
         c = configurationOverrides.get(cacheName);

      c.setGlobalConfiguration(globalConfiguration);
      c.assertValid();
      Cache cache = new InternalCacheFactory().createCache(c, globalComponentRegistry, cacheName, reflectionCache);
      CacheWrapper cw = new CacheWrapper(cache);
      try {
         existingCache = caches.putIfAbsent(cacheName, cw);
         if (existingCache != null) {
            throw new IllegalStateException("attempt to initialize the cache twice");
         }
         cache.start();
      } finally {
         cw.latch.countDown();
      }
      return cache;
   }
View Full Code Here

      globalComponentRegistry.getComponent(CacheManagerJmxRegistration.class).start();
   }

   public void stop() {
      // make sure we stop the default cache LAST!
      Cache defaultCache = null;
      for (Map.Entry<String, CacheWrapper> entry : caches.entrySet()) {
         if (entry.getKey().equals(DEFAULT_CACHE_NAME)) {
            defaultCache = entry.getValue().cache;
         } else {
            Cache c = entry.getValue().cache;
            if (c != null) {
               unregisterCacheMBean(c);
               c.stop();
            }
         }
      }

      if (defaultCache != null) {
View Full Code Here

   @ManagedAttribute(description = "The total number of running caches, including the default cache.")
   @Metric(displayName = "Number of running caches", displayType = DisplayType.SUMMARY)
   public String getRunningCacheCount() {
      int running = 0;
      for (CacheWrapper cachew : caches.values()) {
         Cache cache = cachew.cache;
         if (cache != null && cache.getStatus() == ComponentStatus.RUNNING)
            running++;
      }
      return String.valueOf(running);
   }
View Full Code Here

         setConfigurationName(cacheName, c);

         c.setGlobalConfiguration(globalConfiguration);
         c.accept(configurationValidator);
         c.assertValid();
         Cache cache = new InternalCacheFactory().createCache(c, globalComponentRegistry, cacheName, reflectionCache);
         CacheWrapper cw = new CacheWrapper(cache);
         try {
            existingCache = caches.putIfAbsent(cacheName, cw);
            if (existingCache != null) {
               throw new IllegalStateException("attempt to initialize the cache twice");
            }
            cache.start();
         } finally {
            cw.latch.countDown();
         }
         return cache;
      } finally {
View Full Code Here

TOP

Related Classes of org.infinispan.Cache

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.