0

I have created a cache configuration template as per below code

IgniteConfiguration igniteCfg = new IgniteConfiguration();

try (Ignite ignite = Ignition.start(igniteCfg)) {
    CacheConfiguration cacheCfg = new CacheConfiguration("myCacheTemplate");

    cacheCfg.setBackups(2);
    cacheCfg.setCacheMode(CacheMode.PARTITIONED);

    // Register the cache template
    ignite.addCacheConfiguration(cacheCfg);
}

I created SQL table using CREATE TABLE command using above template successfully. I want to create another table with different configuration parameter values but failed. Since the configuration template register above can not be modified or removed. workaround is to register another template with new name and desired parameters. I want to know is there a way to remove or edit the existing registered templates in the apache ignite cluster

f_puras
  • 2,521
  • 4
  • 33
  • 38

1 Answers1

1

A cache template represents a static configuration of your cluster and is something that you won't like to adjust or remove. The main idea behind cache templates is that you can configure the same setup for a group of your caches in a way that you don't need to specify the parameters for each cache separately.

I suppose, yes, you need to create just another cache template if you need to create another set of tables with the common properties.

On the other hand, if all you need is to control CacheMode and Backups factor, you can set them explicitly inside your DDL's WITH clause:

CREATE TABLE IF NOT EXISTS Person (
  id int,
  city_id int,
  name varchar,
  age int,
  company varchar,
  PRIMARY KEY (id, city_id)
) WITH "template=partitioned,backups=1,affinity_key=city_id, key_type=PersonKey, value_type=MyPerson";

According to the docs:

TEMPLATE=<cache’s template name> - case-sensitive​ name of a cache template. A template is an instance of the CacheConfiguration class registered by calling Ignite.addCacheConfiguration(). Use predefined TEMPLATE=PARTITIONED or TEMPLATE=REPLICATED templates to create the cache with the corresponding replication mode

Alexandr Shapkin
  • 2,350
  • 1
  • 6
  • 10
  • Thanks a lot for the responce , you are right CacheMode and BackUp you can change but not all parameters like onheapCacheEnabled can be passed in CREATE TABLE command. – kashif sayeed Sep 14 '21 at 05:07
  • Another issue is you don't have a mean to know are there more templates already registered in the cluster, some developers may experience their changes are not getting registered as there template name already exits in the cluster. Registering same name template doesn't throw any exception. – kashif sayeed Sep 14 '21 at 05:22
  • Hmm, that's interesting, I was thinking that Ignite won't allow you to define a template if the same name is already taken. I'd like to check it and see if that's the expected behavior. – Alexandr Shapkin Sep 14 '21 at 08:33