public static Region createFixedPartitionedRegion(final Cache cache, String regionName, List<FixedPartitionAttributes> fpaList, int localMaxMemory) { List<String> allPartitions = new ArrayList(); if (fpaList != null) { for (FixedPartitionAttributes fpa : fpaList) { allPartitions.add(fpa.getPartitionName()); } } else { allPartitions.add("Q1"); allPartitions.add("Q2"); } AttributesFactory fact = new AttributesFactory(); PartitionAttributesFactory pfact = new PartitionAttributesFactory(); pfact.setTotalNumBuckets(16); pfact.setRedundantCopies(1); pfact.setLocalMaxMemory(localMaxMemory); if (fpaList != null) { for (FixedPartitionAttributes fpa : fpaList) { pfact.addFixedPartitionAttributes(fpa); } } pfact.setPartitionResolver(new MyFixedPartitionResolver(allPartitions)); fact.setPartitionAttributes(pfact.create()); Region r = cache.createRegionFactory(fact.create()).create(regionName); assertNotNull(r); return r; }
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(); } }
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(); } }
/** * This method creates a partitioned region with all the default values. The cache created is a * loner, so this is only suitable for single VM tests. * */ public static Region createPartionedRegion(String regionname) throws RegionExistsException { return createPartionedRegion(regionname, new PartitionAttributesFactory().create()); }
private PartitionAttributesFactory configureLuceneRegionAttributesFactory( PartitionAttributesFactory attributesFactory, PartitionAttributes<?, ?> dataRegionAttributes) { attributesFactory.setTotalNumBuckets(dataRegionAttributes.getTotalNumBuckets()); attributesFactory.setRedundantCopies(dataRegionAttributes.getRedundantCopies()); attributesFactory.setPartitionResolver(getPartitionResolver(dataRegionAttributes)); attributesFactory.setRecoveryDelay(dataRegionAttributes.getRecoveryDelay()); attributesFactory.setStartupRecoveryDelay(dataRegionAttributes.getStartupRecoveryDelay()); return attributesFactory; }
/** * This function creates Region attributes with provided scope,redundancy and localmaxMemory */ public static RegionAttributes createRegionAttrsForPR(int red, int localMaxMem, long recoveryDelay, EvictionAttributes evictionAttrs, PartitionResolver resolver) { AttributesFactory attr = new AttributesFactory(); attr.setDataPolicy(DataPolicy.PARTITION); PartitionAttributesFactory paf = new PartitionAttributesFactory(); paf.setRedundantCopies(red).setLocalMaxMemory(localMaxMem).setRecoveryDelay(recoveryDelay); if (resolver != null) { paf.setPartitionResolver(resolver); } PartitionAttributes<?, ?> prAttr = paf.create(); attr.setPartitionAttributes(prAttr); attr.setEvictionAttributes(evictionAttrs); return attr.create(); }
Region pr = null; PartitionAttributes pa; PartitionAttributesFactory paf = new PartitionAttributesFactory(); AttributesFactory af = new AttributesFactory(); RegionAttributes ra; "localMaxMemory must be an integer (" + localMaxMemory + ")"); pa = paf.setLocalMaxMemory(lmax).setRedundantCopies(redundancy).create();
PartitionAttributesFactory pfact = new PartitionAttributesFactory(); pfact.setTotalNumBuckets(userPR.getTotalNumberOfBuckets()); pfact.setRedundantCopies(userPR.getRedundantCopies()); pfact.setColocatedWith(regionName); pfact.setLocalMaxMemory(localMaxMemory); pfact.setStartupRecoveryDelay(userPR.getPartitionAttributes().getStartupRecoveryDelay()); pfact.setRecoveryDelay(userPR.getPartitionAttributes().getRecoveryDelay()); fact.setPartitionAttributes(pfact.create());
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 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 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(); } }
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); }
protected <K, V> Region<K, V> createRegion(final String regionName, final RegionShortcut regionShortCut, final String colocatedWithRegionName, final PartitionAttributes partitionAttributes, final RegionAttributes regionAttributes, PartitionListener lucenePrimaryBucketListener) { PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory(); if (lucenePrimaryBucketListener != null) { partitionAttributesFactory.addPartitionListener(lucenePrimaryBucketListener); } partitionAttributesFactory.setColocatedWith(colocatedWithRegionName); configureLuceneRegionAttributesFactory(partitionAttributesFactory, partitionAttributes); // Create AttributesFactory based on input RegionShortcut RegionAttributes baseAttributes = this.cache.getRegionAttributes(regionShortCut.toString()); AttributesFactory factory = new AttributesFactory(baseAttributes); factory.setPartitionAttributes(partitionAttributesFactory.create()); if (regionAttributes.getDataPolicy().withPersistence()) { factory.setDiskStoreName(regionAttributes.getDiskStoreName()); } RegionAttributes<K, V> attributes = factory.create(); return createRegion(regionName, attributes); }
/** * @inheritDoc */ @Override public void afterPropertiesSet() throws Exception { nullSafeList(partitionListeners).forEach(partitionAttributesFactory::addPartitionListener); this.partitionAttributes = partitionAttributesFactory.create(); }
public void setTotalNumBuckets(int numBuckets) { this.partitionAttributesFactory.setTotalNumBuckets(numBuckets); } }
public void setRedundantCopies(int redundantCopies) { this.partitionAttributesFactory.setRedundantCopies(redundantCopies); }
public void setPartitionResolver(PartitionResolver<K, V> resolver) { this.partitionAttributesFactory.setPartitionResolver(resolver); }
public void setLocalMaxMemory(int mb) { this.partitionAttributesFactory.setLocalMaxMemory(mb); }
Position.resetCounter(); PartitionAttributesFactory paf = new PartitionAttributesFactory(); AttributesFactory af = new AttributesFactory();
public void setRecoveryDelay(long recoveryDelay) { this.partitionAttributesFactory.setRecoveryDelay(recoveryDelay); }