public static void createReplicatedRegionWithSenderAndAsyncEventQueue(String regionName, String senderIds, String asyncChannelId, Boolean offHeap) { IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName()); try { AttributesFactory fact = new AttributesFactory(); if (senderIds != null) { StringTokenizer tokenizer = new StringTokenizer(senderIds, ","); while (tokenizer.hasMoreTokens()) { String senderId = tokenizer.nextToken(); fact.addGatewaySenderId(senderId); } } fact.setDataPolicy(DataPolicy.REPLICATE); fact.setOffHeap(offHeap); fact.setScope(Scope.DISTRIBUTED_ACK); RegionFactory regionFactory = cache.createRegionFactory(fact.create()); regionFactory.addAsyncEventQueueId(asyncChannelId); Region r = regionFactory.create(regionName); assertNotNull(r); } finally { exp.remove(); } }
/** * 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(); } }
public static void createPartitionedRegionWithAsyncEventQueue(String regionName, String asyncEventQueueId, Boolean offHeap) { IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName()); IgnoredException exp1 = IgnoredException.addIgnoredException(PartitionOfflineException.class.getName()); try { AttributesFactory fact = new AttributesFactory(); PartitionAttributesFactory pfact = new PartitionAttributesFactory(); pfact.setTotalNumBuckets(16); fact.setPartitionAttributes(pfact.create()); fact.setOffHeap(offHeap); Region r = cache.createRegionFactory(fact.create()).addAsyncEventQueueId(asyncEventQueueId) .create(regionName); assertNotNull(r); } finally { exp.remove(); exp1.remove(); } }
public static void createColocatedPartitionedRegionWithAsyncEventQueue(String regionName, String asyncEventQueueId, Integer totalNumBuckets, String colocatedWith) { IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName()); IgnoredException exp1 = IgnoredException.addIgnoredException(PartitionOfflineException.class.getName()); try { AttributesFactory fact = new AttributesFactory(); PartitionAttributesFactory pfact = new PartitionAttributesFactory(); pfact.setTotalNumBuckets(totalNumBuckets); pfact.setColocatedWith(colocatedWith); fact.setPartitionAttributes(pfact.create()); Region r = cache.createRegionFactory(fact.create()).addAsyncEventQueueId(asyncEventQueueId) .create(regionName); assertNotNull(r); } finally { exp.remove(); exp1.remove(); } }
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); }
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); }
public static void createFixedPartitionedRegionWithAsyncEventQueue(String regionName, String asyncEventQueueId, String partitionName, final List<String> allPartitions, boolean offHeap) { IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName()); IgnoredException exp1 = IgnoredException.addIgnoredException(PartitionOfflineException.class.getName()); try { AttributesFactory fact = new AttributesFactory(); PartitionAttributesFactory pfact = new PartitionAttributesFactory(); pfact.setTotalNumBuckets(16); pfact.addFixedPartitionAttributes( FixedPartitionAttributes.createFixedPartition(partitionName, true)); pfact.setPartitionResolver(new MyFixedPartitionResolver(allPartitions)); fact.setPartitionAttributes(pfact.create()); fact.setOffHeap(offHeap); Region r = cache.createRegionFactory(fact.create()).addAsyncEventQueueId(asyncEventQueueId) .create(regionName); assertNotNull(r); } finally { exp.remove(); exp1.remove(); } }
.forEach(gsi -> factory.addAsyncEventQueueId(gsi));
.forEach(asyncEventQueue -> regionFactory.addAsyncEventQueueId(asyncEventQueue.getId()));
.forEach(asyncEventQueue -> regionFactory.addAsyncEventQueueId(asyncEventQueue.getId()));
.map(RegionAttributes::getGatewaySenderIds).orElse(null))); when(mockRegionFactory.addAsyncEventQueueId(anyString())) .thenAnswer(newAdder(asyncEventQueueIds, mockRegionFactory));