2017-10-04 2 views
0

처음으로 원격 캐시 서버를 시작할 때 출력을 제공하지만 두 번째 쿼리가 작동하지 않지만 클라이언트 노드에서 캐시 크기를 얻고 있습니다. 심지어 나는 cache.iterator() 통해 데이터를 가져올 수 있지만 SQL 쿼리를 통해 캐시 쿼리를 통해 얻지 않고 텍스트 쿼리를 통해 검색 할 수 있습니다.캐시 쿼리가 작동하지 않습니다.

코드 : -

List<Cache.Entry<PersonKey, Person>> as = cache.query(new SqlQuery<PersonKey, Person>(Person.class, sql). 
       setArgs("Manish")).getAll(); 

     System.out.println("data " + as); 
     System.out.println("size " + cache.size()); 
     Iterator<Cache.Entry<PersonKey, Person>> abc = cache.iterator(); 
     while (abc.hasNext()) { 
      Cache.Entry<PersonKey, Person> data = abc.next(); 
      System.out.println("data " + data); 
     } 
     for (Cache.Entry<PersonKey, Person> e : as) { 
      System.out.println(e.getValue().toString()); 
     } 

     SqlFieldsQuery qry = new SqlFieldsQuery("select firstname, lastname from Person where firstname='Manish'"); 

     try (FieldsQueryCursor<List<?>> cursor = cache.query(qry)) { 
      for (List<?> row : cursor) { 
       System.out.println("firstname:" + row.get(0) + ", lastname:" + row.get(1)); 
      } 
     } 

내 캐시 설정 : -

<import resource="classpath:cassandra/connection-settings.xml" /> 

<!-- Persistence settings for 'cache1' --> 
<bean id="cache1_persistence_settings" class="org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings"> 
    <constructor-arg type="org.springframework.core.io.Resource" value="classpath:persistence/primitive/persistence-settings-1.xml" /> 
</bean> 

<!-- Ignite configuration --> 
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> 
    <property name="cacheConfiguration"> 
     <list> 
      <!-- Configuring persistence for "cache1" cache -->  
      <bean class="org.apache.ignite.configuration.CacheConfiguration"> 
       <property name="name" value="cache1"/> 
       <property name="readThrough" value="false"/> 
       <property name="writeThrough" value="true"/> 
       <property name="writeBehindEnabled" value="true"/> 
       <property name="writeBehindFlushSize" value="2"/> 
       <!--     <property name="atomicityMode" value="TRANSACTIONAL"/> 
       <property name="backups" value="1"/>--> 
       <property name="cacheStoreFactory"> 
        <bean class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory"> 
         <property name="dataSourceBean" value="cassandraAdminDataSource" /> 
         <property name="persistenceSettingsBean" value="cache1_persistence_settings"/> 
        </bean> 
       </property> 
       <property name="queryEntities"> 
        <list> 
         <bean class="org.apache.ignite.cache.QueryEntity"> 
          <property name="keyType" value="com.manish.igniteexample.PersonKey"/> 
          <property name="valueType" value="com.manish.igniteexample.Person"/> 

          <property name="fields"> 
           <map> 
            <entry key="firstname" value="java.lang.String"/> 
            <entry key="lastname" value="java.lang.String"/> 
            <entry key="age" value="java.lang.Integer"/> 
            <entry key="married" value="java.lang.Boolean"/> 
            <entry key="birthDate" value="java.util.Date"/> 
            <entry key="phone" value="java.lang.Integer"/> 
           </map> 
          </property> 

          <property name="indexes"> 
           <list> 
            <bean class="org.apache.ignite.cache.QueryIndex"> 
             <constructor-arg value="firstname"/> 
            </bean> 
            <bean class="org.apache.ignite.cache.QueryIndex"> 
             <constructor-arg value="lastname"/> 
            </bean> 
           </list> 
          </property> 
         </bean> 
        </list> 
       </property> 
      </bean> 
     </list> 
    </property> 
    <property name="clientMode" value="false"/> 

내 출력 프로그램이 그림

first time execution에 도시 된 바와 같이, Second time execution

+0

인덱스를 비활성화 할 때 재생산합니까? – Denis

+0

Ignite 로그에 -DIGNITE_QUIET = false 시스템 속성을 제공 할 수 있습니까? – alexfedotov

+0

또한 "firstname = 'Manish'"조건없이 작동합니까? – Denis

답변

1

수정이 문제 내 POJO 클래스 수정, QuerySqlFiel의 name 속성 추가 d.

public class Person { 

    @QuerySqlField(name = "firstname" , index = true) 
    private String firstname; 

    @QuerySqlField(name = "last_name" , index = true) 
    private String lastname; 

    @QuerySqlField(name = "age") 
    private int age; 

    @QuerySqlField(name = "married") 
    private boolean married; 

    @QuerySqlField(name = "birth_date") 
    private Date birthDate; 

    @QuerySqlField(name = "phones") 
    private String phones; 

    /** 
    * getter and setter methods ... 
    */ 
}