/** * convenience method to create a partition region with customized regionFactory and a customized * PartitionAttributeFactory * * @param regionFactoryConsumer a lamda that allows you to customize the regionFactory * @param attributesFactoryConsumer a lamda that allows you to customize the * partitionAttributeFactory */ public Region createPartitionRegion(String name, Consumer<RegionFactory> regionFactoryConsumer, Consumer<PartitionAttributesFactory> attributesFactoryConsumer) { return createRegion(RegionShortcut.PARTITION, name, rf -> { regionFactoryConsumer.accept(rf); PartitionAttributesFactory attributeFactory = new PartitionAttributesFactory(); attributesFactoryConsumer.accept(attributeFactory); rf.setPartitionAttributes(attributeFactory.create()); }); }
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); }
@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; } });
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); }
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); }
factory.setPartitionAttributes( PartitionAttributesImpl.fromConfig(regionAttributes.getPartitionAttributes(), cache));
private static void setupRegions(String regionName, String parRegionName) { InternalCache cache = ClusterStartupRule.getCache(); RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE); Region dataRegion = regionFactory.create(DATA_REGION_NAME); assertNotNull(dataRegion); dataRegion = dataRegion.createSubregion(DATA_REGION_NAME_CHILD_1, dataRegion.getAttributes()); assertNotNull(dataRegion); dataRegion = dataRegion.createSubregion(DATA_REGION_NAME_CHILD_1_2, dataRegion.getAttributes()); assertNotNull(dataRegion); dataRegion = regionFactory.create(regionName); assertNotNull(dataRegion); PartitionAttributes partitionAttrs = new PartitionAttributesFactory().setRedundantCopies(2).create(); RegionFactory<Object, Object> partitionRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION); partitionRegionFactory.setPartitionAttributes(partitionAttrs); Region dataParRegion = partitionRegionFactory.create(DATA_PAR_REGION_NAME); assertNotNull(dataParRegion); dataParRegion = partitionRegionFactory.create(parRegionName); assertNotNull(dataParRegion); }
when(mockRegionFactory.setPartitionAttributes(any(PartitionAttributes.class))) .thenAnswer(newSetter(partitionAttributes, mockRegionFactory));
regionFactory.setPartitionAttributes(partitionAttributesFactory.create());
regionFactory.setPartitionAttributes(partitionAttributesFactory.create());