特定のキャッシュに存在するすべてのテーブルをリストし、Apache Igniteサーバー上にあるすべてのキャッシュをリストする方法はありますか?Apache Ignite:すべてのテーブルとすべてのキャッシュを一覧表示する方法
----------------------------------アップデート----------- --------------- こんにちは、 次のコードを実行してキャッシュ名を確認し、キャッシュにあるすべてのテーブルを一覧表示しています。このプログラムリストは、サーバーに存在するすべてのキャッシュ名を出力します。ただし、テーブルのリストは空白のコレクションとして表示されます。一方、SQLのクエリの例では正常に動作しています。
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);
}
}
こんにちは@PavelTupitsyn、私を助けてくれてありがとう:あなたがここに見つけることができる
SHOW
コマンドについて詳細:すべてのテーブル名を取得するためには、
SHOW TABLES
コマンドを使用することができます。 Ignite.cacheNames()は正常に動作しています。しかし、ccfg.getQueryEntities()は私に空白のコレクションを与えて、テーブルに "Select文"を実行してテーブルをキャッシュに入れることができます。おかげで – Sushilあなたが実行する選択ステートメントは何ですか?どのようにキャッシュを開始しますか? –
基本的には、Selectステートメントを実行する前に、テーブルがキャッシュに存在することを確認します。 – Sushil