I am able to create ignite cache using below code in java:
Ignition.setClientMode(true);
Set<String> set = new HashSet<>();
set.add("127.0.0.1:48500..48520");
discoveryMulticastIpFinder.setAddresses(set);
TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi();
discoverySpi.setIpFinder(discoveryMulticastIpFinder);
cfg.setDiscoverySpi(discoverySpi);
Ignite ignite = Ignition.start(cfg);
cacheConfiguration = new CacheConfiguration<>(CACHENAME);
cacheConfiguration.setName(CACHENAME);
cacheConfiguration.setSqlSchema("PUBLIC");
cacheConfiguration.setAtomicityMode(CacheAtomicityMode.ATOMIC);
cache = ignite.getOrCreateCache(cacheConfiguration).withKeepBinary();
System.out.println("All Available Cache on server : "+ignite.cacheNames());
ignite.cacheNames()
is printing all my created caches in the console. Now I want to create table like MYTABLE
in each cache.
I have tried :
cache.query(new SqlFieldsQuery("CREATE TABLE IF NOT EXISTS MYTABLE( TAG VARCHAR,TIMECREATED TIMESTAMP,VALUE DOUBLE, PRIMARY KEY(TAG,TIMECREATED) )"));
but this query creates only one table for all caches. I cannot write query something like one below for above scenario .
SELECT * FROM "CACHENAME".MYTABLE WHERE SOME_CONDITION = 1;
I have referred [1]:Apache Ignite : How to list all tables and all Caches question from stackoverflow but this seems to be not helping much to answer my question.
Collection<QueryEntity> entities = cacheConfiguration.getQueryEntities();
System.out.println("All available tables in "+CACHENAME+"cache : "+entities);
Using above code I can see cache name but no table is created inside of that cache.
Ultimately, I want to create one table MYTABLE
in each and every cache and I should be able to query using JAVA SQL_QUERY
method in ignite:
SELECT * FROM "CACHE_NAME".MYTABLE WHERE SOME_CONDITION = 1;
Your answers are really valued and appreciated.
Thanks.