use of org.infinispan.commons.configuration.XMLStringConfiguration in project kogito-apps by kiegroup.
the class ProtoSchemaManager method onSchemaRegisteredEvent.
public void onSchemaRegisteredEvent(@Observes SchemaRegisteredEvent event) {
if (schemaAcceptor.accept(event.getSchemaType())) {
SchemaDescriptor schemaDescriptor = event.getSchemaDescriptor();
Storage<String, String> cache = protobufCacheService.getProtobufCache();
cache.put(schemaDescriptor.getName(), schemaDescriptor.getSchemaContent());
schemaDescriptor.getProcessDescriptor().ifPresent(processDescriptor -> {
cacheManager.getProcessIdModelCache().put(processDescriptor.getProcessId(), processDescriptor.getProcessType());
// Initialize domain cache
String cacheName = cacheManager.getDomainModelCacheName(processDescriptor.getProcessId());
String cacheTemplateRendered = getTemplateRendered(schemaDescriptor, cacheName);
LOGGER.debug("Cache template: \n{}", cacheTemplateRendered);
manager.administration().getOrCreateCache(cacheName, new XMLStringConfiguration(cacheTemplateRendered));
});
List<String> errors = checkSchemaErrors(cache);
if (!errors.isEmpty()) {
String message = "Proto Schema contain errors:\n" + String.join("\n", errors);
throw new SchemaRegistrationException(message);
}
if (LOGGER.isDebugEnabled()) {
logProtoCacheKeys();
}
}
}
use of org.infinispan.commons.configuration.XMLStringConfiguration in project indy by Commonjava.
the class CacheProducer method getBasicCache.
/**
* Get a BasicCache instance. If the remote cache is enabled, it will match the named with remote.patterns.
* If matched, it will create/return a RemoteCache. If not matched, an embedded cache will be created/returned to the caller.
*/
public synchronized <K, V> BasicCacheHandle<K, V> getBasicCache(String named) {
BasicCacheHandle handle = caches.computeIfAbsent(named, (k) -> {
if (remoteConfiguration.isEnabled()) {
RemoteCache<K, V> cache = null;
try {
// For infinispan 9.x, it needs to load the specific cache configuration to create it
// For infinispan 11.x, there is no need to load this configuration here, instead, declaring it
// in hotrod-client.properties and get the cache by remoteCacheManager.getCache( "cacheName" )
File confDir = indyConfiguration.getIndyConfDir();
File cacheConf = new File(confDir, "caches/cache-" + named + ".xml");
if (!cacheConf.exists()) {
logger.warn("Invalid conf path, name: {}, path: {}", named, cacheConf);
return null;
}
String confStr;
try (InputStream confStream = FileUtils.openInputStream(cacheConf)) {
confStr = interpolateStrFromStream(confStream, cacheConf.getPath());
} catch (IOException e) {
throw new RuntimeException("Cannot read cache configuration from file: " + cacheConf, e);
}
cache = remoteCacheManager.administration().getOrCreateCache(named, new XMLStringConfiguration(confStr));
if (cache == null) {
logger.warn("Can not get remote cache, name: {}", k);
return null;
}
} catch (Exception e) {
logger.warn("Get remote cache failed", e);
return null;
}
logger.info("Get remote cache, name: {}", k);
return new RemoteCacheHandle(k, cache, metricsManager, getCacheMetricPrefix(k));
}
return null;
});
if (handle == null) {
handle = getCache(named);
}
return handle;
}
use of org.infinispan.commons.configuration.XMLStringConfiguration in project quarkus-quickstarts by quarkusio.
the class InfinispanClientApp method onStart.
void onStart(@Observes StartupEvent ev) {
LOGGER.info("Create or get cache named mycache with the default configuration");
RemoteCache<Object, Object> cache = cacheManager.administration().getOrCreateCache("mycache", new XMLStringConfiguration(String.format(CACHE_CONFIG, "mycache")));
cache.put("hello", "Hello World, Infinispan is up!");
}
use of org.infinispan.commons.configuration.XMLStringConfiguration in project quarkus-test-suite by quarkus-qe.
the class InfinispanClientApp method onStart.
void onStart(@Observes StartupEvent ev) {
LOGGER.info("Create or get cache named mycache with the default configuration");
RemoteCache<Object, Object> cache = cacheManager.administration().getOrCreateCache("mycache", new XMLStringConfiguration(String.format(MYCACHE_CACHE_CONFIG, "mycache")));
cache.addClientListener(new EventPrintListener());
if (cache.isEmpty()) {
cache.put("counter", 0);
}
LOGGER.info("Create or get cache named myshop with the x-protostream configuration");
RemoteCache<Object, Object> myshop = cacheManager.administration().getOrCreateCache("myshop", new XMLStringConfiguration(String.format(MYSHOP_CACHE_CONFIG, "myshop")));
cache.addClientListener(new EventPrintListener());
}
use of org.infinispan.commons.configuration.XMLStringConfiguration in project quarkus-test-suite by quarkus-qe.
the class InfinispanPopulated method onStart.
void onStart(@Observes StartupEvent ev) {
LOGGER.info("Create or get cache named mycache with the default configuration");
RemoteCache<Object, Object> cache = cacheManager.administration().getOrCreateCache("mycache", new XMLStringConfiguration(CACHE_CONFIG));
cache.put("hello", "Hello World, Infinispan is up!");
}
Aggregations