2016-12-22 2 views
1

데이터베이스에 asyn 데이터를 쓰도록 CacheStore를 구현 중입니다. 응용 프로그램 내부에서 Ignite를 "서버"로 실행하면서 데이터가 데이터베이스에 저장되는 동안 코드가 올바르게 작동합니다.서버 측에서 CacheStore 구현이 ClassNotFoundException을 발생 시킴

문제가있는 시나리오 : 원격 노드를 "클라이언트"로 서버 및 응용 프로그램으로 실행 중일 때 클라이언트 노드가 이미 시작된 동안 서버 노드가 ClassNotFoundException을 throw합니다.

서버

<bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> 
    <property name="metricsLogFrequency" value="0"/> 
    <property name="peerClassLoadingEnabled" value="true"/> 
    <property name="marshaller"> 
      <bean class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller"> 
      <!-- Set to false to allow non-serializable objects in examples, default is true. --> 
      <property name="requireSerializable" value="false"/> 
     </bean> 
     </property> 

    <property name="discoverySpi"> 
     <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> 
      <property name="ipFinder"> 
      <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.zk.TcpDiscoveryZookeeperIpFinder"> 
       <property name="zkConnectionString" value="localhost:2181"/> 
      </bean> 
      </property> 
     </bean> 
    </property> 
</bean> 

클라이언트 : : 이제

CacheConfiguration cacheConfiguration = new CacheConfiguration(); 
cacheConfiguration.setName(name); 
cacheConfiguration.setBackups(backup); 
cacheConfiguration.setRebalanceMode(CacheRebalanceMode.SYNC); 
cacheConfiguration.setCacheMode(CacheMode.PARTITIONED); 
LruEvictionPolicy evictionPolicy = new LruEvictionPolicy(); 
evictionPolicy.setMaxSize(maxEntries); 
cacheConfiguration.setEvictionPolicy(evictionPolicy); 
cacheConfiguration.setEvictSynchronized(true); 
cacheConfiguration.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(duration)); 
cacheConfiguration.setStartSize(100*1024*1024); 
cacheConfiguration.setReadThrough(true); 
cacheConfiguration.setWriteThrough(true); 
cacheConfiguration.setWriteBehindEnabled(true); 
cacheConfiguration.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); 
cacheConfiguration.setCacheStoreFactory(new FactoryBuilder.SingletonFactory<CacheStore>(cacheStore)); 



IgniteConfiguration igniteConfiguration = new IgniteConfiguration(); 
igniteConfiguration.setPeerClassLoadingEnabled(true); 
TcpDiscoverySpi tcpDiscoverySpi = new TcpDiscoverySpi(); 
TcpDiscoveryZookeeperIpFinder ipFinder = new TcpDiscoveryZookeeperIpFinder(); 
ipFinder.setZkConnectionString(zookeeperConString); 
tcpDiscoverySpi.setIpFinder(ipFinder); 

OptimizedMarshaller marshaller = new OptimizedMarshaller(); 
marshaller.setRequireSerializable(false); 

igniteConfiguration. 
       setCacheConfiguration(cacheConfiguration). 
       setClientMode(isClient); 
igniteConfiguration.setDiscoverySpi(tcpDiscoverySpi); 
igniteConfiguration.setMarshaller(marshaller). 
       setGridName(gridName). 
       setMetricsLogFrequency(0); 
SpringCacheManager springCacheManager = new SpringCacheManager(); 
springCacheManager.setConfiguration(igniteConfiguration); 

, 나는 내가 peerclassloading를 활성화하므로 서버 노드에 CacheStore을 배포 할 해달라고 다음

내 구성입니다. 하지만 동일한 예외가 발생하여 인터넷에서 확인하고 트랜잭션에 대한 atomicitymode를 변경하여 클라이언트의 CacheStore가 매번 사용됩니다. 하지만 여전히 같은 문제에 직면 해 있습니다.

+0

코드에서 OptimizedMarshaller를 사용하고 있지만 BinaryMarshaller와 BinaryMarshaller도 있습니다. 서버 노드에 유형이 필요하지 않습니다. – kuaw26

답변

0

CacheConfiguration에있는 모든 클래스가 모든 노드에서 사용 가능해야합니다. P2P 클래스 로딩은 CacheStore에서 작동하지 않습니다. 클래스를 수동으로 배포해야합니다.

+0

http://apache-ignite-users.70518.x6.nabble.com/CacheStore-being-serialized-to-client-td1931.html –

+0

그래서 두 가지 다른 빌드를 만들어야합니다. 즉 클라이언트를 빌드하고 다른 캐시를 업데이트해야합니다. 데이터베이스를 업데이트하기 위해 서버를 빌드 한 다음 다른 Tomcat 서버에 배포하십시오. 아니면 점화의 lib 디렉토리에 내 항아리를 배치 작동합니까? –

+0

\ libs 폴더에 항아리를 넣어야합니다. –