echache 3 постоянный кеш уничтожен при перезапуске приложения - PullRequest
0 голосов
/ 24 января 2020

следующая проблема:

Я настроил jpa hibernation и ehcache 3.6 на использование постоянного кэша (всегда на dis c), потому что я хочу использовать кэш как долговременное решение при сбое базы данных.

кеш запущен, хиты работают.

теперь проблема:

при отключении tomcat через bin / shutdown. sh Я вижу в логах, что кеш закрыт правильно:

2020-01-24 11:40:57,885  INFO | SpringContextShutdownHook | o.s.scheduling.concurrent.ThreadPoolTaskScheduler       | Shutting down ExecutorService 'taskScheduler' 
2020-01-24 11:40:57,889  INFO | SpringContextShutdownHook | o.s.scheduling.concurrent.ThreadPoolTaskExecutor        | Shutting down ExecutorService 'applicationTaskExecutor' 
2020-01-24 11:40:57,893  INFO | SpringContextShutdownHook | o.s.orm.jpa.LocalContainerEntityManagerFactoryBean      | Closing JPA EntityManagerFactory for persistence unit 'vocapp202PU' 
2020-01-24 11:40:57,893 DEBUG | SpringContextShutdownHook | org.hibernate.internal.SessionFactoryImpl               | HHH000031: Closing 
2020-01-24 11:40:57,901 DEBUG | SpringContextShutdownHook | o.e.impl.internal.statistics.DefaultStatisticsService   | Cache removed de.firsttelecom.voice.blacklist_ng.model.vocapp202.FraudDetectionConfig 
2020-01-24 11:40:57,904 DEBUG | SpringContextShutdownHook | c.e.c.E.f.v.b.model.vocapp202.FraudDetectionConfig      | Close successful. 
2020-01-24 11:40:57,905  INFO | SpringContextShutdownHook | org.ehcache.core.EhcacheManager                         | Cache 'de.firsttelecom.voice.blacklist_ng.model.vocapp202.FraudDetectionConfig' removed from EhcacheManager. 
2020-01-24 11:40:57,905 DEBUG | SpringContextShutdownHook | o.e.impl.internal.statistics.DefaultStatisticsService   | Cache removed default-query-results-region 
2020-01-24 11:40:57,906 DEBUG | SpringContextShutdownHook | c.ehcache.core.Ehcache-default-query-results-region     | Close successful. 
2020-01-24 11:40:57,906  INFO | SpringContextShutdownHook | org.ehcache.core.EhcacheManager                         | Cache 'default-query-results-region' removed from EhcacheManager. 
2020-01-24 11:40:57,906 DEBUG | SpringContextShutdownHook | o.e.impl.internal.statistics.DefaultStatisticsService   | Cache removed de.firsttelecom.voice.blacklist_ng.model.vocapp202.Blacklist 
2020-01-24 11:40:57,912 DEBUG | SpringContextShutdownHook | c.e.c.E.f.voice.blacklist_ng.model.vocapp202.Blacklist  | Close successful. 
2020-01-24 11:40:57,912  INFO | SpringContextShutdownHook | org.ehcache.core.EhcacheManager                         | Cache 'de.firsttelecom.voice.blacklist_ng.model.vocapp202.Blacklist' removed from EhcacheManager. 
2020-01-24 11:40:57,912 DEBUG | SpringContextShutdownHook | o.e.impl.internal.statistics.DefaultStatisticsService   | Cache removed de.firsttelecom.voice.blacklist_ng.model.vocapp202.FraudScanningLock 
2020-01-24 11:40:57,913 DEBUG | SpringContextShutdownHook | c.e.c.E.f.v.b.model.vocapp202.FraudScanningLock         | Close successful. 
2020-01-24 11:40:57,914  INFO | SpringContextShutdownHook | org.ehcache.core.EhcacheManager                         | Cache 'de.firsttelecom.voice.blacklist_ng.model.vocapp202.FraudScanningLock' removed from EhcacheManager. 
2020-01-24 11:40:57,915 TRACE | SpringContextShutdownHook | org.hibernate.type.spi.TypeConfiguration$Scope          | Handling #sessionFactoryClosed from [org.hibernate.internal.SessionFactoryImpl@451aeca7] for TypeConfiguration 
2020-01-24 11:40:57,915 DEBUG | SpringContextShutdownHook | org.hibernate.type.spi.TypeConfiguration$Scope          | Un-scoping TypeConfiguration [org.hibernate.type.spi.TypeConfiguration$Scope@4d3154d9] from SessionFactory [org.hibernate.internal.SessionFactoryImpl@451aeca7] 
2020-01-24 11:40:57,916 DEBUG | SpringContextShutdownHook | o.h.service.internal.AbstractServiceRegistryImpl        | Implicitly destroying ServiceRegistry on de-registration of all child ServiceRegistries 
2020-01-24 11:40:57,918 DEBUG | SpringContextShutdownHook | o.e.impl.internal.statistics.DefaultStatisticsService   | Cache removed default-update-timestamps-region 
2020-01-24 11:40:57,919 DEBUG | SpringContextShutdownHook | c.ehcache.core.Ehcache-default-update-timestamps-region | Close successful. 
2020-01-24 11:40:57,919  INFO | SpringContextShutdownHook | org.ehcache.core.EhcacheManager                         | Cache 'default-update-timestamps-region' removed from EhcacheManager. 
2020-01-24 11:40:57,919 DEBUG | SpringContextShutdownHook | o.e.impl.internal.statistics.DefaultStatisticsService   | Cache removed de.firsttelecom.voice.blacklist_ng.model.asterisk.Cdr 
2020-01-24 11:40:57,920 DEBUG | SpringContextShutdownHook | c.e.c.E.f.voice.blacklist_ng.model.asterisk.Cdr         | Close successful. 
2020-01-24 11:40:57,920  INFO | SpringContextShutdownHook | org.ehcache.core.EhcacheManager                         | Cache 'de.firsttelecom.voice.blacklist_ng.model.asterisk.Cdr' removed from EhcacheManager. 
2020-01-24 11:40:57,920 DEBUG | SpringContextShutdownHook | o.e.impl.internal.statistics.DefaultStatisticsService   | Cache removed de.firsttelecom.voice.blacklist_ng.model.billing.Customer 
2020-01-24 11:40:57,921 DEBUG | SpringContextShutdownHook | c.e.c.E.f.voice.blacklist_ng.model.billing.Customer     | Close successful. 
2020-01-24 11:40:57,921  INFO | SpringContextShutdownHook | org.ehcache.core.EhcacheManager                         | Cache 'de.firsttelecom.voice.blacklist_ng.model.billing.Customer' removed from EhcacheManager. 
2020-01-24 11:40:57,921 DEBUG | SpringContextShutdownHook | org.ehcache.core.internal.service.ServiceLocator        | Stopping 17 Services... 
2020-01-24 11:40:57,923 DEBUG | SpringContextShutdownHook | o.e.impl.internal.statistics.DefaultStatisticsService   | Stopping service 
2020-01-24 11:40:57,927 DEBUG | SpringContextShutdownHook | org.ehcache.core.internal.service.ServiceLocator        | All Services successfully stopped, 17 Services in 6ms 
2020-01-24 11:40:57,927 DEBUG | SpringContextShutdownHook | org.ehcache.core.EhcacheManager                         | Close successful. 

