private boolean[] getBucketSet(Set<Integer> bucketSet) { if (bucketSet != null) { int maxBucketId = ((PartitionedRegion)this.baseRegion).getTotalNumberOfBuckets(); boolean[] buckets = new boolean[maxBucketId + 1]; for (int b : bucketSet) { buckets[b] = true; } return buckets; } return null; }
public static int getHashKey(PartitionedRegion pr, Object routingObject) { return getHashKey(routingObject, pr.getTotalNumberOfBuckets()); }
public static int getHashKey(PartitionedRegion pr, Object routingObject) { return getHashKey(routingObject, pr.getTotalNumberOfBuckets()); }
public Object call() throws Exception { PartitionedRegion pr = (PartitionedRegion)cache.getRegion(regionName); final HashSet testKeysSet = new HashSet(); for (int i = (pr.getTotalNumberOfBuckets() * 2); i > 0; i--) { testKeysSet.add("execKey-" + i); } int j = 0; HashSet origVals = new HashSet(); for (Iterator i = testKeysSet.iterator(); i.hasNext();) { Integer val = new Integer(j++); origVals.add(val); pr.put(i.next(), val); } return Boolean.TRUE; } });
public Object call() throws Exception { PartitionedRegion pr = (PartitionedRegion)cache.getRegion(regionName); final HashSet testKeysSet = new HashSet(); for (int i = (pr.getTotalNumberOfBuckets() * 2); i > 0; i--) { testKeysSet.add("execKey-" + i); } int j = 0; HashSet origVals = new HashSet(); for (Iterator i = testKeysSet.iterator(); i.hasNext();) { Integer val = new Integer(j++); origVals.add(val); pr.put(i.next(), val); } return Boolean.TRUE; } });
public Set keysWithoutCreatesForTests() { checkReadiness(); Set<Integer> availableBuckets = new HashSet<Integer>(); for(int i =0; i < getTotalNumberOfBuckets(); i++) { if(distAdvisor.isStorageAssignedForBucket(i)) { availableBuckets.add(Integer.valueOf(i)); } } return Collections.unmodifiableSet(new KeysSet(availableBuckets)); }
public Set keysWithoutCreatesForTests() { checkReadiness(); Set<Integer> availableBuckets = new HashSet<Integer>(); for(int i =0; i < getTotalNumberOfBuckets(); i++) { if(distAdvisor.isStorageAssignedForBucket(i)) { availableBuckets.add(Integer.valueOf(i)); } } return Collections.unmodifiableSet(new KeysSet(availableBuckets, getTXState())); }
private static void getPRMetaData(final PartitionedRegion region, final String tableName, final String[] partColumns, final int[] bucketCount, final Clob[] bucketToServerMapping) throws SQLException { bucketCount[0] = region.getTotalNumberOfBuckets(); // get partitioning columns GfxdPartitionByExpressionResolver resolver = (GfxdPartitionByExpressionResolver)region.getPartitionResolver(); StringBuilder stringBuffer = new StringBuilder(); for (String col : resolver.getColumnNames()) { stringBuffer.append(col).append(':'); } partColumns[0] = stringBuffer.toString(); // bucket to server mapping GET_BUCKET_TO_SERVER_MAPPING2(tableName, bucketToServerMapping); }
public void run2() throws CacheException { Cache cache = getCache(); PartitionedRegion pr = (PartitionedRegion) cache.getRegion(regionName); Integer k; for(int i=pr.getTotalNumberOfBuckets()*2; i>=0; --i) { k=new Integer(i); assertTrue("containsKey for key="+k, pr.containsKey(k)); assertEquals("get for key="+k, value, pr.get(k)); } } };
public void run2() throws CacheException { Cache cache = getCache(); PartitionedRegion pr = (PartitionedRegion)cache .getRegion(Region.SEPARATOR + parentRegionName + Region.SEPARATOR + childRegionName + Region.SEPARATOR + PR_PREFIX); for (int i = 0; i < pr.getTotalNumberOfBuckets(); i++) { // Assume creating total number of bucket keys creates the maximum amount of buckets pr.put(new Integer(i), i + ""); } } };
public void run2() throws CacheException { Cache cache = getCache(); PartitionedRegion pr = (PartitionedRegion) cache.getRegion(regionName); assertTrue(pr.isEmpty()); Integer k; // Create keys such that all buckets are created, Integer works well // assuming buckets are allocated on the mod of the key hashCode, x 2 just to be safe final int numEntries=pr.getTotalNumberOfBuckets()*2; for(int i=numEntries; i>=0; --i) { k = new Integer(i); pr.put(k, value); } assertEquals(numEntries+1,pr.size()); assertEquals(pr.getRegionAdvisor().getBucketSet().size(), pr.getTotalNumberOfBuckets()); } }
public void run2() throws CacheException { for (int rs = 0; rs < regions.length; rs++) { PartitionedRegion p = (PartitionedRegion) getCache().getRegion(regions[rs]); assertNotNull(p); assertEquals(3, p.getTotalNumberOfBuckets()); // Create one bucket p.put(new Integer(0), "zero"); assertEquals(1, p.getRegionAdvisor().getCreatedBucketsCount()); } } });
public void run2() throws CacheException { String[] regions = {rName0, rName1, rName2}; for (int rs = 0; rs < regions.length; rs++) { PartitionedRegion p = (PartitionedRegion) getCache().getRegion(regions[rs]); assertNotNull(p); assertTrue(!p.isDestroyed()); assertEquals(numBuckets, p.getTotalNumberOfBuckets()); try { for(int i = 0; i < p.getTotalNumberOfBuckets(); i++) { assertEquals(0, p.getRegionAdvisor().getBucketOwners(i).size()); assertEquals(0, p.getBucketOwnersForValidation(i).size()); } } catch (ForceReattemptException noGood) { fail("Unexpected force retry", noGood); } } } };
public long generateTailKey() { long key = this.eventSeqNum.addAndGet(this.partitionedRegion .getTotalNumberOfBuckets()); if (key < 0 || key % getPartitionedRegion().getTotalNumberOfBuckets() != getId()) { logger .error(LocalizedMessage .create( LocalizedStrings.GatewaySender_SEQUENCENUMBER_GENERATED_FOR_EVENT_IS_INVALID, new Object[] { key, getId() })); } if (logger.isDebugEnabled()) { logger.debug("WAN: On primary bucket {}, setting the seq number as {}", getId(), this.eventSeqNum.get()); } return eventSeqNum.get(); }
private static int getNumberOfBuckets(PartitionedRegion pr) { if (pr.isFixedPartitionedRegion()) { int numBuckets = 0; Set<FixedPartitionAttributesImpl> fpaSet = new HashSet<FixedPartitionAttributesImpl>( pr.getRegionAdvisor().adviseAllFixedPartitionAttributes()); if (pr.getFixedPartitionAttributesImpl() != null) { fpaSet.addAll(pr.getFixedPartitionAttributesImpl()); } for (FixedPartitionAttributesImpl fpa : fpaSet) { numBuckets = numBuckets + fpa.getNumBuckets(); } return numBuckets; } return pr.getTotalNumberOfBuckets(); }
private static int getNumberOfBuckets(PartitionedRegion pr) { if (pr.isFixedPartitionedRegion()) { int numBuckets = 0; Set<FixedPartitionAttributesImpl> fpaSet = new HashSet<FixedPartitionAttributesImpl>( pr.getRegionAdvisor().adviseAllFixedPartitionAttributes()); if (pr.getFixedPartitionAttributesImpl() != null) { fpaSet.addAll(pr.getFixedPartitionAttributesImpl()); } for (FixedPartitionAttributesImpl fpa : fpaSet) { numBuckets = numBuckets + fpa.getNumBuckets(); } return numBuckets; } return pr.getTotalNumberOfBuckets(); }
public static Object executeFunction() { PartitionedRegion pr = (PartitionedRegion)cache.getRegion(regionName); final HashSet testKeysSet = new HashSet(); for (int i = (pr.getTotalNumberOfBuckets() * 2); i > 0; i--) { testKeysSet.add("execKey-" + i); } Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_HA); FunctionService.registerFunction(function); Execution dataSet = FunctionService.onRegion(pr); ResultCollector rs = dataSet.withFilter(testKeysSet).withArgs(Boolean.TRUE) .execute(function.getId()); List l = ((List)rs.getResult()); return l; }
public void run2() { Cache cache = getCache(); for (int j = 0; j < MAX_REGIONS; j++) { PartitionedRegion pr = (PartitionedRegion)cache .getRegion(Region.SEPARATOR + rName + j); assertNotNull(pr); int numBuckets = pr.getTotalNumberOfBuckets(); Integer key; for (int k = 0; k < numBuckets; k++) { key = new Integer(k); pr.put(key, rName + k); } getLogWriter() .info("VM0 Done put successfully for PR = " + rName + j); } } });
protected void createMissingBuckets(PartitionedRegion region) { PartitionedRegion parentRegion = ColocationHelper.getColocatedRegion(region); if(parentRegion == null) { return; } // Fix for 48954 - Make sure the parent region has created missing buckets // before we create missing buckets for this child region. createMissingBuckets(parentRegion); for (int i = 0; i < region .getTotalNumberOfBuckets(); i++) { if(parentRegion.getRegionAdvisor().getBucketAdvisor(i) .getBucketRedundancy() != region.getRegionAdvisor().getBucketAdvisor(i).getBucketRedundancy()){ /*if (leaderRegion.getRegionAdvisor().isStorageAssignedForBucket(i)) {*/ final long startTime = PartitionedRegionStats.startTime(); region.getRedundancyProvider().createBucketAtomically(i, 0, startTime, true, null); } } } }
protected void createMissingBuckets(PartitionedRegion region) { PartitionedRegion parentRegion = ColocationHelper.getColocatedRegion(region); if(parentRegion == null) { return; } // Fix for 48954 - Make sure the parent region has created missing buckets // before we create missing buckets for this child region. createMissingBuckets(parentRegion); for (int i = 0; i < region .getTotalNumberOfBuckets(); i++) { if(parentRegion.getRegionAdvisor().getBucketAdvisor(i) .getBucketRedundancy() != region.getRegionAdvisor().getBucketAdvisor(i).getBucketRedundancy()){ /*if (leaderRegion.getRegionAdvisor().isStorageAssignedForBucket(i)) {*/ final long startTime = PartitionedRegionStats.startTime(); region.getRedundancyProvider().createBucketAtomically(i, 0, startTime, true, null); } } } }