org.ehcache.config.builders.ResourcePoolsBuilder.build()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(82)

本文整理了Java中org.ehcache.config.builders.ResourcePoolsBuilder.build方法的一些代码示例,展示了ResourcePoolsBuilder.build的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourcePoolsBuilder.build方法的具体详情如下:
包路径:org.ehcache.config.builders.ResourcePoolsBuilder
类名称:ResourcePoolsBuilder
方法名:build

ResourcePoolsBuilder.build介绍

[英]Builds the ResourcePools based on this builder's configuration.
[中]基于此生成器的配置生成资源池。

代码示例

代码示例来源:origin: ehcache/ehcache3

/**
 * Convenience method to add a {@link ResourcePools} configuration based on the provided {@link ResourcePoolsBuilder}
 * to the returned builder.
 *
 * @param resourcePoolsBuilder the builder to get the resource pools from
 * @return a new builder with the configured resource pools
 *
 * @see #withResourcePools(ResourcePools)
 */
public final UserManagedCacheBuilder<K, V, T> withResourcePools(ResourcePoolsBuilder resourcePoolsBuilder) {
 return withResourcePools(resourcePoolsBuilder.build());
}

代码示例来源:origin: ehcache/ehcache3

/**
 * Convenience method to add a {@link ResourcePools} through a {@link ResourcePoolsBuilder} to the returned builder.
 *
 * @param resourcePoolsBuilder the builder providing the resource pool
 * @return a new builder with the added resource pools
 *
 * @see #withResourcePools(ResourcePools)
 */
public CacheConfigurationBuilder<K, V> withResourcePools(ResourcePoolsBuilder resourcePoolsBuilder) {
 return withResourcePools(requireNonNull(resourcePoolsBuilder, "Null resource pools builder").build());
}

代码示例来源:origin: ehcache/ehcache3

private ResourcePools buildResourcePools(Comparable<Long> capacityConstraint) {
 if (capacityConstraint == null) {
  return newResourcePoolsBuilder().heap(Long.MAX_VALUE, EntryUnit.ENTRIES).build();
 } else {
  return newResourcePoolsBuilder().heap((Long)capacityConstraint, EntryUnit.ENTRIES).build();
 }
}

代码示例来源:origin: ehcache/ehcache3

private ResourcePools buildResourcePools(Comparable<Long> capacityConstraint) {
 if (capacityConstraint == null) {
  return newResourcePoolsBuilder().heap(Long.MAX_VALUE, EntryUnit.ENTRIES).build();
 } else {
  return newResourcePoolsBuilder().heap((Long)capacityConstraint, EntryUnit.ENTRIES).build();
 }
}

代码示例来源:origin: ehcache/ehcache3

private ResourcePools buildResourcePools(Comparable<Long> capacityConstraint) {
 if (capacityConstraint == null) {
  capacityConstraint = 10L;
 }
 return newResourcePoolsBuilder().heap((Long)capacityConstraint, MemoryUnit.MB).build();
}

代码示例来源:origin: ehcache/ehcache3

private ResourcePools buildResourcePools(Comparable<Long> capacityConstraint) {
 if (capacityConstraint == null) {
  return newResourcePoolsBuilder().heap(10l, MemoryUnit.KB).build();
 } else {
  return newResourcePoolsBuilder().heap((Long) capacityConstraint * MAGIC_NUM, MemoryUnit.B).build();
 }
}

代码示例来源:origin: ehcache/ehcache3

private ResourcePools getDiskResourcePool(Comparable<Long> capacityConstraint) {
 if (capacityConstraint == null) {
  capacityConstraint = 10L;
 }
 return newResourcePoolsBuilder().disk((Long) capacityConstraint, MemoryUnit.MB).build();
}

代码示例来源:origin: ehcache/ehcache3

private ResourcePools buildResourcePools(Comparable<Long> capacityConstraint) {
 if (capacityConstraint == null) {
  return newResourcePoolsBuilder().heap(10, MemoryUnit.KB).build();
 } else {
  return newResourcePoolsBuilder().heap((Long)capacityConstraint * MAGIC_NUM, MemoryUnit.B).build();
 }
}

代码示例来源:origin: ehcache/ehcache3

private ResourcePools buildResourcePools(Comparable<Long> capacityConstraint) {
 if (capacityConstraint == null) {
  return newResourcePoolsBuilder().heap(Long.MAX_VALUE, EntryUnit.ENTRIES).build();
 } else {
  return newResourcePoolsBuilder().heap((Long) capacityConstraint, EntryUnit.ENTRIES).build();
 }
}

代码示例来源:origin: ehcache/ehcache3

private ResourcePools buildResourcePools(Comparable<Long> capacityConstraint) {
 if (capacityConstraint == null) {
  capacityConstraint = 10L;
 }
 return newResourcePoolsBuilder().heap((Long)capacityConstraint, MemoryUnit.MB).build();
}

代码示例来源:origin: ehcache/ehcache3

