/** * convenience method to create a region with customized regionFactory * * @param regionFactoryConsumer a lamda that allows you to customize the regionFactory */ public Region createRegion(RegionShortcut type, String name, Consumer<RegionFactory> regionFactoryConsumer) { RegionFactory regionFactory = getCache().createRegionFactory(type); regionFactoryConsumer.accept(regionFactory); return regionFactory.create(name); }
private static void setupDataRegionAndSubregions() { InternalCache cache = ClusterStartupRule.getCache(); RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE); Region dataRegion = regionFactory.create(DATA_REGION_NAME); assertThat(dataRegion).isNotNull(); Region dataSubRegion = regionFactory.createSubregion(dataRegion, DATA_REGION_NAME_CHILD_1); assertThat(dataSubRegion).isNotNull(); dataSubRegion = regionFactory.createSubregion(dataSubRegion, DATA_REGION_NAME_CHILD_1_2); assertThat(dataSubRegion).isNotNull(); assertThat(dataRegion).isNotNull(); }
@Override public void run2() throws CacheException { Cache cache = getCache(); RegionAttributes<?, ?> regionAttribs = getRegionAttributes(); cache.createRegionFactory(regionAttribs).create("R1"); } };
@Override public void before() { super.before(); if (autoStart) { startServer(); regions.forEach((regionName, regionType) -> { RegionFactory rf = getCache().createRegionFactory(regionType); rf.create(regionName); }); } }
@BeforeClass public static void beforeClass() throws Exception { serverStarter.getCache().createRegionFactory(RegionShortcut.REPLICATE).create("region1"); }
private static Region<?, ?> createPartitionedRegion(String regionName, Cache cache, Class keyConstraint, Class valueConstraint) { RegionFactory regionFactory = cache.createRegionFactory(); regionFactory.setDataPolicy(DataPolicy.PARTITION); regionFactory.setKeyConstraint(keyConstraint); regionFactory.setValueConstraint(valueConstraint); return regionFactory.create(regionName); }
/** * Creates a Local region */ protected void createLocalRegion(final VM vm, final String localRegionName) { vm.invoke("Create Local region", () -> { InternalCache cache = GemFireCacheImpl.getInstance(); SystemManagementService service = (SystemManagementService) getManagementService(); RegionFactory factory = cache.createRegionFactory(RegionShortcut.LOCAL); factory.create(localRegionName); }); }
/** * Creates a partition Region */ protected void createPartitionRegion(final VM vm, final String partitionRegionName) { vm.invoke("Create Partitioned region", () -> { InternalCache cache = GemFireCacheImpl.getInstance(); SystemManagementService service = (SystemManagementService) getManagementService(); RegionFactory factory = cache.createRegionFactory(RegionShortcut.PARTITION_REDUNDANT); factory.create(partitionRegionName); }); }
public MemoryHog(String n, Cache c, AtomicBoolean critical) { this.name = n; this.cache = c; this.tenuredData = new RegionFactory().setScope(Scope.LOCAL).create(this.name); this.criticalState = critical; }
public void createPartitionRegion(String name, Class constraint) { ExpirationAttributes expiration = ExpirationAttributes.DEFAULT; PartitionAttributesFactory paf = new PartitionAttributesFactory(); RegionFactory factory = cache.createRegionFactory(RegionShortcut.PARTITION).setPartitionAttributes(paf.create()); if (constraint != null) { factory.setValueConstraint(constraint); } factory.create(name); }
@Test public void createsPartitionedInCache() { RegionConfig config = new RegionConfig(); config.setName("regionName"); config.setType("PARTITION"); RegionConfigRealizer realizer = new RegionConfigRealizer(); realizer.create(config, cache); ArgumentCaptor<DataPolicy> dataPolicyArgumentCaptor = ArgumentCaptor.forClass(DataPolicy.class); verify(regionFactory).setDataPolicy(dataPolicyArgumentCaptor.capture()); assertThat(dataPolicyArgumentCaptor.getValue()).isEqualTo(DataPolicy.PARTITION); verify(regionFactory).create("regionName"); }
@Override public Object call() throws Exception { PartitionAttributesFactory paf = new PartitionAttributesFactory(); RegionFactory factory = getCache().createRegionFactory(RegionShortcut.PARTITION) .setPartitionAttributes(paf.create()); if (valueConstraint != null) { factory.setValueConstraint(valueConstraint); } factory.create(regionName); return true; } });
static void putForClient() { Cache cache = new ClientServerMiscDUnitTestBase().getCache(); Region r2 = cache.getRegion(Region.SEPARATOR + REGION_NAME2); if (r2 == null) { r2 = cache.createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME2); } r2.put(k1, "client2_k1"); r2.put(k2, "client2_k2"); }
private static void setupReplicatedRegion(String regionName) { InternalCache cache = ClusterStartupRule.getCache(); RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE); Region dataRegion = regionFactory.create(regionName); assertThat(dataRegion).isNotNull(); assertThat(dataRegion.getFullPath()).contains(regionName); }
private static void setupReplicatedRegion(String regionName) { InternalCache cache = ClusterStartupRule.getCache(); RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE); Region dataRegion = regionFactory.create(regionName); assertThat(dataRegion).isNotNull(); assertThat(dataRegion.getFullPath()).contains(regionName); }
public static void createReplicatedRegionWithCacheLoaderAndAsyncEventQueue(String regionName, String asyncQueueIds) { AttributesFactory fact = new AttributesFactory(); addAsyncEventQueueIds(fact, asyncQueueIds); fact.setDataPolicy(DataPolicy.REPLICATE); // set the CacheLoader fact.setCacheLoader(new MyCacheLoader()); RegionFactory regionFactory = cache.createRegionFactory(fact.create()); Region r = regionFactory.create(regionName); assertNotNull(r); }
@Before public void setUp() throws Exception { cache = new CacheFactory().set(ConfigurationProperties.LOCATORS, "").create(); Region region = cache.createRegionFactory(RegionShortcut.LOCAL).create("region"); IntStream.range(0, 2).forEach(i -> region.put("key" + i, new PortfolioPdx(i))); }
private static void setupPartitionedRegion(String regionName) { InternalCache cache = ClusterStartupRule.getCache(); PartitionAttributes partitionAttrs = new PartitionAttributesFactory().setRedundantCopies(2).create(); RegionFactory<Object, Object> partitionRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION); partitionRegionFactory.setPartitionAttributes(partitionAttrs); Region dataParRegion = partitionRegionFactory.create(regionName); assertThat(dataParRegion).isNotNull(); assertThat(dataParRegion.getFullPath()).contains(regionName); }
public static void createPartitionedRegionWithCacheLoaderAndAsyncQueue(String regionName, String asyncEventQueueId) { AttributesFactory fact = new AttributesFactory(); PartitionAttributesFactory pfact = new PartitionAttributesFactory(); pfact.setTotalNumBuckets(16); fact.setPartitionAttributes(pfact.create()); // set the CacheLoader implementation fact.setCacheLoader(new MyCacheLoader()); Region r = cache.createRegionFactory(fact.create()).addAsyncEventQueueId(asyncEventQueueId) .create(regionName); assertNotNull(r); }
private static void setupReplicatedRegionWithEviction(String regionName) { InternalCache cache = ClusterStartupRule.getCache(); EvictionAttributesImpl evictionAttributes = new EvictionAttributesImpl(); evictionAttributes.setMaximum(1).setAction(EvictionAction.OVERFLOW_TO_DISK) .setAlgorithm(EvictionAlgorithm.LRU_ENTRY); RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE) .setEvictionAttributes(evictionAttributes); Region dataRegion = regionFactory.create(regionName); assertThat(dataRegion).isNotNull(); assertThat(dataRegion.getFullPath()).contains(regionName); }