Package org.infinispan.manager

Examples of org.infinispan.manager.EmbeddedCacheManager


    assertTrue(storeConfiguration instanceof JpaStoreConfiguration);
    JpaStoreConfiguration jpaCacheLoaderConfig = (JpaStoreConfiguration) storeConfiguration;
    assertEquals(PERSISTENCE_UNIT_NAME, jpaCacheLoaderConfig.persistenceUnitName());
    assertEquals(User.class, jpaCacheLoaderConfig.entityClass());

    EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);

    cacheManager.defineConfiguration("userCache", cacheConfig);

    cacheManager.start();
    Cache<String, User> userCache = cacheManager.getCache("userCache");
    User user = new User();
    user.setUsername("rtsang");
    user.setFirstName("Ray");
    user.setLastName("Tsang");
    userCache.put(user.getUsername(), user);
    userCache.stop();
    cacheManager.stop();
  }
View Full Code Here


      assertEquals(Vehicle.class, jpaConfig.entityClass());
      assertEquals(PERSISTENCE_UNIT_NAME, jpaConfig.persistenceUnitName());
  }
 
  public void testXmlConfig60() throws IOException {
    EmbeddedCacheManager cacheManager = new DefaultCacheManager("config/jpa-config-60.xml");
   
    Cache<VehicleId, Vehicle> vehicleCache = cacheManager.getCache("vehicleCache");
    validateConfig(vehicleCache);
   
    Vehicle v = new Vehicle();
    v.setId(new VehicleId("NC", "123456"));
    v.setColor("BLUE");
    vehicleCache.put(v.getId(), v);

    vehicleCache.stop();
    cacheManager.stop();
  }
View Full Code Here

      if (!started) {
         log.info("Ignoring call to stop as service is not started.");
         return;
      }
      started = false;
      EmbeddedCacheManager cacheManager = (EmbeddedCacheManager) cache.getCacheManager();
      if (cacheManager.getListeners().contains(listenerRegistration)) {
         cacheManager.removeListener(listenerRegistration);
      } else {
         throw new IllegalStateException("Listener must have been registered!");
      }
      //most likely the listeners collection is shared between CacheManager and the Cache
      if (cache.getListeners().contains(listenerRegistration)) {
View Full Code Here

      if (!started) {
         log.debug("Ignoring call to stop as service is not started.");
         return;
      }
      started = false;
      EmbeddedCacheManager cacheManager = cache.getCacheManager();
      if (cacheManager.getListeners().contains(listenerRegistration)) {
         cacheManager.removeListener(listenerRegistration);
      } else {
         throw new IllegalStateException("Listener must have been registered!");
      }
      //most likely the listeners collection is shared between CacheManager and the Cache
      if (cache.getListeners().contains(listenerRegistration)) {
View Full Code Here

      registerProtobufMetadataManagerMBean(protobufMetadataManager, gcr, cacheManager.getName());
   }

   @Override
   public void cacheManagerStarting(GlobalComponentRegistry gcr, GlobalConfiguration globalCfg) {
      EmbeddedCacheManager cacheManager = gcr.getComponent(EmbeddedCacheManager.class);
      initProtobufMetadataManager((DefaultCacheManager) cacheManager, gcr);

      Map<Integer, AdvancedExternalizer<?>> externalizerMap = globalCfg.serialization().advancedExternalizers();
      externalizerMap.put(ExternalizerIds.PROTOBUF_VALUE_WRAPPER, new ProtobufValueWrapper.Externalizer());
   }
View Full Code Here

      for(int i = 0; i < numberOfNodes; i++) {
         GlobalConfigurationBuilder globalConfigurationBuilder = GlobalConfigurationBuilder
               .defaultClusteredBuilder();
         globalConfigurationBuilder.transport().machineId("a" + i).rackId("b" + i).siteId("test" + i);

         EmbeddedCacheManager cm1 = TestCacheManagerFactory.createClusteredCacheManager(
               globalConfigurationBuilder, builder);

         caches.add(cm1.getCache());
      }

      return caches;
   }