@Override
public ServiceConfiguration<?>[] getServiceConfigurations() {
 try {
  CacheConfiguration<?, ?> cacheConfiguration = mock(CacheConfiguration.class);
  when(cacheConfiguration.getResourcePools()).thenReturn(newResourcePoolsBuilder().disk(1, MemoryUnit.MB, false).build());
  String spaceName = "OffheapDiskStore-" + index.getAndIncrement();
  PersistenceSpaceIdentifier<?> space = diskResourceService.getPersistenceSpaceIdentifier(spaceName, cacheConfiguration);
  return new ServiceConfiguration<?>[] {space};
 } catch (CachePersistenceException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: ehcache/ehcache3

private FileBasedPersistenceContext getPersistenceContext() {
 try {
  CacheConfiguration<?, ?> cacheConfiguration = mock(CacheConfiguration.class);
  when(cacheConfiguration.getResourcePools()).thenReturn(newResourcePoolsBuilder().disk(1, MB, false).build());
  PersistenceSpaceIdentifier<?> space = diskResourceService.getPersistenceSpaceIdentifier("cache", cacheConfiguration);
  return diskResourceService.createPersistenceContextWithin(space, "store");
 } catch (CachePersistenceException e) {
  throw new AssertionError(e);
 }
}

代码示例来源:origin: ehcache/ehcache3

@Override
protected void updateStoreCapacity(OnHeapStore<?, ?> store, int newCapacity) {
 CacheConfigurationChangeListener listener = store.getConfigurationChangeListeners().get(0);
 listener.cacheConfigurationChange(new CacheConfigurationChangeEvent(CacheConfigurationProperty.UPDATE_SIZE,
   newResourcePoolsBuilder().heap(100, EntryUnit.ENTRIES).build(),
   newResourcePoolsBuilder().heap(newCapacity, EntryUnit.ENTRIES).build()));
}

代码示例来源:origin: ehcache/ehcache3

@Override
protected void updateStoreCapacity(OnHeapStore<?, ?> store, int newCapacity) {
 CacheConfigurationChangeListener listener = store.getConfigurationChangeListeners().get(0);
 listener.cacheConfigurationChange(new CacheConfigurationChangeEvent(CacheConfigurationProperty.UPDATE_SIZE,
   newResourcePoolsBuilder().heap(100, MemoryUnit.KB).build(),
   newResourcePoolsBuilder().heap(newCapacity * MAGIC_NUM, MemoryUnit.KB).build()));
}

代码示例来源:origin: ehcache/ehcache3

private ResourcePools buildResourcePools(Comparable<Long> capacityConstraint) {
 if (capacityConstraint == null) {
  return newResourcePoolsBuilder().heap(Long.MAX_VALUE, EntryUnit.ENTRIES).offheap(1, MemoryUnit.MB).build();
 } else {
  return newResourcePoolsBuilder().heap((Long)capacityConstraint, EntryUnit.ENTRIES).offheap(1, MemoryUnit.MB).build();
 }
}

代码示例来源:origin: ehcache/ehcache3

@Override
protected void updateStoreCapacity(OnHeapStore<?, ?> store, int newCapacity) {
 CacheConfigurationChangeListener listener = store.getConfigurationChangeListeners().get(0);
 listener.cacheConfigurationChange(new CacheConfigurationChangeEvent(CacheConfigurationProperty.UPDATE_SIZE,
   newResourcePoolsBuilder().heap(100, MemoryUnit.KB).build(),
   newResourcePoolsBuilder().heap(newCapacity * MAGIC_NUM, MemoryUnit.KB).build()));
}

代码示例来源:origin: ehcache/ehcache3

@Test
public void testWithReplacingNoInitial() throws Exception {
 long newSize = 16;
 ResourceUnit mb = MemoryUnit.MB;
 SizedResourcePool newPool = new SizedResourcePoolImpl<>(HEAP, newSize, mb, false);
 ResourcePoolsBuilder builder = newResourcePoolsBuilder();
 ResourcePools resourcePools = builder.withReplacing(newPool).build();
 SizedResourcePool pool = resourcePools.getPoolForResource(HEAP);
 assertThat(pool.getSize(), is(newSize));
 assertThat(pool.getUnit(), is(mb));
}

代码示例来源:origin: ehcache/ehcache3

@Test
public void testClusteredDedicatedResourcePoolUpdation() throws Exception {
 expectedException.expect(UnsupportedOperationException.class);
 expectedException.expectMessage("Updating CLUSTERED resource is not supported");
 dedicatedCache.getRuntimeConfiguration().updateResourcePools(
  ResourcePoolsBuilder.newResourcePoolsBuilder()
   .with(ClusteredResourcePoolBuilder.clusteredDedicated("primary-server-resource", 8, MemoryUnit.MB))
   .build()
 );
}

代码示例来源:origin: ehcache/ehcache3

@Test
 public void testClusteredSharedResourcePoolUpdation() throws Exception {
  expectedException.expect(UnsupportedOperationException.class);
  expectedException.expectMessage("Updating CLUSTERED resource is not supported");
  sharedCache.getRuntimeConfiguration().updateResourcePools(
   ResourcePoolsBuilder.newResourcePoolsBuilder()
    .with(ClusteredResourcePoolBuilder.clusteredShared("resource-pool-a"))
    .build()
  );
 }
}

代码示例来源:origin: ehcache/ehcache3

@Test
public void testNotShared() {
 // tag::notShared[]
 ResourcePools pool = ResourcePoolsBuilder.heap(10).build();
 CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
  .withCache("test-cache1", CacheConfigurationBuilder.newCacheConfigurationBuilder(Integer.class, String.class, pool))
  .withCache("test-cache2", CacheConfigurationBuilder.newCacheConfigurationBuilder(Integer.class, String.class, pool))
  .build(true);
 // end::notShared[]
}

相关文章