use of org.infinispan.manager.DefaultCacheManager in project camel by apache.
the class InfinispanIdempotentRepositoryTest method setUp.
@Before
public void setUp() throws Exception {
basicCacheContainer = new DefaultCacheManager(GLOBAL_CONFIGURATION);
basicCacheContainer.start();
idempotentRepository = InfinispanIdempotentRepository.infinispanIdempotentRepository(basicCacheContainer, cacheName);
}
use of org.infinispan.manager.DefaultCacheManager in project wildfly by wildfly.
the class CacheContainerBuilder method build.
@Override
public ServiceBuilder<CacheContainer> build(ServiceTarget target) {
Function<EmbeddedCacheManager, CacheContainer> mapper = manager -> new DefaultCacheContainer(this.name, manager, this.defaultCache, this.batcherFactory);
Supplier<EmbeddedCacheManager> supplier = () -> {
GlobalConfiguration config = this.configuration.getValue();
EmbeddedCacheManager manager = new DefaultCacheManager(config, null, false);
manager.addListener(this);
manager.start();
InfinispanLogger.ROOT_LOGGER.debugf("%s cache container started", this.name);
return manager;
};
Consumer<EmbeddedCacheManager> destroyer = manager -> {
manager.stop();
manager.removeListener(this);
InfinispanLogger.ROOT_LOGGER.debugf("%s cache container stopped", this.name);
};
Service<CacheContainer> service = new SuppliedValueService<>(mapper, supplier, destroyer);
ServiceBuilder<CacheContainer> builder = target.addService(this.getServiceName(), service).addAliases(this.aliases.stream().toArray(ServiceName[]::new)).setInitialMode(ServiceController.Mode.PASSIVE);
return this.configuration.register(builder);
}
use of org.infinispan.manager.DefaultCacheManager in project indy by Commonjava.
the class CacheProducer method start.
@PostConstruct
public void start() {
// FIXME This is just here to trigger shutdown hook init for embedded log4j in infinispan-embedded-query.
// FIXES:
//
// Thread-15 ERROR Unable to register shutdown hook because JVM is shutting down.
// java.lang.IllegalStateException: Cannot add new shutdown hook as this is not started. Current state: STOPPED
//
new MarshallableTypeHints().getBufferSizePredictor(CacheHandle.class);
File confDir = indyConfiguration.getIndyConfDir();
File ispnConf = new File(confDir, ISPN_XML);
String configuration;
if (ispnConf.exists()) {
try {
configuration = FileUtils.readFileToString(ispnConf);
} catch (IOException e) {
throw new RuntimeException("Cannot read infinispan configuration from file: " + ispnConf, e);
}
} else {
try (InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(ISPN_XML)) {
configuration = IOUtils.toString(stream);
} catch (IOException e) {
throw new RuntimeException("Cannot read infinispan configuration from classpath: " + ISPN_XML, e);
}
}
StringSearchInterpolator interpolator = new StringSearchInterpolator();
interpolator.addValueSource(new PropertiesBasedValueSource(System.getProperties()));
try {
configuration = interpolator.interpolate(configuration);
} catch (InterpolationException e) {
throw new RuntimeException("Cannot resolve expressions in infinispan configuration.", e);
}
Logger logger = LoggerFactory.getLogger(getClass());
logger.info("Using Infinispan configuration:\n\n{}\n\n", configuration);
try {
cacheManager = new DefaultCacheManager(new ByteArrayInputStream(configuration.getBytes(StandardCharsets.UTF_8)));
} catch (IOException e) {
throw new RuntimeException("Cannot read infinispan configuration.", e);
}
}
Aggregations