View Full Code Here

   }

   protected EmbeddedCacheManager createCacheManager(Properties properties) throws CacheException {
      try {
         String configLoc = ConfigurationHelper.getString(INFINISPAN_CONFIG_RESOURCE_PROP, properties, DEF_INFINISPAN_CONFIG_RESOURCE);
         EmbeddedCacheManager manager = new DefaultCacheManager(configLoc, false);
         String globalStats = ConfigurationHelper.extractPropertyValue(INFINISPAN_GLOBAL_STATISTICS_PROP, properties);
         if (globalStats != null) {
            manager.getGlobalConfiguration().setExposeGlobalJmxStatistics(Boolean.parseBoolean(globalStats));
         }
         manager.start();
         return manager;
      } catch (IOException e) {
         throw new CacheException("Unable to create default cache manager", e);
      }
   }
View Full Code Here

      final ConfigurationContainer templateConfiguration = createTemplateConfiguration();

      this.globalConfigurationOverrides.applyOverridesTo(templateConfiguration.globalConfiguration);
      this.configurationOverrides.applyOverridesTo(templateConfiguration.defaultConfiguration);

      final EmbeddedCacheManager nativeEmbeddedCacheManager = new DefaultCacheManager(
               templateConfiguration.globalConfiguration,
               templateConfiguration.defaultConfiguration);
      for (final Map.Entry<String, Configuration> namedCacheConfig : templateConfiguration.namedCaches
               .entrySet()) {
         nativeEmbeddedCacheManager.defineConfiguration(namedCacheConfig.getKey(),
                  namedCacheConfig.getValue());
      }

      return nativeEmbeddedCacheManager;
   }
View Full Code Here

         return realOne.getListeners();
      }
   }

   public void testViewChange() throws Exception {
      EmbeddedCacheManager cmA = TestCacheManagerFactory.createClusteredCacheManager();
      cmA.getCache();
      CountDownLatch barrier = new CountDownLatch(1);
      GetCacheManagerCheckListener listener = new GetCacheManagerCheckListener(barrier);
      cmA.addListener(listener);
      CacheContainer cmB = TestCacheManagerFactory.createClusteredCacheManager();
      cmB.getCache();
      try {
         barrier.await();
         assert listener.cacheContainer != null;
View Full Code Here

    @Override
    public <E extends SerializationGroupMember<K, V, G>> BackingCacheEntryStore<K, V, E> createIntegratedObjectStore(final String beanName, IdentifierFactory<K> identifierFactory, PassivationManager<K, E> passivationManager, StatefulTimeoutInfo timeout) {
        Cache<?, ?> groupCache = this.groupCache.getValue();
        Configuration groupCacheConfiguration = groupCache.getCacheConfiguration();
        EmbeddedCacheManager container = groupCache.getCacheManager();
        ConfigurationBuilder builder = new ConfigurationBuilder().read(groupCacheConfiguration);
        builder.storeAsBinary().enable().storeKeysAsBinary(true).storeValuesAsBinary(false);
        if (this.maxSize > 0) {
            if (!groupCacheConfiguration.eviction().strategy().isEnabled()) {
                builder.eviction().strategy(EvictionStrategy.LRU);
            }
            builder.eviction().maxEntries(this.maxSize);
        }
        groupCache.getCacheManager().defineConfiguration(beanName, builder.build());
        Cache<K, MarshalledValue<E, MarshallingContext>> cache = container.<K, MarshalledValue<E, MarshallingContext>>getCache(beanName);
        MarshallingContext context = new MarshallingContext(this.factory, passivationManager);
        MarshalledValueFactory<MarshallingContext> valueFactory = new SimpleMarshalledValueFactory(context);
        LockKeyFactory<K> lockKeyFactory = new LockKeyFactory<K>() {
            @Override
            public Serializable createLockKey(K key) {
View Full Code Here

TOP

Related Classes of org.infinispan.manager.EmbeddedCacheManager

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.