Apache Ignite : How to list all tables and all Caches
Get all cache names: Ignite.cacheNames()
. Then use Ignite.cache(String)
to get the cache instance.
Get SQL tables:
CacheConfiguration ccfg = cache.getConfiguration(CacheConfiguration.class);
Collection<QueryEntity> entities = ccfg.getQueryEntities();
Each query entity represents a table.
You can read using h2 query. SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA is the cache name
ClientConfiguration cfg = new ClientConfiguration().setAddresses(host+":"+port).
setUserName(username).setUserPassword(pwd);
private static IgniteClient igniteClient = Ignition.startClient(cfg);
private static ClientCache<Integer, String>
cache=igniteClient.getOrCreateCache(cacheName);
QueryCursor<List<?>> cursor =cache.query(new SqlFieldsQuery("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='"+cacheName+"'"));
for (List<?> row : cursor) {
System.out.println(row.get(0));
}