кеш персистентности уничтожается при запуске приложения:

 2020-01-24 12:27:30,488 DEBUG | localhost-startStop-1 | org.ehcache.core.internal.service.ServiceLocator        | Starting 20 Services... 
2020-01-24 12:27:30,497 DEBUG | localhost-startStop-1 | o.e.impl.persistence.DefaultLocalPersistenceService     | RootDirectory Locked 
2020-01-24 12:27:30,498 DEBUG | localhost-startStop-1 | o.e.impl.internal.statistics.DefaultStatisticsService   | Starting service 
2020-01-24 12:27:30,499 DEBUG | localhost-startStop-1 | org.ehcache.core.internal.service.ServiceLocator        | All Services successfully started, 20 Services in 11ms 
2020-01-24 12:27:30,499 DEBUG | localhost-startStop-1 | org.ehcache.core.EhcacheManager                         | Creating Cache 'de.firsttelecom.voice.blacklist_ng.mode l.vocapp202.Blacklist' in EhcacheManager. 
2020-01-24 12:27:30,503 DEBUG | localhost-startStop-1 | o.e.impl.persistence.DefaultLocalPersistenceService     | Destroying file based persistence context for de.firsttelecom.voice.blacklist_ng.mode l.vocapp202.Blacklist 
2020-01-24 12:27:30,503 DEBUG | localhost-startStop-1 | org.ehcache.impl.persistence.FileUtils                  | Reusing /opt/as/APP/VOC-APP202/cache-data/file 
2020-01-24 12:27:30,503 DEBUG | localhost-startStop-1 | org.ehcache.impl.persistence.FileUtils                  | Created /opt/as/APP/VOC-APP202/cache-data/file/de%002efirsttelecom%002evoice%002eblacklist_ng%002emode%0020l%002evocapp202%0
02eBlacklist_213c52e456ea19681c98c9d83d67f88456c89c68 
2020-01-24 12:27:30,506 DEBUG | localhost-startStop-1 | o.e.i.i.spi.serialization.DefaultSerializationProvider  | Serializer for <java.lang.String> : org.ehcache.impl.serialization.StringSerializer@5a8a632d 
2020-01-24 12:27:30,508 DEBUG | localhost-startStop-1 | o.e.i.i.spi.serialization.DefaultSerializationProvider  | Serializer for <java.lang.String> : org.ehcache.impl.serialization.StringSerializer@62f8847f 
2020-01-24 12:27:30,524 DEBUG | localhost-startStop-1 | org.ehcache.impl.internal.spi.copy.DefaultCopyProvider  | Copier for <java.lang.String> : org.ehcache.impl.copy.IdentityCopier@62f7c3d7 
2020-01-24 12:27:30,525 DEBUG | localhost-startStop-1 | org.ehcache.impl.internal.spi.copy.DefaultCopyProvider  | Copier for <java.lang.String> : org.ehcache.impl.copy.IdentityCopier@1c40ef5 
2020-01-24 12:27:30,581 DEBUG | localhost-startStop-1 | org.ehcache.impl.persistence.FileUtils                  | Created /opt/as/APP/VOC-APP202/cache-data/file/de%002efirsttelecom%002evoice%002eblacklist_ng%002emode%0020l%002evocapp202%0
02eBlacklist_213c52e456ea19681c98c9d83d67f88456c89c68/offheap-disk-store 
2020-01-24 12:27:30,693 DEBUG | localhost-startStop-1 | c.e.c.E.f.voice.blacklist_ng.mode l.vocapp202.Blacklist | Initialize successful. 
2020-01-24 12:27:30,694  INFO | localhost-startStop-1 | org.ehcache.core.EhcacheManager                         | Cache 'de.firsttelecom.voice.blacklist_ng.mode l.vocapp202.Blacklist' created in EhcacheManager. 
2020-01-24 12:27:30,694 DEBUG | localhost-startStop-1 | org.ehcache.core.EhcacheManager                         | Creating Cache 'QueryCache' in EhcacheManager. 
2020-01-24 12:27:30,694 DEBUG | localhost-startStop-1 | o.e.impl.persistence.DefaultLocalPersistenceService     | Destroying file based persistence context for QueryCache 
2020-01-24 12:27:30,694 DEBUG | localhost-startStop-1 | org.ehcache.impl.persistence.FileUtils                  | Reusing /opt/as/APP/VOC-APP202/cache-data/file 
2020-01-24 12:27:30,694 DEBUG | localhost-startStop-1 | org.ehcache.impl.persistence.FileUtils                  | Created /opt/as/APP/VOC-APP202/cache-data/file/QueryCache_943123f908b2a7553fcb6f2ab57bafc1db8409b1 
2020-01-24 12:27:30,695 DEBUG | localhost-startStop-1 | o.e.i.i.spi.serialization.DefaultSerializationProvider  | Serializer for <java.util.ArrayList> : org.ehcache.impl.serialization.PlainJavaSerializer@749a1813 
2020-01-24 12:27:30,695 DEBUG | localhost-startStop-1 | o.e.i.i.spi.serialization.DefaultSerializationProvider  | Serializer for <java.util.ArrayList> : org.ehcache.impl.serialization.PlainJavaSerializer@5eb12dc3 
2020-01-24 12:27:30,695 DEBUG | localhost-startStop-1 | org.ehcache.impl.internal.spi.copy.DefaultCopyProvider  | Copier for <java.util.ArrayList> : org.ehcache.impl.copy.IdentityCopier@7ab9ea6b 
2020-01-24 12:27:30,695 DEBUG | localhost-startStop-1 | org.ehcache.impl.internal.spi.copy.DefaultCopyProvider  | Copier for <java.util.ArrayList> : org.ehcache.impl.copy.IdentityCopier@475fdef2 
2020-01-24 12:27:30,698 DEBUG | localhost-startStop-1 | org.ehcache.impl.persistence.FileUtils                  | Created /opt/as/APP/VOC-APP202/cache-data/file/QueryCache_943123f908b2a7553fcb6f2ab57bafc1db8409b1/offheap-disk-store 
2020-01-24 12:27:30,703 DEBUG | localhost-startStop-1 | class org.ehcache.core.Ehcache-QueryCache               | Initialize successful. 
2020-01-24 12:27:30,704  INFO | localhost-startStop-1 | org.ehcache.core.EhcacheManager                         | Cache 'QueryCache' created in EhcacheManager. 
2020-01-24 12:27:30,704 DEBUG | localhost-startStop-1 | org.ehcache.core.EhcacheManager                         | Creating Cache 'RepositoryCache' in EhcacheManager. 
2020-01-24 12:27:30,704 DEBUG | localhost-startStop-1 | o.e.impl.persistence.DefaultLocalPersistenceService     | Destroying file based persistence context for RepositoryCache 
2020-01-24 12:27:30,704 DEBUG | localhost-startStop-1 | org.ehcache.impl.persistence.FileUtils                  | Reusing /opt/as/APP/VOC-APP202/cache-data/file 
2020-01-24 12:27:30,704 DEBUG | localhost-startStop-1 | org.ehcache.impl.persistence.FileUtils                  | Created /opt/as/APP/VOC-APP202/cache-data/file/RepositoryCache_f0ffab0e8397d8c5d51aeb9b8de8dd50faac1f15 
2020-01-24 12:27:30,704 DEBUG | localhost-startStop-1 | o.e.i.i.spi.serialization.DefaultSerializationProvider  | Serializer for <java.lang.String> : org.ehcache.impl.serialization.StringSerializer@b894a0c 
2020-01-24 12:27:30,704 DEBUG | localhost-startStop-1 | o.e.i.i.spi.serialization.DefaultSerializationProvider  | Serializer for <java.util.ArrayList> : org.ehcache.impl.serialization.PlainJavaSerializer@4d608ccb 
2020-01-24 12:27:30,704 DEBUG | localhost-startStop-1 | org.ehcache.impl.internal.spi.copy.DefaultCopyProvider  | Copier for <java.lang.String> : org.ehcache.impl.copy.IdentityCopier@18502034 
2020-01-24 12:27:30,704 DEBUG | localhost-startStop-1 | org.ehcache.impl.internal.spi.copy.DefaultCopyProvider  | Copier for <java.util.ArrayList> : org.ehcache.impl.copy.IdentityCopier@78ac2782 
2020-01-24 12:27:30,706 DEBUG | localhost-startStop-1 | org.ehcache.impl.persistence.FileUtils                  | Created /opt/as/APP/VOC-APP202/cache-data/file/RepositoryCache_f0ffab0e8397d8c5d51aeb9b8de8dd50faac1f15/offheap-disk-store 
2020-01-24 12:27:30,712 DEBUG | localhost-startStop-1 | class org.ehcache.core.Ehcache-RepositoryCache          | Initialize successful. 
2020-01-24 12:27:30,712  INFO | localhost-startStop-1 | org.ehcache.core.EhcacheManager                         | Cache 'RepositoryCache' created in EhcacheManager. 
2020-01-24 12:27:30,712 DEBUG | localhost-startStop-1 | o.e.impl.internal.statistics.DefaultStatisticsService   | Moving from UNINITIALIZED to AVAILABLE 
2020-01-24 12:27:30,713 DEBUG | localhost-startStop-1 | o.e.impl.internal.statistics.DefaultStatisticsService   | Cache added de.firsttelecom.voice.blacklist_ng.mode l.vocapp202.Blacklist 
2020-01-24 12:27:30,727 DEBUG | localhost-startStop-1 | o.e.impl.internal.statistics.DefaultStatisticsService   | Cache added QueryCache 
2020-01-24 12:27:30,731 DEBUG | localhost-startStop-1 | o.e.impl.internal.statistics.DefaultStatisticsService   | Cache added RepositoryCache 
2020-01-24 12:27:30,734 DEBUG | localhost-startStop-1 | org.ehcache.core.EhcacheManager                         | Initialize successful. 

