2016-10-05 13 views
2

私はIgniteを初めて使用しており、実際にはigniteとやりとりするためのスプリングブートアプリケーションを使用しています。私はキャッシュを取り込んで着火させ、着火からキャッシュを通してキャッシュを取り込んだ。しかし、私はクエリAPIを介してキャッシュを取得しようとすると、私は次の例外を取得しています。igniteでクエリを実行するとCacheExceptionが発生する

[16:56:55,225][SEVERE][http-nio-8080-exec-2][[dispatcherServlet]] Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is javax.cache.CacheException: Indexing is disabled for cache: testCache. Use setIndexedTypes or setTypeMetadata methods on CacheConfiguration to enable.] with root cause javax.cache.CacheException: Indexing is disabled for cache: testCache. Use setIndexedTypes or setTypeMetadata methods on CacheConfiguration to enable. 

には、以下の私の実装のためのコードです:

私は上記の例外

@RequestMapping(value = "/query/cache", produces = "text/html") 
private String queryCache(Model model) { 
    try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) { 
     // Load cache with data from the database. 
     CacheConfiguration<Long, IgnitePerson> cfg = new CacheConfiguration<>("testCache"); 
     IgniteCache<Long, IgnitePerson> cache = ignite.getOrCreateCache(cfg); 
     SqlQuery<Long, IgnitePerson> query = new SqlQuery<>(IgnitePerson.class, "select * from IgnitePerson"); 
     List<Entry<Long, IgnitePerson>> list = cache.query(query).getAll(); 
     personsList = new ArrayList<>(); 
     for (Entry<Long, IgnitePerson> entry : list) { 
      personsList.add(entry.getValue()); 
     } 
     model.addAttribute("persons", personsList); 
    } 
    return "cacheresults"; 
} 

これは正常に動作し、私は発火

からキャッシュを取得していますに取得しています。このメソッドを呼び出すと
@RequestMapping(value = "/read/cache", produces = "text/html") 
private String readCache(Model model) { 
    try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) { 
     // Load cache with data from the database. 
     CacheConfiguration<Long, IgnitePerson> cfg = new CacheConfiguration<>("testCache"); 
     IgniteCache<Long, IgnitePerson> cache = ignite.getOrCreateCache(cfg); 
     Set<Long> keys = new TreeSet<>(); 
     keys.add((long) 1); 
     keys.add((long) 2); 
     Map<Long, IgnitePerson> map = cache.getAll(keys); 
     personsList = new ArrayList<>(map.values()); 
     model.addAttribute("persons", personsList); 
    } 
    return "cacheresults"; 
} 

答えて

2

SQLスキーマと索引付けを構成していません。これは、r unquery。詳細については、このページを参照してください:https://apacheignite.readme.io/docs/sql-queries

+0

あなたの返信ありがとうございます。私は 'cfg.setIndexedTypes(Long.class、IgnitePerson.class);をキャッシュ内のデータをキャッシュするためのキャッシュ構成に追加しました。私のIgnitePersonクラス変数は@QuerySqlFieldで注釈が付けられています。私はlibs内でignite-indexingモジュールを追加しました。 _ "ignite.bat /examples/config/example-ignite.xml" _を使用して1つのノードのみを起動しました。しかし、私はまだこの例外を取得しています。 'javax.cache.CacheException:クエリを実行できませんでした。すべてのIgniteノードのクラスパスに 'ignite-indexing'モジュールを追加してください ' – user2784095

+0

あなたはどこで入手できますか?サーバーまたはクライアントで?どこでも利用できるインデックスモジュールが必要であることに注意してください。 –

+0

私は間違っていない場合実際に私はクライアントでそれを得ています。私は春のブートアプリケーションを使用しており、APIを介して照会しようとしています。どのようにしてapiを介してクライアントにそのモジュールを追加できますか?私はこれを理解することができます、私たちがクラスタを起動する操作をしているとき、Java APIはクライアントのサーバーを起動し、クラスタ上でデータを取り込み/照会します。あれは正しいですか。?私が間違っている場合は修正してください。 – user2784095

関連する問題