use of org.apache.geode.cache.PartitionAttributes in project geode by apache.
the class PRDeltaPropagationDUnitTest method createPR.
public static void createPR(String partitionedRegionName, Integer redundancy, Integer localMaxMemory, Integer totalNumBuckets, Boolean setExpiry, Boolean withCloning, Compressor compressor) {
PartitionAttributesFactory paf = new PartitionAttributesFactory();
PartitionAttributes prAttr = paf.setRedundantCopies(redundancy.intValue()).setLocalMaxMemory(localMaxMemory.intValue()).setTotalNumBuckets(totalNumBuckets.intValue()).create();
AttributesFactory attr = new AttributesFactory();
attr.setPartitionAttributes(prAttr);
attr.setDataPolicy(DataPolicy.PARTITION);
attr.setConcurrencyChecksEnabled(true);
attr.setCloningEnabled(withCloning);
if (setExpiry) {
attr.setStatisticsEnabled(true);
attr.setEntryIdleTimeout(new ExpirationAttributes(1, ExpirationAction.INVALIDATE));
}
if (compressor != null) {
attr.setCompressor(compressor);
}
// attr.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(5));
assertNotNull(cache);
deltaPR = cache.createRegion(partitionedRegionName, attr.create());
assertNotNull(deltaPR);
LogWriterUtils.getLogWriter().info("Partitioned Region " + partitionedRegionName + " created Successfully :" + deltaPR);
}
use of org.apache.geode.cache.PartitionAttributes in project geode by apache.
the class PdxQueryCQTestBase method configAndStartBridgeServer.
protected void configAndStartBridgeServer(boolean isPr, boolean isAccessor, boolean asyncIndex, Compressor compressor) {
AttributesFactory factory = new AttributesFactory();
if (isPr) {
PartitionAttributesFactory paf = new PartitionAttributesFactory();
// factory.setDataPolicy(DataPolicy.PARTITION);
if (isAccessor) {
paf.setLocalMaxMemory(0);
}
PartitionAttributes prAttr = paf.setTotalNumBuckets(20).setRedundantCopies(0).create();
factory.setPartitionAttributes(prAttr);
} else {
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
}
if (asyncIndex) {
factory.setIndexMaintenanceSynchronous(!asyncIndex);
}
if (compressor != null) {
factory.setCompressor(compressor);
}
createRegion(this.regionName, this.rootRegionName, factory.create());
createRegion(this.regionName2, this.rootRegionName, factory.create());
try {
startBridgeServer(0, false);
} catch (Exception ex) {
Assert.fail("While starting CacheServer", ex);
}
}
use of org.apache.geode.cache.PartitionAttributes in project geode by apache.
the class PrCqUsingPoolDUnitTest method createServer.
/**
* Create a bridge server with partitioned region.
*
* @param server VM where to create the bridge server.
* @param port bridge server port.
* @param isAccessor if true the under lying partitioned region will not host data on this vm.
* @param redundantCopies number of redundant copies for the primary bucket.
*/
public void createServer(VM server, final int port, final boolean isAccessor, final int redundantCopies) {
SerializableRunnable createServer = new CacheSerializableRunnable("Create Cache Server") {
public void run2() throws CacheException {
LogWriterUtils.getLogWriter().info("### Create Cache Server. ###");
// AttributesFactory factory = new AttributesFactory();
// factory.setScope(Scope.DISTRIBUTED_ACK);
// factory.setMirrorType(MirrorType.KEYS_VALUES);
// int maxMem = 0;
AttributesFactory attr = new AttributesFactory();
// attr.setValueConstraint(valueConstraint);
PartitionAttributesFactory paf = new PartitionAttributesFactory();
if (isAccessor) {
paf.setLocalMaxMemory(0);
}
PartitionAttributes prAttr = paf.setTotalNumBuckets(197).setRedundantCopies(redundantCopies).create();
attr.setPartitionAttributes(prAttr);
assertFalse(getSystem().isLoner());
// 0);
for (int i = 0; i < regions.length; i++) {
Region r = createRegion(regions[i], attr.create());
LogWriterUtils.getLogWriter().info("Server created the region: " + r);
}
// pause(2000);
try {
startBridgeServer(port, true);
} catch (Exception ex) {
Assert.fail("While starting CacheServer", ex);
}
// pause(2000);
}
};
server.invoke(createServer);
}
use of org.apache.geode.cache.PartitionAttributes in project geode by apache.
the class PartitionedRegionCqQueryDUnitTest method createServer.
/**
* Create a bridge server with partitioned region.
*
* @param server VM where to create the bridge server.
* @param port bridge server port.
* @param isAccessor if true the under lying partitioned region will not host data on this vm.
* @param redundantCopies number of redundant copies for the primary bucket.
*/
public void createServer(VM server, final int port, final boolean isAccessor, final int redundantCopies) {
SerializableRunnable createServer = new CacheSerializableRunnable("Create Cache Server") {
public void run2() throws CacheException {
LogWriterUtils.getLogWriter().info("### Create Cache Server. ###");
AttributesFactory attr = new AttributesFactory();
PartitionAttributesFactory paf = new PartitionAttributesFactory();
if (isAccessor) {
paf.setLocalMaxMemory(0);
}
PartitionAttributes prAttr = paf.setTotalNumBuckets(197).setRedundantCopies(redundantCopies).create();
attr.setPartitionAttributes(prAttr);
assertFalse(getSystem().isLoner());
// 0);
for (int i = 0; i < regions.length; i++) {
Region r = createRegion(regions[i], attr.create());
LogWriterUtils.getLogWriter().info("Server created the region: " + r);
}
try {
startBridgeServer(port, true);
} catch (Exception ex) {
Assert.fail("While starting CacheServer", ex);
}
}
};
server.invoke(createServer);
}
use of org.apache.geode.cache.PartitionAttributes in project geode by apache.
the class LuceneIndexForPartitionedRegion method createLuceneListenersAndFileChunkRegions.
protected void createLuceneListenersAndFileChunkRegions(AbstractPartitionedRepositoryManager partitionedRepositoryManager) {
partitionedRepositoryManager.setUserRegionForRepositoryManager();
RegionShortcut regionShortCut;
final boolean withPersistence = withPersistence();
RegionAttributes regionAttributes = dataRegion.getAttributes();
final boolean withStorage = regionAttributes.getPartitionAttributes().getLocalMaxMemory() > 0;
// 4) Offheap to Offheap
if (!withStorage) {
regionShortCut = RegionShortcut.PARTITION_PROXY;
} else if (withPersistence) {
// TODO: add PartitionedRegionAttributes instead
regionShortCut = RegionShortcut.PARTITION_PERSISTENT;
} else {
regionShortCut = RegionShortcut.PARTITION;
}
// create PR fileAndChunkRegion, but not to create its buckets for now
final String fileRegionName = createFileRegionName();
PartitionAttributes partitionAttributes = dataRegion.getPartitionAttributes();
DM dm = this.cache.getInternalDistributedSystem().getDistributionManager();
LuceneBucketListener lucenePrimaryBucketListener = new LuceneBucketListener(partitionedRepositoryManager, dm);
if (!fileRegionExists(fileRegionName)) {
fileAndChunkRegion = createFileRegion(regionShortCut, fileRegionName, partitionAttributes, regionAttributes, lucenePrimaryBucketListener);
}
fileSystemStats.setBytesSupplier(() -> getFileAndChunkRegion().getPrStats().getDataStoreBytesInUse());
}
Aggregations