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

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?

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?

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.

How to set proxy in keystone js

I am new in Keystone JS and I observed there is no much support available on google for it.
I am uploading files to S3 on AWS, but I am facing timeout issue, I figured out that, I need to set proxy for it.
But I don't know how to set proxy in keystone, I searched on its site but found nothing.
Note:: I am using keystone.storage and keystone-storage-adapter-s3
The package keystone-storage-adapter-s3 that you are using is using knox, and knox's proxy support proxy was added in pull 137.
After make sure you have updated knox, you can add your proxy options to
var storage = new keystone.Storage({
adapter: require('keystone-storage-adapter-s3'),
s3: {
key: 's3-key', // required; defaults to process.env.S3_KEY
secret: 'secret', // required; defaults to process.env.S3_SECRET
bucket: 'mybucket', // required; defaults to process.env.S3_BUCKET
proxy: '<your proxy>',
...
More information:
Setting proxy server for connections in Knox
https://www.npmjs.com/package/keystone-storage-adapter-s3
https://github.com/keystonejs/keystone-storage-adapter-s3/blob/master/index.js
Note: I have not try this but I just provide the information based on the source code trace, good luck.

How to modify cache settings on a running ignite instance?

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.

Retrieving Web App connection strings using ConfigurationBuilder

We are storing some of our sensitive keys and connection strings in the Connection strings section under the Web App application settings:
We retrieve configuration settings using the ConfigurationBuilder:
Configuration = new ConfigurationBuilder()
.SetBasePath(environment.ContentRootPath)
.AddEnvironmentVariables()
.Build();
I would have expected AddEnvironmentVariables() to pick up these connection strings, but it doesn't. Note that this does work if you set these values as "App settings" in the Web App.
Under closer inspection (using the Kudu console) I found that the environment variables being set for these connections strings have CUSTOMCONNSTR_ prefixed to the key name:
CUSTOMCONNSTR_MongoDb:ConnectionString=...
CUSTOMCONNSTR_Logging:ConnectionString=...
CUSTOMCONNSTR_ApplicationInsights:ChronosInstrumentationKey=...
How should I now read in these connection strings using the ConfigurationBuilder?
EDIT:
I found that a handy AddEnvironmentVariables overload exists with a prefix parameter, described as:
// prefix:
// The prefix that environment variable names must start with. The prefix will be
// removed from the environment variable names.
But adding .AddEnvironmentVariables("CUSTOMCONNSTR_") to the configuration builder doesn't work either!
But adding .AddEnvironmentVariables("CUSTOMCONNSTR_") to the configuration builder doesn't work either!
AddEnvironmentVariables with prefix just add a limit for environment variables which must with the specified prefix. It will not change the environment variables.
To retrieve value from connection string configuration, you could use code as following.
Configuration.GetConnectionString("MongoDb:ConnectionString");
For hierarchical structure setting, please add it to app settings instead of connection strings on Azure portal.
How should I now read in these connection strings using the ConfigurationBuilder?
As a workaround, you could re-add EnvironmentVariable and rebuild the ConfigurationBuilder after you get the connection string. Code below is for your reference.
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
//Add EnvironmentVariable and rebuild ConfigurationBuilder
Environment.SetEnvironmentVariable("MongoDb:ConnectionString", Configuration.GetConnectionString("MongoDb:ConnectionString"));
builder.AddEnvironmentVariables();
Configuration = builder.Build();
}
It should just work, and it does for me in my sample app: https://github.com/davidebbo-test/AspNetCoreDemo. Specifically:
MyDatabase connection string is defined here.
It is used here.
If you define MyDatabase conn string in Azure Portal, you will see the new value at runtime (go to the About page).
So start by verifying that mine works, and try to see what you may be doing differently. You should never need to make any assumptions on the CUSTOMCONNSTR_ prefix!