net.sf.ehcache.config.Configuration Java Examples
The following examples show how to use
net.sf.ehcache.config.Configuration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProvisionedDomainAccessControlStoreTest.java From joynr with Apache License 2.0 | 6 votes |
private Injector getInjector(Properties customProperties) { Injector injector = Guice.createInjector(new JoynrPropertiesModule(customProperties), new AbstractModule() { @Override protected void configure() { bind(DomainAccessControlProvisioning.class).to(StaticDomainAccessControlProvisioning.class); bind(DomainAccessControlStore.class).to(DomainAccessControlStoreEhCache.class); } @Provides CacheManager provideCacheManager() { Configuration configuration = new Configuration(); configuration.setName("GDACEhCacheManager"); return CacheManager.create(configuration); } }); return injector; }
Example #2
Source File: WebEhCacheManagerFacotryBean.java From Lottery with GNU General Public License v2.0 | 6 votes |
public void afterPropertiesSet() throws IOException, CacheException { log.info("Initializing EHCache CacheManager"); Configuration config = null; if (this.configLocation != null) { config = ConfigurationFactory .parseConfiguration(this.configLocation.getInputStream()); if (this.diskStoreLocation != null) { DiskStoreConfiguration dc = new DiskStoreConfiguration(); dc.setPath(this.diskStoreLocation.getFile().getAbsolutePath()); try { config.addDiskStore(dc); } catch (ObjectExistsException e) { log.warn("if you want to config distStore in spring," + " please remove diskStore in config file!", e); } } } if (config != null) { this.cacheManager = new CacheManager(config); } else { this.cacheManager = new CacheManager(); } if (this.cacheManagerName != null) { this.cacheManager.setName(this.cacheManagerName); } }
Example #3
Source File: EhcacheManager.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
public static void init() { Configuration config = ConfigurationFactory.parseConfiguration(); config.setClassLoader(ehcacheClassloader); String maxBytesLocalHeap = JbootConfigManager.me().getConfigValue("jpress.ehcache.maxBytesLocalHeap"); config.setMaxBytesLocalHeap(StrUtil.obtainDefaultIfBlank(maxBytesLocalHeap, "100M")); String maxBytesLocalDisk = JbootConfigManager.me().getConfigValue("jpress.ehcache.maxBytesLocalDisk"); config.setMaxBytesLocalDisk(StrUtil.obtainDefaultIfBlank(maxBytesLocalDisk, "5G")); CacheConfiguration cacheConfiguration = new CacheConfiguration(); cacheConfiguration.setClassLoader(ehcacheClassloader); config.defaultCache(cacheConfiguration); CacheManager.create(config); }
Example #4
Source File: GenerateEhCacheDefaultConfig.java From dubbo-plus with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws IllegalAccessException { CacheManager manager = CacheManager.create(); Configuration configuration = manager.getConfiguration(); GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); Object object= poolConfig; Field[] fields = object.getClass().getDeclaredFields(); String prefix="cache.ehcache."; for(Field field:fields){ field.setAccessible(true); Method method = getSetMethod(object.getClass(),field); if(method!=null&& CacheConfig.checkIsBasicType(field.getType())){ System.out.println("#默认值"+field.get(object)); System.out.println(prefix+field.getName()); } } }
Example #5
Source File: EhcacheMemoryService.java From sakai with Educational Community License v2.0 | 6 votes |
@Override public Properties getProperties() { Configuration ec = cacheManager.getConfiguration(); Properties p = new Properties(); p.put("name", ec.getName()); p.put("source", ec.getConfigurationSource().toString()); p.put("timeoutSeconds", ec.getDefaultTransactionTimeoutInSeconds()); p.put("maxBytesDisk", ec.getMaxBytesLocalDisk()); p.put("maxBytesHeap", ec.getMaxBytesLocalHeap()); p.put("maxDepth", ec.getSizeOfPolicyConfiguration().getMaxDepth()); p.put("defaultCacheMaxEntries", ec.getDefaultCacheConfiguration().getMaxEntriesLocalHeap()); p.put("defaultCacheTimeToIdleSecs", ec.getDefaultCacheConfiguration().getTimeToIdleSeconds()); p.put("defaultCacheTimeToLiveSecs", ec.getDefaultCacheConfiguration().getTimeToLiveSeconds()); p.put("defaultCacheEternal", ec.getDefaultCacheConfiguration().isEternal()); return p; }
Example #6
Source File: EhcacheMemoryService.java From sakai with Educational Community License v2.0 | 6 votes |
@Override public Properties getProperties() { Configuration ec = cacheManager.getConfiguration(); Properties p = new Properties(); p.put("name", ec.getName()); p.put("source", ec.getConfigurationSource().toString()); p.put("timeoutSeconds", ec.getDefaultTransactionTimeoutInSeconds()); p.put("maxBytesDisk", ec.getMaxBytesLocalDisk()); p.put("maxBytesHeap", ec.getMaxBytesLocalHeap()); p.put("maxDepth", ec.getSizeOfPolicyConfiguration().getMaxDepth()); p.put("defaultCacheMaxEntries", ec.getDefaultCacheConfiguration().getMaxEntriesLocalHeap()); p.put("defaultCacheTimeToIdleSecs", ec.getDefaultCacheConfiguration().getTimeToIdleSeconds()); p.put("defaultCacheTimeToLiveSecs", ec.getDefaultCacheConfiguration().getTimeToLiveSeconds()); p.put("defaultCacheEternal", ec.getDefaultCacheConfiguration().isEternal()); return p; }
Example #7
Source File: EhCacheManagerFactoryBean.java From entando-components with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void afterPropertiesSet() throws IOException, CacheException { logger.info("Initializing EhCache CacheManager"); InputStream is = this.extractEntandoConfig(); try { // A bit convoluted for EhCache 1.x/2.0 compatibility. // To be much simpler once we require EhCache 2.1+ if (this.cacheManagerName != null) { if (this.shared && createWithConfiguration == null) { // No CacheManager.create(Configuration) method available before EhCache 2.1; // can only set CacheManager name after creation. this.cacheManager = (is != null ? CacheManager.create(is) : CacheManager.create()); this.cacheManager.setName(this.cacheManagerName); } else { Configuration configuration = (is != null ? ConfigurationFactory.parseConfiguration(is) : ConfigurationFactory.parseConfiguration()); configuration.setName(this.cacheManagerName); if (this.shared) { this.cacheManager = (CacheManager) ReflectionUtils.invokeMethod(createWithConfiguration, null, configuration); } else { this.cacheManager = new CacheManager(configuration); } } } else if (this.shared) { // For strict backwards compatibility: use simplest possible constructors... this.cacheManager = (is != null ? CacheManager.create(is) : CacheManager.create()); } else { this.cacheManager = (is != null ? new CacheManager(is) : new CacheManager()); } } finally { if (is != null) { is.close(); } } }
Example #8
Source File: EhCacheManagerFactoryBean.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public void afterPropertiesSet() throws CacheException { logger.info("Initializing EhCache CacheManager"); Configuration configuration = (this.configLocation != null ? EhCacheManagerUtils.parseConfiguration(this.configLocation) : ConfigurationFactory.parseConfiguration()); if (this.cacheManagerName != null) { configuration.setName(this.cacheManagerName); } if (this.shared) { // Old-school EhCache singleton sharing... // No way to find out whether we actually created a new CacheManager // or just received an existing singleton reference. this.cacheManager = CacheManager.create(configuration); } else if (this.acceptExisting) { // EhCache 2.5+: Reusing an existing CacheManager of the same name. // Basically the same code as in CacheManager.getInstance(String), // just storing whether we're dealing with an existing instance. synchronized (CacheManager.class) { this.cacheManager = CacheManager.getCacheManager(this.cacheManagerName); if (this.cacheManager == null) { this.cacheManager = new CacheManager(configuration); } else { this.locallyManaged = false; } } } else { // Throwing an exception if a CacheManager of the same name exists already... this.cacheManager = new CacheManager(configuration); } }
Example #9
Source File: EhCacheCacheManagerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Before public void setup() { nativeCacheManager = new CacheManager(new Configuration().name("EhCacheCacheManagerTests") .defaultCache(new CacheConfiguration("default", 100))); addNativeCache(CACHE_NAME); cacheManager = new EhCacheCacheManager(nativeCacheManager); cacheManager.setTransactionAware(false); cacheManager.afterPropertiesSet(); transactionalCacheManager = new EhCacheCacheManager(nativeCacheManager); transactionalCacheManager.setTransactionAware(true); transactionalCacheManager.afterPropertiesSet(); }
Example #10
Source File: EhCacheCacheTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Before public void setUp() { cacheManager = new CacheManager(new Configuration().name("EhCacheCacheTests") .defaultCache(new CacheConfiguration("default", 100))); nativeCache = new net.sf.ehcache.Cache(new CacheConfiguration(CACHE_NAME, 100)); cacheManager.addCache(nativeCache); cache = new EhCacheCache(nativeCache); }
Example #11
Source File: CacheFactory.java From subsonic with GNU General Public License v3.0 | 5 votes |
public void afterPropertiesSet() throws Exception { Configuration configuration = ConfigurationFactory.parseConfiguration(); // Override configuration to make sure cache is stored in Subsonic home dir. File cacheDir = new File(SettingsService.getSubsonicHome(), "cache"); configuration.getDiskStoreConfiguration().setPath(cacheDir.getPath()); cacheManager = CacheManager.create(configuration); }
Example #12
Source File: CacheService.java From lutece-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Gets the unique instance of the CacheService * * @return The unique instance of the CacheService */ public static synchronized CacheService getInstance( ) { if ( _singleton == null ) { _singleton = new CacheService( ); _singleton.init( ); Configuration configuration = ConfigurationFactory.parseConfiguration( ); configuration.setName( LUTECE_CACHEMANAGER_NAME ); _manager = CacheManager.create( configuration ); } return _singleton; }
Example #13
Source File: AccessControlClientModule.java From joynr with Apache License 2.0 | 5 votes |
@Provides @Singleton public CacheManager provideCacheManager() { Configuration configuration = new Configuration(); configuration.setName("LDACEhCacheManager"); configuration.setUpdateCheck(false); return CacheManager.create(configuration); }
Example #14
Source File: PipelineSqlMapDao.java From gocd with Apache License 2.0 | 5 votes |
private static Ehcache createCacheIfRequired(String cacheName) { final CacheManager instance = CacheManager.newInstance(new Configuration().name(cacheName)); synchronized (instance) { if (!instance.cacheExists(cacheName)) { instance.addCache(new Cache(cacheConfiguration(cacheName))); } return instance.getCache(cacheName); } }
Example #15
Source File: JobInstanceSqlMapDao.java From gocd with Apache License 2.0 | 5 votes |
private static Ehcache createCacheIfRequired(String cacheName) { final CacheManager instance = CacheManager.newInstance(new Configuration().name(cacheName)); synchronized (instance) { if (!instance.cacheExists(cacheName)) { instance.addCache(new net.sf.ehcache.Cache(cacheConfiguration(cacheName))); } return instance.getCache(cacheName); } }
Example #16
Source File: GoCacheFactory.java From gocd with Apache License 2.0 | 5 votes |
@Bean(name = "goCache") public GoCache createCache() { CacheManager cacheManager = CacheManager.newInstance(new Configuration().name(getClass().getName())); Cache cache = new Cache(cacheConfiguration); cacheManager.addCache(cache); return new GoCache(cache, transactionSynchronizationManager); }
Example #17
Source File: IbisCacheManager.java From iaf with Apache License 2.0 | 5 votes |
private IbisCacheManager() { Configuration cacheManagerConfig = new Configuration(); String cacheDir = AppConstants.getInstance().getResolvedProperty(CACHE_DIR_KEY); if (StringUtils.isNotEmpty(cacheDir)) { log.debug("setting cache directory to ["+cacheDir+"]"); DiskStoreConfiguration diskStoreConfiguration = new DiskStoreConfiguration(); diskStoreConfiguration.setPath(cacheDir); cacheManagerConfig.addDiskStore(diskStoreConfiguration); } CacheConfiguration defaultCacheConfig = new CacheConfiguration(); cacheManagerConfig.addDefaultCache(defaultCacheConfig); cacheManager= new CacheManager(cacheManagerConfig); }
Example #18
Source File: GlobalDomainAccessControllerModule.java From joynr with Apache License 2.0 | 5 votes |
@Provides @Singleton CacheManager provideCacheManager() { Configuration configuration = new Configuration(); configuration.setName("GDACEhCacheManager"); return CacheManager.create(configuration); }
Example #19
Source File: EhCacheManagerFactoryBean.java From spring-analysis-note with MIT License | 5 votes |
@Override public void afterPropertiesSet() throws CacheException { if (logger.isInfoEnabled()) { logger.info("Initializing EhCache CacheManager" + (this.cacheManagerName != null ? " '" + this.cacheManagerName + "'" : "")); } Configuration configuration = (this.configLocation != null ? EhCacheManagerUtils.parseConfiguration(this.configLocation) : ConfigurationFactory.parseConfiguration()); if (this.cacheManagerName != null) { configuration.setName(this.cacheManagerName); } if (this.shared) { // Old-school EhCache singleton sharing... // No way to find out whether we actually created a new CacheManager // or just received an existing singleton reference. this.cacheManager = CacheManager.create(configuration); } else if (this.acceptExisting) { // EhCache 2.5+: Reusing an existing CacheManager of the same name. // Basically the same code as in CacheManager.getInstance(String), // just storing whether we're dealing with an existing instance. synchronized (CacheManager.class) { this.cacheManager = CacheManager.getCacheManager(this.cacheManagerName); if (this.cacheManager == null) { this.cacheManager = new CacheManager(configuration); } else { this.locallyManaged = false; } } } else { // Throwing an exception if a CacheManager of the same name exists already... this.cacheManager = new CacheManager(configuration); } }
Example #20
Source File: EhCacheManagerFactoryBean.java From java-technology-stack with MIT License | 5 votes |
@Override public void afterPropertiesSet() throws CacheException { if (logger.isInfoEnabled()) { logger.info("Initializing EhCache CacheManager" + (this.cacheManagerName != null ? " '" + this.cacheManagerName + "'" : "")); } Configuration configuration = (this.configLocation != null ? EhCacheManagerUtils.parseConfiguration(this.configLocation) : ConfigurationFactory.parseConfiguration()); if (this.cacheManagerName != null) { configuration.setName(this.cacheManagerName); } if (this.shared) { // Old-school EhCache singleton sharing... // No way to find out whether we actually created a new CacheManager // or just received an existing singleton reference. this.cacheManager = CacheManager.create(configuration); } else if (this.acceptExisting) { // EhCache 2.5+: Reusing an existing CacheManager of the same name. // Basically the same code as in CacheManager.getInstance(String), // just storing whether we're dealing with an existing instance. synchronized (CacheManager.class) { this.cacheManager = CacheManager.getCacheManager(this.cacheManagerName); if (this.cacheManager == null) { this.cacheManager = new CacheManager(configuration); } else { this.locallyManaged = false; } } } else { // Throwing an exception if a CacheManager of the same name exists already... this.cacheManager = new CacheManager(configuration); } }
Example #21
Source File: EhCacheCacheManagerTests.java From spring-analysis-note with MIT License | 5 votes |
@Before public void setup() { nativeCacheManager = new CacheManager(new Configuration().name("EhCacheCacheManagerTests") .defaultCache(new CacheConfiguration("default", 100))); addNativeCache(CACHE_NAME); cacheManager = new EhCacheCacheManager(nativeCacheManager); cacheManager.setTransactionAware(false); cacheManager.afterPropertiesSet(); transactionalCacheManager = new EhCacheCacheManager(nativeCacheManager); transactionalCacheManager.setTransactionAware(true); transactionalCacheManager.afterPropertiesSet(); }
Example #22
Source File: EhCacheCacheTests.java From spring-analysis-note with MIT License | 5 votes |
@Before public void setup() { cacheManager = new CacheManager(new Configuration().name("EhCacheCacheTests") .defaultCache(new CacheConfiguration("default", 100))); nativeCache = new net.sf.ehcache.Cache(new CacheConfiguration(CACHE_NAME, 100)); cacheManager.addCache(nativeCache); cache = new EhCacheCache(nativeCache); }
Example #23
Source File: EhCacheManagerFactoryBean.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void afterPropertiesSet() throws CacheException { if (logger.isInfoEnabled()) { logger.info("Initializing EhCache CacheManager" + (this.cacheManagerName != null ? " '" + this.cacheManagerName + "'" : "")); } Configuration configuration = (this.configLocation != null ? EhCacheManagerUtils.parseConfiguration(this.configLocation) : ConfigurationFactory.parseConfiguration()); if (this.cacheManagerName != null) { configuration.setName(this.cacheManagerName); } if (this.shared) { // Old-school EhCache singleton sharing... // No way to find out whether we actually created a new CacheManager // or just received an existing singleton reference. this.cacheManager = CacheManager.create(configuration); } else if (this.acceptExisting) { // EhCache 2.5+: Reusing an existing CacheManager of the same name. // Basically the same code as in CacheManager.getInstance(String), // just storing whether we're dealing with an existing instance. synchronized (CacheManager.class) { this.cacheManager = CacheManager.getCacheManager(this.cacheManagerName); if (this.cacheManager == null) { this.cacheManager = new CacheManager(configuration); } else { this.locallyManaged = false; } } } else { // Throwing an exception if a CacheManager of the same name exists already... this.cacheManager = new CacheManager(configuration); } }
Example #24
Source File: CacheFactory.java From airsonic with GNU General Public License v3.0 | 5 votes |
public void afterPropertiesSet() { Configuration configuration = ConfigurationFactory.parseConfiguration(); // Override configuration to make sure cache is stored in Airsonic home dir. File cacheDir = new File(SettingsService.getAirsonicHome(), "cache"); configuration.getDiskStoreConfiguration().setPath(cacheDir.getPath()); cacheManager = CacheManager.create(configuration); }
Example #25
Source File: EhCache2MetricsCompatibilityTest.java From micrometer with Apache License 2.0 | 5 votes |
EhCache2MetricsCompatibilityTest() { Configuration config = ConfigurationFactory.parseConfiguration(); config.setName(UUID.randomUUID().toString()); this.cacheManager = CacheManager.newInstance(config); this.cacheManager.addCache("mycache"); this.cache = cacheManager.getCache("mycache"); }
Example #26
Source File: EhCacheCacheManagerTests.java From java-technology-stack with MIT License | 5 votes |
@Before public void setup() { nativeCacheManager = new CacheManager(new Configuration().name("EhCacheCacheManagerTests") .defaultCache(new CacheConfiguration("default", 100))); addNativeCache(CACHE_NAME); cacheManager = new EhCacheCacheManager(nativeCacheManager); cacheManager.setTransactionAware(false); cacheManager.afterPropertiesSet(); transactionalCacheManager = new EhCacheCacheManager(nativeCacheManager); transactionalCacheManager.setTransactionAware(true); transactionalCacheManager.afterPropertiesSet(); }
Example #27
Source File: EhCacheCacheTests.java From java-technology-stack with MIT License | 5 votes |
@Before public void setup() { cacheManager = new CacheManager(new Configuration().name("EhCacheCacheTests") .defaultCache(new CacheConfiguration("default", 100))); nativeCache = new net.sf.ehcache.Cache(new CacheConfiguration(CACHE_NAME, 100)); cacheManager.addCache(nativeCache); cache = new EhCacheCache(nativeCache); }
Example #28
Source File: CacheTemplate.java From smart-cache with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public void afterPropertiesSet() throws Exception { Cache.ID = key + "." + Dates.newDateStringOfFormatDateTimeSSSNoneSpace(); Cache.HOST = Utils.getLocalHostIP(); Cache.CACHE_STORE = key + spliter + "cache" + spliter + "store"; Cache.CACHE_STORE_SYNC = Cache.CACHE_STORE + spliter + "sync"; if (this.localEnabled) { Configuration configuration = new Configuration(); configuration.setName(Cache.ID); configuration.setMaxBytesLocalHeap(localMaxBytesLocalHeap); configuration.setMaxBytesLocalDisk(localMaxBytesLocalDisk); // DiskStore // 每次启动设置新的文件地址,以避免重启期间一级缓存未同步,以及单机多应用启动造成EhcacheManager重复的问题. DiskStoreConfiguration dsc = new DiskStoreConfiguration(); dsc.setPath(localStoreLocation + Cache.ID); configuration.diskStore(dsc); // DefaultCache CacheConfiguration defaultCacheConfiguration = new CacheConfiguration(); defaultCacheConfiguration.setEternal(false); defaultCacheConfiguration.setOverflowToDisk(true); defaultCacheConfiguration.setDiskPersistent(false); defaultCacheConfiguration.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU); defaultCacheConfiguration.setDiskExpiryThreadIntervalSeconds(localDiskExpiryThreadIntervalSeconds); // 默认false,使用引用.设置为true,避免外部代码修改了缓存对象.造成EhCache的缓存对象也随之改变 // 但是设置为true后,将引起element的tti不自动刷新.如果直接新建element去覆盖原值.则本地ttl和远程ttl会产生一定的误差. // 因此,使用时放弃手动覆盖方式刷新本地tti,当本地tti过期后,自动从Redis中再获取即可. defaultCacheConfiguration.copyOnRead(true); defaultCacheConfiguration.copyOnWrite(true); defaultCacheConfiguration.setTimeToIdleSeconds(localTimeToIdleSeconds); defaultCacheConfiguration.setTimeToLiveSeconds(localTimeToLiveSeconds); configuration.setDefaultCacheConfiguration(defaultCacheConfiguration); configuration.setDynamicConfig(false); configuration.setUpdateCheck(false); this.cacheManager = new CacheManager(configuration); this.cacheSync = new RedisPubSubSync(this);// 使用Redis Topic发送订阅缓存变更消息 } }
Example #29
Source File: InMemoryDirectoryServiceFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
/** * {@inheritDoc} */ @Override public void init(String name) throws Exception { if ((directoryService != null) && directoryService.isStarted()) { return; } directoryService.setInstanceId(name); // instance layout InstanceLayout instanceLayout = new InstanceLayout(System.getProperty("java.io.tmpdir") + "/server-work-" + name); if (instanceLayout.getInstanceDirectory().exists()) { try { FileUtils.deleteDirectory(instanceLayout.getInstanceDirectory()); } catch (IOException e) { LOG.warn("couldn't delete the instance directory before initializing the DirectoryService", e); } } directoryService.setInstanceLayout(instanceLayout); // EhCache in disabled-like-mode Configuration ehCacheConfig = new Configuration(); CacheConfiguration defaultCache = new CacheConfiguration("ApacheDSTestCache", 1).eternal(false).timeToIdleSeconds(30) .timeToLiveSeconds(30).overflowToDisk(false); ehCacheConfig.addDefaultCache(defaultCache); cacheManager = new CacheManager(ehCacheConfig); CacheService cacheService = new CacheService(cacheManager); directoryService.setCacheService(cacheService); // Init the schema // SchemaLoader loader = new SingleLdifSchemaLoader(); SchemaLoader loader = new JarLdifSchemaLoader(); SchemaManager schemaManager = new DefaultSchemaManager(loader); schemaManager.loadAllEnabled(); ComparatorRegistry comparatorRegistry = schemaManager.getComparatorRegistry(); for (LdapComparator<?> comparator : comparatorRegistry) { if (comparator instanceof NormalizingComparator) { ((NormalizingComparator) comparator).setOnServer(); } } directoryService.setSchemaManager(schemaManager); InMemorySchemaPartition inMemorySchemaPartition = new InMemorySchemaPartition(schemaManager); SchemaPartition schemaPartition = new SchemaPartition(schemaManager); schemaPartition.setWrappedPartition(inMemorySchemaPartition); directoryService.setSchemaPartition(schemaPartition); List<Throwable> errors = schemaManager.getErrors(); if (errors.size() != 0) { throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors))); } // Init system partition Partition systemPartition = partitionFactory.createPartition(directoryService.getSchemaManager(), "system", ServerDNConstants.SYSTEM_DN, 500, new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "system")); systemPartition.setSchemaManager(directoryService.getSchemaManager()); partitionFactory.addIndex(systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100); directoryService.setSystemPartition(systemPartition); directoryService.startup(); }
Example #30
Source File: EhcacheTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
@Test public void basicTest() throws InterruptedException { System.out.println("runtime used memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "M"); Configuration conf = new Configuration(); conf.setMaxBytesLocalHeap("100M"); CacheManager cacheManager = CacheManager.create(conf); //Create a Cache specifying its configuration. Cache testCache = //Create a Cache specifying its configuration. new Cache(new CacheConfiguration("test", 0).// memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU).// eternal(false).// timeToIdleSeconds(86400).// diskExpiryThreadIntervalSeconds(0).// //maxBytesLocalHeap(1000, MemoryUnit.MEGABYTES).// persistence(new PersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.NONE))); cacheManager.addCache(testCache); System.out.println("runtime used memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "M"); byte[] blob = new byte[(1024 * 80 * 1024)];//400M Random random = new Random(); for (int i = 0; i < blob.length; i++) { blob[i] = (byte) random.nextInt(); } // List<String> manyObjects = Lists.newArrayList(); // for (int i = 0; i < 10000; i++) { // manyObjects.add(new String("" + i)); // } // testCache.put(new Element("0", manyObjects)); testCache.put(new Element("1", blob)); System.out.println(testCache.get("1") == null); System.out.println(testCache.getSize()); System.out.println(testCache.getStatistics().getLocalHeapSizeInBytes()); System.out.println("runtime used memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "M"); blob = new byte[(1024 * 80 * 1024)];//400M for (int i = 0; i < blob.length; i++) { blob[i] = (byte) random.nextInt(); } testCache.put(new Element("2", blob)); System.out.println(testCache.get("1") == null); System.out.println(testCache.get("2") == null); System.out.println(testCache.getSize()); System.out.println(testCache.getStatistics().getLocalHeapSizeInBytes()); System.out.println("runtime used memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "M"); blob = new byte[(1024 * 80 * 1024)];//400M for (int i = 0; i < blob.length; i++) { blob[i] = (byte) random.nextInt(); } testCache.put(new Element("3", blob)); System.out.println(testCache.get("1") == null); System.out.println(testCache.get("2") == null); System.out.println(testCache.get("3") == null); System.out.println(testCache.getSize()); System.out.println(testCache.getStatistics().getLocalHeapSizeInBytes()); System.out.println("runtime used memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "M"); cacheManager.shutdown(); }