Is there any way to list all tables present in a specific Cache and list all caches present on a Apache Ignite Server?
----------------------------------UPDATED-------------------------- Hi, I am running following code to know Cache name and list all tables present in my cache. This program list outs all cache name present on server. However table listing is printed as blank collection. Meanwhile SQL query present in example is working fine.
public static void main(String[] args) throws Exception {
System.out.println("Run Spring example!!");
Ignition.setClientMode(true);
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setIncludeEventTypes( EVTS_CACHE);
cfg.setPeerClassLoadingEnabled(true);
TcpDiscoveryMulticastIpFinder discoveryMulticastIpFinder = new TcpDiscoveryMulticastIpFinder();
Set<String> set = new HashSet<>();
set.add("hostname:47500..47509");
discoveryMulticastIpFinder.setAddresses(set);
TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi();
discoverySpi.setIpFinder(discoveryMulticastIpFinder);
cfg.setDiscoverySpi(discoverySpi);
cfg.setPeerClassLoadingEnabled(true);
cfg.setIncludeEventTypes(EVTS_CACHE);
Ignite ignite = Ignition.start(cfg);
System.out.println("All Available Cache on server : "+ignite.cacheNames());
CacheConfiguration<String, BinaryObject> cacheConfiguration = new CacheConfiguration<>(CACHE_NAME);
Collection<QueryEntity> entities = cacheConfiguration.getQueryEntities();
System.out.println("All available tables in cache : "+entities);
cacheConfiguration.setIndexedTypes(String.class, BinaryObject.class);
//cacheConfiguration.setCacheMode(CacheMode.PARTITIONED);
IgniteCache<String, BinaryObject> cache = ignite.getOrCreateCache(cacheConfiguration).withKeepBinary();
System.out.println();
QueryCursor<List<?>> query = cache.query(new SqlFieldsQuery("select Field1 from table1 where Field1='TEST'"));
List<List<?>> all = query.getAll();
for (List<?> l : all) {
System.out.println(l);
}
}
To delete a cache from all cluster nodes, call the destroy() method. Ignite ignite = Ignition. ignite(); IgniteCache<Long, String> cache = ignite. cache("myCache"); cache.
In-memory cache is a storage layer placed between applications and databases. The cache keeps your hot data in memory to offload existing databases and accelerate applications.
Is Ignite A NoSQL Database? Just like other NoSQL databases, Ignite is highly available and horizontally scalable. However, unlike other NoSQL databases, Ignite supports SQL and ACID transactions across multiple cluster nodes.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With