У меня есть система с Spring Cache, в ней несколько загрузчиков классов. На самом деле я использую ehcache, и он отлично работает:
@Component
public class ObjectRepository extends MongoRepository<Object> {
// -------------------------- OTHER METHODS --------------------------
@Override
@Cacheable(value = "object", key = "#p0+#p1.name")
public Object get(String id, Class<? extends Object> clazz) {
return super.get(id, clazz);
}
@Override
@CacheEvict(value = "object", key = "#p0+#p1.name")
public void remove(String id, Class<? extends Object> clazz) {
super.remove(id, clazz);
}
@Override
@CacheEvict(value = "object", key = "#p0+#p0.class.name")
public void save(Object object) {
super.save(object);
}
}
Я пытаюсь изменить, чтобы зажечь:
@Bean
@SuppressWarnings("unchecked")
public CacheManager cacheManager() {
SpringCacheManager springCacheManager = new SpringCacheManager();
IgniteConfiguration igniteConfiguration = new IgniteConfiguration();
igniteConfiguration.setPeerClassLoadingEnabled(true);
igniteConfiguration.setIncludeEventTypes(org.apache.ignite.events.EventType.EVTS_TASK_EXECUTION);
springCacheManager.setConfiguration(igniteConfiguration);
return springCacheManager;
}
Из-за нескольких загрузчиков классов я получаю сообщение об ошибке, когда я делаю objectRepository.get("1", com.test.ClassInClassLoader1.class)
, все работает нормально, но после того, как я делаю objectRepository.get("2", com.test.ClassInClassLoader2.class)
, я получаю сообщение об ошибке:
Caused by: class org.apache.ignite.IgniteCheckedException: Encountered incompatible class loaders for cache [class1=com.test.ClassInClassLoader2, class2=com.test.ClassInClassLoader1]
at org.apache.ignite.internal.processors.cache.GridCacheDeploymentManager.registerClass(GridCacheDeploymentManager.java:656)
at org.apache.ignite.internal.processors.cache.GridCacheDeploymentManager.registerClass(GridCacheDeploymentManager.java:601)
at org.apache.ignite.internal.processors.cache.GridCacheDeploymentManager.registerClass(GridCacheDeploymentManager.java:590)
at org.apache.ignite.internal.processors.cache.GridCacheDeploymentManager.registerClasses(GridCacheDeploymentManager.java:573)
at org.apache.ignite.internal.processors.cache.GridCacheUtils.marshal(GridCacheUtils.java:950)
at org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessorImpl.marshal(IgniteCacheObjectProcessorImpl.java:94)
at org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl.marshal(CacheObjectPortableProcessorImpl.java:727)
at org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessorImpl$UserCacheObjectImpl.prepareForCache(IgniteCacheObjectProcessorImpl.java:343)
... 186 more
Я пытался использовать DeploymentMode.ISOLATED
и DeploymentMode.PRIVATE
, но они не работают с igniteConfiguration.setPeerClassLoadingEnabled(true)
, поэтому мне приходится вручную регистрировать все классы, и я не нашел, как это сделать с помощью LocalDeploymentSpi, я пытался использовать igniteConfiguration.getDeploymentSpi()
, но он нулевой, и когда я его создаю, как Ignite игнорирует классы там.