use of org.apache.geode.cache.PartitionAttributesFactory in project geode by apache.
the class ClientServerMiscDUnitTest method createServerCache.
public static Integer createServerCache(Boolean notifyBySubscription, Integer maxThreads, boolean isHA) throws Exception {
Cache cache = new ClientServerMiscDUnitTest().createCacheV(new Properties());
unsetSlowDispatcherFlag();
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setEnableConflation(true);
factory.setDataPolicy(DataPolicy.REPLICATE);
RegionAttributes myAttrs = factory.create();
Region r1 = cache.createRegion(REGION_NAME1, myAttrs);
Region r2 = cache.createRegion(REGION_NAME2, myAttrs);
factory = new AttributesFactory();
factory.setDataPolicy(DataPolicy.PARTITION);
if (isHA) {
PartitionAttributesFactory paf = new PartitionAttributesFactory().setRedundantCopies(1);
factory.setPartitionAttributes(paf.create());
}
RegionAttributes prAttrs = factory.create();
Region pr = cache.createRegion(PR_REGION_NAME, prAttrs);
assertNotNull(r1);
assertNotNull(r2);
assertNotNull(pr);
CacheServer server = cache.addCacheServer();
int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
r1.getCache().getDistributedSystem().getLogWriter().info("Starting server on port " + port);
server.setPort(port);
server.setMaxThreads(maxThreads.intValue());
server.setNotifyBySubscription(notifyBySubscription.booleanValue());
server.start();
r1.getCache().getDistributedSystem().getLogWriter().info("Started server on port " + server.getPort());
return new Integer(server.getPort());
}
use of org.apache.geode.cache.PartitionAttributesFactory in project geode by apache.
the class ParallelGatewaySenderQueueJUnitTest method mockPR.
private PartitionedRegion mockPR(String name) {
PartitionedRegion region = mock(PartitionedRegion.class);
when(region.getFullPath()).thenReturn(name);
when(region.getPartitionAttributes()).thenReturn(new PartitionAttributesFactory<>().create());
when(region.getTotalNumberOfBuckets()).thenReturn(113);
when(region.getDataPolicy()).thenReturn(DataPolicy.PARTITION);
return region;
}
use of org.apache.geode.cache.PartitionAttributesFactory in project geode by apache.
the class MyGatewayEventSubstitutionFilter method createPartitionedRegion.
public static void createPartitionedRegion(String regionName, String senderIds, Integer redundantCopies, Integer totalNumBuckets) {
IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
IgnoredException exp1 = IgnoredException.addIgnoredException(PartitionOfflineException.class.getName());
try {
AttributesFactory fact = new AttributesFactory();
if (senderIds != null) {
StringTokenizer tokenizer = new StringTokenizer(senderIds, ",");
while (tokenizer.hasMoreTokens()) {
String senderId = tokenizer.nextToken();
// GatewaySender sender = cache.getGatewaySender(senderId);
// assertNotNull(sender);
fact.addGatewaySenderId(senderId);
}
}
PartitionAttributesFactory pfact = new PartitionAttributesFactory();
pfact.setTotalNumBuckets(totalNumBuckets);
pfact.setRedundantCopies(redundantCopies);
pfact.setRecoveryDelay(0);
fact.setPartitionAttributes(pfact.create());
Region r = cache.createRegionFactory(fact.create()).create(regionName);
assertNotNull(r);
} finally {
exp.remove();
exp1.remove();
}
}
use of org.apache.geode.cache.PartitionAttributesFactory in project geode by apache.
the class MyGatewayEventSubstitutionFilter method createPRWithRedundantCopyWithAsyncEventQueue.
/**
* Create PartitionedRegion with 1 redundant copy
*/
public static void createPRWithRedundantCopyWithAsyncEventQueue(String regionName, String asyncEventQueueId, Boolean offHeap) throws InterruptedException {
IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
CountDownLatch recoveryDone = new CountDownLatch(2);
ResourceObserver observer = new InternalResourceManager.ResourceObserverAdapter() {
@Override
public void recoveryFinished(Region region) {
recoveryDone.countDown();
}
};
InternalResourceManager.setResourceObserver(observer);
try {
AttributesFactory fact = new AttributesFactory();
PartitionAttributesFactory pfact = new PartitionAttributesFactory();
pfact.setTotalNumBuckets(16);
pfact.setRedundantCopies(1);
fact.setPartitionAttributes(pfact.create());
fact.setOffHeap(offHeap);
Region r = cache.createRegionFactory(fact.create()).addAsyncEventQueueId(asyncEventQueueId).create(regionName);
assertNotNull(r);
recoveryDone.await();
} finally {
exp.remove();
}
}
use of org.apache.geode.cache.PartitionAttributesFactory in project geode by apache.
the class MyGatewayEventSubstitutionFilter method createPartitionedRegionAccessorWithAsyncEventQueue.
public static void createPartitionedRegionAccessorWithAsyncEventQueue(String regionName, String asyncEventQueueId) {
AttributesFactory fact = new AttributesFactory();
PartitionAttributesFactory pfact = new PartitionAttributesFactory();
pfact.setTotalNumBuckets(16);
pfact.setLocalMaxMemory(0);
fact.setPartitionAttributes(pfact.create());
Region r = cache.createRegionFactory(fact.create()).addAsyncEventQueueId(asyncEventQueueId).create(regionName);
// fact.create()).create(regionName);
assertNotNull(r);
}
Aggregations