Hi,

You can create a cache via CacheManager instance using Ignite
CacheConfiguration or MutableConfiguration:

public class ExampleNodeStartup {
    public static void main(String[] args) throws Exception {
        CachingProvider provider = Caching.getCachingProvider();
        CacheManager manager = provider.getCacheManager();

        Cache c1 = manager.createCache("my-test-cache-1", new
MutableConfiguration<>());

        CacheConfiguration cfg = new
CacheConfiguration<>("my-test-cache-2");
        cfg.setCacheMode(CacheMode.REPLICATED);
        cfg.setBackups(2);

        Cache c2 = manager.createCache(cfg.getName(), cfg);
    }
}

Moreover, you can provide your own Ignite configuration as well:

public class ExampleNodeStartup {
    public static void main(String[] args) throws Exception {
        URI igniteCfg =
"//projects//ignite//examples//config//example-cache.xml";

        CachingProvider provider = Caching.getCachingProvider();
        CacheManager manager = provider.getCacheManager(igniteCfg,
ExampleNodeStartup.class.getClassLoader());

        Cache default = manager.getCache("default");
    }
}

All these examples work as expected, without any errors/exceptions.

So, I owuld suggest creating a small project, that reproduces the issue you
mentioned, and upload it on GitHub
so that the community can take a look at this.

Thanks.

вт, 7 авг. 2018 г. в 20:45, daya airody <[email protected]>:

> Hi slava,
>
> thanks for your comments. I am creating the cache directly using JCache API
> below:
> -------------------
>     @Bean
>     public JCacheManagerCustomizer cacheManagerCustomizer() {
>         return cm -> {
>             Configuration<Object, Object> cacheConfiguration =
> createCacheConfiguration();
>
>             if (cm.getCache("users") == null)
>                 cm.createCache("users", cacheConfiguration);
>             if (cm.getCache("cannedReports") == null)
>                 cm.createCache("cannedReports",
> createCustomCacheConfiguration());
>         };
>     }
> ----------------------
> Even though I have created these caches using JCache API ( and not through
> Ignite API), when I restart my application, cache.getCacheManager() is
> returning null within JCacheMetrics constructor. This is a blocker.
>
> Any help is appreciated.
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Reply via email to