Okay Here is my Ignite Server cfg code.
@Bean("serverCfg")
public IgniteConfiguration createConfiguration() throws Exception {
IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteInstanceName("CcPlatformUserRolesOrganizationAssociationServer");
cfg.setSqlSchemas("public");
TcpDiscoverySpi discovery = new TcpDiscoverySpi();
TcpDiscoveryMulticastIpFinder ipFinder = new
TcpDiscoveryMulticastIpFinder();
ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47510"));
discovery.setIpFinder(ipFinder);
cfg.setDiscoverySpi(discovery);
// cfg.setPeerClassLoadingEnabled(true);
cfg.setCacheConfiguration(cacheOrganizationsCache()
,
cacheRolesCache(), cacheUsersCache(),
cacheUsersRolesCache(), cacheGroupsCache(),
cacheGroupusersCache(), cacheGlobalPermissionsCache(),
cacheTemplatesCache(), cachePasswordsCache()
);
return cfg;
}
And Here is my Ignite Client Code.
@Bean
public Ignite createConfiguration() throws Exception {
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setClientMode(true); cfg.setIgniteInstanceName("CcPlatformUserRolesOrganizationAssociationServerClient");
TcpDiscoverySpi discovery = new TcpDiscoverySpi();
TcpDiscoveryMulticastIpFinder ipFinder = new
TcpDiscoveryMulticastIpFinder();
ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47510"));
discovery.setIpFinder(ipFinder);
cfg.setDiscoverySpi(discovery);
cfg.setCacheConfiguration( cacheOrganizationsCache(), cacheRolesCache(),
cacheUsersCache(), cacheUsersRolesCache(), cacheGroupsCache(),
cacheGroupusersCache() );
Ignite ignite = Ignition.start(cfg);
ignite.cluster().active(true);
return ignite;
}
So My question is do I had to have same piece of code that contains all cache configurations including data source at client side also? How to avoid this code redundancy?
You don't have to supply all cache configurations on client. Once first server node comes up, it will start all caches, other nodes will be able to use them regardless whether they have them in their own configs or not. Any new caches will be created when nodes join. Cache configurations will never be changed on join of new nodes with differing cfgs of existing caches.