public static int getHashKey(PartitionedRegion pr, Object routingObject) { return getHashKey(routingObject, pr.getTotalNumberOfBuckets()); }
public Set keysWithoutCreatesForTests() { checkReadiness(); Set<Integer> availableBuckets = new HashSet<Integer>(); for (int i = 0; i < getTotalNumberOfBuckets(); i++) { if (distAdvisor.isStorageAssignedForBucket(i)) { availableBuckets.add(i); } } return Collections.unmodifiableSet(new KeysSet(availableBuckets)); }
public long generateTailKey() { long key = this.eventSeqNum.addAndGet(this.partitionedRegion.getTotalNumberOfBuckets()); if (key < 0 || key % getPartitionedRegion().getTotalNumberOfBuckets() != getId()) { logger.error("ERROR! The sequence number {} generated for the bucket {} is incorrect.", 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(); }
/** * validate that for all partitions defined across all datastores, sum of num-buckets is not more * than total-num-buckets defined */ private void validateFixedPartitionAttributesAgainstTotalNumberBuckets() { for (FixedPartitionAttributesImpl fpa : this.pr.getFixedPartitionAttributesImpl()) { int numBuckets = 0; Set<FixedPartitionAttributesImpl> allFPAs = new HashSet<FixedPartitionAttributesImpl>( this.pr.getRegionAdvisor().adviseAllFixedPartitionAttributes()); allFPAs.add(fpa); for (FixedPartitionAttributes samefpa : allFPAs) { numBuckets = numBuckets + samefpa.getNumBuckets(); } if (numBuckets > this.pr.getTotalNumberOfBuckets()) { throw new IllegalStateException( String.format( "For region %s,sum of num-buckets %s for different primary partitions should not be greater than total-num-buckets %s.", this.pr.getName(), numBuckets, this.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(); }
Assert.assertTrue(memoryRatio <= 1.0); final int totalBucketInstances = this.partitionedRegion.getTotalNumberOfBuckets() * (this.partitionedRegion.getRedundantCopies() + 1);
@Test public void verifyThatGetCallbackArgIsCorrectlyPassedToGetHashKey() { PartitionedRegion pr = mock(PartitionedRegion.class); when(pr.getTotalNumberOfBuckets()).thenReturn(33); LocalDataSet lds = new LocalDataSet(pr, Collections.emptySet()); LocalDataSet spy = spy(lds); Object key = "key"; Object callbackArg = "callbackArg"; spy.get(key, callbackArg); verify(spy).getHashKey(Operation.CONTAINS_KEY, key, null, callbackArg); } }
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; }
long key = this.eventSeqNum.addAndGet(this.partitionedRegion.getTotalNumberOfBuckets()); if (key < 0 || key % getPartitionedRegion().getTotalNumberOfBuckets() != getId()) { logger.error("ERROR! The sequence number {} generated for the bucket {} is incorrect.", new Object[] {key, getId()});
/** * Creates PartitionedRegionDataStore for dataStorage of PR and starts a PartitionService to * handle remote operations on this DataStore from other participating nodes. * * @param pr PartitionedRegion associated with this DataStore. */ PartitionedRegionDataStore(final PartitionedRegion pr) { final int bucketCount = pr.getTotalNumberOfBuckets(); this.localBucket2RegionMap = new ConcurrentHashMap<Integer, BucketRegion>(bucketCount); this.partitionedRegion = pr; this.bucketCreationLock = new StoppableReentrantReadWriteLock(pr.getCancelCriterion()); if (pr.getAttributes().getCacheLoader() != null) { this.loader = pr.getAttributes().getCacheLoader(); if (logger.isDebugEnabled()) { logger.debug("Installing cache loader from partitioned region attributes: {}", loader); } } // this.maximumLocalBytes = (long) (pr.getLocalMaxMemory() * // PartitionedRegionHelper.BYTES_PER_MB // * this.partitionedRegion.rebalanceThreshold); this.maximumLocalBytes = (pr.getLocalMaxMemory() * PartitionedRegionHelper.BYTES_PER_MB); // this.bucketStats = new CachePerfStats(pr.getSystem(), "partition-" + pr.getName()); this.bucketStats = new RegionPerfStats(pr.getCache(), pr.getCachePerfStats(), "partition-" + pr.getName()); this.keysOfInterest = new ConcurrentHashMap(); }
InternalDistributedMember localMember = (InternalDistributedMember) pr.getMyId(); int configuredBucketCount = pr.getTotalNumberOfBuckets(); long[] bucketSizes = new long[configuredBucketCount];
fileDataStore = Mockito.mock(PartitionedRegionDataStore.class); when(fileAndChunkRegion.getDataStore()).thenReturn(fileDataStore); when(fileAndChunkRegion.getTotalNumberOfBuckets()).thenReturn(113); when(fileAndChunkRegion.getFullPath()).thenReturn("FileRegion"); when(fileAndChunkRegion.getCache()).thenReturn(cache);
if (bucketId >= getTotalNumberOfBuckets()) { return Collections.emptyList();
int totalBuckets = getTotalNumberOfBuckets(); int retryAttempts = calcRetry(); for (int bucket = 0; bucket < totalBuckets; bucket++) {
PRPersistentConfig config = diskStore.getPersistentPRConfig(this.getFullPath()); if (config != null) { if (config.getTotalNumBuckets() != this.getTotalNumberOfBuckets()) { Object[] prms = new Object[] {this.getFullPath(), this.getTotalNumberOfBuckets(), config.getTotalNumBuckets()}; throw new IllegalStateException( config = new PRPersistentConfig(this.getTotalNumberOfBuckets(), colocatedWith); diskStore.addPersistentPR(this.getFullPath(), config);
@Override public PRLoad getLoad(PartitionedRegion pr) { PartitionedRegionDataStore ds = pr.getDataStore(); int configuredBucketCount = pr.getTotalNumberOfBuckets(); PRLoad prLoad = new PRLoad(configuredBucketCount, pr.getLocalMaxMemory()); // key: bid, value: size for (Integer bidInt : ds.getAllLocalBucketIds()) { int bid = bidInt.intValue(); BucketAdvisor bucketAdvisor = pr.getRegionAdvisor().getBucket(bid).getBucketAdvisor(); // Wait for a primary to exist for this bucket, because // it might be this member. bucketAdvisor.getPrimary(); boolean isPrimary = pr.getRegionAdvisor().getBucket(bid).getBucketAdvisor().isPrimary(); prLoad.addBucket(bid, 1, isPrimary ? 1 : 0); } return prLoad; }
int configuredBucketCount = pr.getTotalNumberOfBuckets(); int createdBucketCount = pr.getRegionAdvisor().getCreatedBucketsCount(); int lowRedundancyBucketCount = prStats.getLowRedundancyBucketCount();
@Override public PRLoad getLoad(PartitionedRegion pr) { PartitionedRegionDataStore ds = pr.getDataStore(); int configuredBucketCount = pr.getTotalNumberOfBuckets(); PRLoad prLoad = new PRLoad(configuredBucketCount, pr.getLocalMaxMemory()); // key: bid, value: size for (Integer bidInt : ds.getAllLocalBucketIds()) { int bid = bidInt.intValue(); long bucketSize = ds.getBucketSize(bid); if (bucketSize < MIN_BUCKET_SIZE) { bucketSize = MIN_BUCKET_SIZE; } BucketAdvisor bucketAdvisor = pr.getRegionAdvisor().getBucket(bid).getBucketAdvisor(); // Wait for a primary to exist for this bucket, because // it might be this member. bucketAdvisor.getPrimary(); boolean isPrimary = pr.getRegionAdvisor().getBucket(bid).getBucketAdvisor().isPrimary(); prLoad.addBucket(bid, bucketSize, isPrimary ? 1 : 0); } return prLoad; }
int totalNumberOfBuckets = leaderRegion.getTotalNumberOfBuckets(); Set<InternalDistributedMember> criticalMembers = resourceManager.getResourceAdvisor().adviseCriticalMembers();;
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); } } } }