ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veyroke <rodolfo.picha...@pega.com>
Subject Creating a distributed cache via cacheManager (JCACHE)
Date Wed, 30 Nov 2016 21:30:30 GMT
Hi Val,

My team is working on a cache component, we want to take advantage of
JSR-107. So instead of creating the cache via the Ignite.getOrCreate(..), a
*cacheManager * gets exposed instead.

 I followed your recommendation on 
http://stackoverflow.com/questions/35017564/can-i-use-the-jcache-api-for-distributed-caches-in-apache-ignite
<http://stackoverflow.com/questions/35017564/can-i-use-the-jcache-api-for-distributed-caches-in-apache-ignite>
 
to create a cache via JCACHE.

However, the cache gets created as a *local *cache, instead of a
*distributed *one. I guess i may be missing something in my
configuration/code.

My POC code looks as follows:

 /private static Cache<String, String> *configureJCache*(Ignite ignite) {	
    javax.cache.spi.CachingProvider cachingProvider =
Caching.getCachingProvider();

   CacheManager cacheMgr = cachingProvider.getCacheManager();
	      
   CacheConfiguration<String, String> cfg = new CacheConfiguration<>();
   cfg.setCacheMode(CacheMode.PARTITIONED);

   return cacheMgr.createCache("cache", cfg);
}/

The cluster gets programmatically configured, and it is started before
calling the above method as follows:

  /  Ignite ignite = configureAndStartCluster(arguments);
   mCache = *configureJCache*(ignite);/

IgniteVisor shows the following topology

/visor> top
Hosts: 1
+==================================================================================================================+
|  Int./Ext. IPs  |   Node ID8(@)    | Node Type |         OS          |
CPUs |          MACs           | CPU Load |
+==================================================================================================================+
| 0:0:0:0:0:0:0:1 | 1: D4515BF8(@n0) | Server    | Windows 7 amd64 6.1 | 8   
| A4:4E:31:CA:1C:0C       | 0.00 %   |/


but no cache available.

/visor> cache
(wrn) <visor>: No caches found./

I also started a two-server cluster, and put an element into the cache in
Node1. Node2 ,however, complains that the cache does not exist when trying
to get a value.

The Ignite version is 1.7, running on windows OS.  As mentioned earlier the
cluster get programmatically configured , no XML involved. The configuration
looks as follows;

/IgniteConfiguration cfg           = new IgniteConfiguration();
TcpDiscoverySpi discovery           = new TcpDiscoverySpi();
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();	
ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500","127.0.0.1:47501",
"127.0.0.1:47502" ));
discovery.setIpFinder(ipFinder);
cfg.setDiscoverySpi(discovery);/

Any pointer on what i may be missing would be greatly appreciated. 

Thank you
P.S I also validate the the Ignite cachingProvider was registered.

-Rodo




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Creating-a-distributed-cache-via-cacheManager-JCACHE-tp9310.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message