Есть ли в ehcache 3.6 возможность отключить уничтожение существующего кеша навсегда (если оно правильно закрыто, из c)?

Я читаю документацию здесь: https://www.ehcache.org/documentation/3.6/getting-started.html

Application.class

@SpringBootApplication
@EnableJpaAuditing
@EnableCaching
@Configuration
@EnableAutoConfiguration(exclude={CacheAutoConfiguration.class})
public class BlacklistngApplication {

    public static void main(String[] args) {
        SpringApplication.run(BlacklistngApplication.class, args);
    }

        @Bean
        public PersistentCacheManager cacheManager() {
            // configure and return an implementation of Spring's CacheManager SPI
            PersistentCacheManager persistentCacheManager = CacheManagerBuilder.newCacheManagerBuilder()             
            .with(CacheManagerBuilder.persistence(new File("/opt/as/APP/VOC-APP202/cache-data", "myData"))) 
            .withCache("persistent-cache", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
            ResourcePoolsBuilder.newResourcePoolsBuilder().disk(10, MemoryUnit.MB, true)) 
            )
            .build(true);
            return persistentCacheManager;
            //persistentCacheManager.close();
        }

но теперь я получаю:

java .lang.IllegalStateException: CacheResolver не указан и бин типа CacheManager не найден. Зарегистрируйте компонент CacheManager или удалите аннотацию @EnableCaching из своей конфигурации. в org.springframework.cache.interceptor.CacheAspectSupport.afterSingletonsInstantiated (CacheAspectSupport. java: 227)

Чего мне не хватает? Я хочу использовать ecache.xml для конфигурации.

...