How to modify cache settings on a running ignite instance? - ignite

Is there any setOrCreateCache method in ignite? I just find a getOrCreateCache method.
I want to modify cache settings on a running ignite instance. How to?
My ignite version is 1.9.0. Thanks.
Here is my codes:
IgniteCache<Integer, String> cache = ignite.getOrCreateCache("myCacheName"); // I've created a cache
// How to change the config of myCacheName?

You can dynamically create cache on running ignite by using getOrCreateCache(CacheConfiguration cacheCfg) method. It's possible to dynamically configure cache before create it.

Related

How to create Infinispan ClusteredLockManager in Wildfly?

I have Wildfly 26.1.2 and Infinispan 13.0.10.Final.
We already have a cluster and Wildfly Infinispan subsystem with cache containers, transport, jgroups, and local caches.
Now we want to use clustered-locks, and I need to create ClusteredLockManager
If I read the manuals here
https://infinispan.org/docs/stable/titles/embedding/embedding.html
They say
// Set up a clustered Cache Manager.
GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder();
// Configure the cache mode, in this case it is distributed and synchronous.
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().cacheMode(CacheMode.DIST_SYNC);
// Initialize a new default Cache Manager.
DefaultCacheManager cm = new DefaultCacheManager(global.build(), builder.build());
// Initialize a Clustered Lock Manager.
ClusteredLockManager clm1 =
EmbeddedClusteredLockManagerFactory.from(cm);
In the logs, I see it creates a NEW cluster with a default name (ISPN), and I need to put here all the configurations (at least with jgroups and transport), and duplicate them from the inifinispan-wildfly subsystems
But I don't want to do it because I already have configured cluster in my standalone-ec2-full-ha.xml file with Infinispan caches containers and managers and all that stuff
Can I somehow create my ClusteredLockManager using an already-defined configuration and infinispan-cluster from a standalone-ec2-full-ha.xml file?
Or can I define a config for ClusteredLockManager in my Wildfly subsystem?
And just inject it as a resource in Java Code
If I do something like
#Resource(name = "java:jboss/infinispan/container/cacheManager")
private EmbeddedCacheManager cacheManager;
...
ClusteredLockManager lockManager = EmbeddedClusteredLockManagerFactory.from(cacheManager);
It returns null. And the factory can create ClusteredLockManager only from cacheManager.
Are there any options for creating ClusteredLockManager using the existing cluster and wildfly-infinispan-subsystems configuration?

setIndexedTypes seems to be ignored when the cache configuration is set with a template

I am getting the following exception when querying a cache
javax.cache.CacheException: Indexing is disabled for cache: DEFAULT. Use setIndexedTypes or setTypeMetadata methods on CacheConfiguration to enable.
The cache configuration is set using a template
// template for cache configurations
CacheConfiguration cacheCfg = new CacheConfiguration("cacheTemplate");
cacheCfg.setBackups(backups);
cacheCfg.setCacheMode(CacheMode.PARTITIONED);
cacheCfg.setIndexedTypes(Key.class, Payload.class);
ignite.addCacheConfiguration(cacheCfg);
Shouldn't that work? Or do I need to set the configuration explicitely, in which case, what is the point of having a template?

Create Cluster Configuration in Ignite web console is not working

Create CLuster COnfig The "Create Cluster Configuration button" not working from webconsole https://console.gridgain.com/configuration/overview..
Moreover when i launch the console.gridgain.com from my browser. I am getting below error
Failed to load clusters: Cannot start/stop cache within lock or transaction [cacheNames=ClusterCache, operation=dynamicStartCache]
I think this means you have tried to use getOrCreateCache from within an Apache Ignite Transaction.
I recommend getting all of your caches before you start a Transaction. Maybe there's something else but you will need to share more details.
Seems Gridgain ignite team has made a fix and it is now resolved.

Trying to disable the metrics logging in Ignite but failed

Found that the Ignite Metrics logging is a bit excessive so decided to disabled it.
As indicated in the screenshot, it should be done by setting setMetricsLogFrequency to 0.
However, it does not work. Below is my code for creating IgniteConfiguration. Note that Ignite is created with client mode.
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setMetricsLogFrequency(0); // Trying to disabled it!
cfg.setIgniteInstanceName("IgnitePod");
cfg.setClientMode(true);
cfg.setAuthenticationEnabled(true);
// Ignite persistence configuration.
DataStorageConfiguration storageCfg = new DataStorageConfiguration();
storageCfg.getDefaultDataRegionConfiguration().setPersistenceEnabled(true);
cfg.setDataStorageConfiguration(storageCfg);
cfg.setDiscoverySpi(spi);
Ignite ignite = Ignition.start(cfg);
Any idea on how to solve this?
It is a different Ignite instance. Your one is called "IgnitePod" but this one is "CacheManager_0". You need to adjust its config, too.

Ignite Websession persistance issue with HttpServletResponse.encodeURL

Using Apache Ignite Websession Persistence with Weblogic. The HttpServletResponse.encodeURL method does not work as expected. The issue I'm facing are as follows when cookies are disabled from the browser.
1) Request is sent to node-1 and Ignite creates a new session and when you call HttpServletResponse.encodeURL it appends the 'jsessionId' to the URL and is fine.
2) When you hit the node-2 with the encoded URL from node-1, Ignite is able to pull the session from the Ignite Cache and doesn't create a new session, but when you call encodeURL it doesn't append the 'jsessionid'. This is because the response object has a reference to the Weblogic's HTTPRequest/session objects and not the Ignite wrapper HTTPServleteRequestObjects and it doesn't append the sessionId to the URL.
The only way I can workaround this issue is to override the implementation of encodeURL and encodeRedirectURL methods which I don't prefer as it could be error prone.
Has anybody else faced this issue and found a good solution ?