/** * Creates an instance of <code>FixedPartitionAttributes</code>. * * @param name Name of the fixed partition. */ public static FixedPartitionAttributes createFixedPartition(String name) { return new FixedPartitionAttributesImpl().setPartitionName(name) .isPrimary(DEFAULT_PRIMARY_STATUS).setNumBuckets(DEFAULT_NUM_BUCKETS); }
int largestStartBucId = -1; for (FixedPartitionAttributesImpl fpa : elderFPAs) { if (fpa.getStartingBucketID() > largestStartBucId) { largestStartBucId = fpa.getStartingBucketID(); startingBucketID = largestStartBucId + fpa.getNumBuckets(); if (elderFPAs != null && elderFPAs.contains(fpaImpl)) { for (FixedPartitionAttributesImpl remotefpa : elderFPAs) { if (remotefpa.equals(fpaImpl)) { fpaImpl.setStartingBucketID(remotefpa.getStartingBucketID()); fpaImpl.setStartingBucketID(startingBucketID); startingBucketID += fpaImpl.getNumBuckets(); this.partitionsMap.put(fxPrAttr.getPartitionName(), new Integer[] {fxPrAttr.getStartingBucketID(), fxPrAttr.getNumBuckets()});
public boolean hasBucket(int bucketId) { return getStartingBucketID() <= bucketId && bucketId <= getLastBucketID(); }
private boolean isLocalPrimary(String partitionName) { List<FixedPartitionAttributesImpl> FPAs = this.prRegion.getFixedPartitionAttributesImpl(); if (FPAs != null) { for (FixedPartitionAttributesImpl fpa : FPAs) { if (fpa.getPartitionName().equals(partitionName) && fpa.isPrimary()) { return true; } } } return false; }
@Test public void testEqualsForNonEqualInstances() { FixedPartitionAttributesImpl fixedPartitionAttributes1 = new FixedPartitionAttributesImpl(); fixedPartitionAttributes1.setPartitionName("setPartitionName1"); FixedPartitionAttributesImpl fixedPartitionAttributes2 = new FixedPartitionAttributesImpl(); fixedPartitionAttributes2.setPartitionName("setPartitionName2"); PartitionAttributesImpl instance = new PartitionAttributesImpl(); fillInForEqualityTest(instance); instance.addFixedPartitionAttributes(fixedPartitionAttributes1); PartitionAttributesImpl other = new PartitionAttributesImpl(); fillInForEqualityTest(other); other.addFixedPartitionAttributes(fixedPartitionAttributes2); assertNotEquals(instance, other); }
if (fpaList != null) { for (FixedPartitionAttributesImpl fpa : fpaList) { if (fpa.hasBucket(bid)) { startingBucketID = fpa.getStartingBucketID(); partitionName = fpa.getPartitionName(); break; if (fpa.getPartitionName().equals(this.diskRegion.getPartitionName()) && this.diskRegion.getStartingBucketId() != -1) { fpa.setStartingBucketID(this.diskRegion.getStartingBucketId()); partitionedRegion.getPartitionsMap().put(fpa.getPartitionName(), new Integer[] {fpa.getStartingBucketID(), fpa.getNumBuckets()});
private void updatePartitionMap(PartitionRegionConfig prConfig) { int prId = prConfig.getPRId(); PartitionedRegion pr = null; try { pr = PartitionedRegion.getPRFromId(prId); if (pr != null) { Map<String, Integer[]> partitionMap = pr.getPartitionsMap(); for (FixedPartitionAttributesImpl fxPrAttr : prConfig.getElderFPAs()) { partitionMap.put(fxPrAttr.getPartitionName(), new Integer[] {fxPrAttr.getStartingBucketID(), fxPrAttr.getNumBuckets()}); } } } catch (PRLocallyDestroyedException e) { logger.debug("PRLocallyDestroyedException : Region ={} is locally destroyed on this node", prConfig.getPRId(), e); } } }
public int hashCode() { return this.getPartitionName().hashCode(); }
@Override public boolean include(Profile profile) { if (profile instanceof PartitionProfile) { PartitionProfile p = (PartitionProfile) profile; if (p.fixedPAttrs != null) { for (FixedPartitionAttributesImpl fpa : p.fixedPAttrs) { if (fpa.isPrimary() && fpa.hasBucket(bucketId)) { fixedPartitionDataStore.add(0, p.getDistributedMember()); return true; } } } } return false; } });
private void assignStartingBucketAdvisorIfFixedPartitioned() { if (startingBucketAdvisor != null) { // already assigned return; } if (this.pRegion.isFixedPartitionedRegion()) { List<FixedPartitionAttributesImpl> fpas = this.pRegion.getFixedPartitionAttributesImpl(); if (fpas != null) { int bucketId = getBucket().getId(); for (FixedPartitionAttributesImpl fpa : fpas) { if (fpa.hasBucket(bucketId) && bucketId != fpa.getStartingBucketID()) { startingBucketAdvisor = this.regionAdvisor.getBucketAdvisor(fpa.getStartingBucketID()); break; } } } } }
int numSecondaries = 0; for (FixedPartitionAttributes otherfpa : allSameFPAs) { if (fpa.getNumBuckets() != otherfpa.getNumBuckets()) { throw new IllegalStateException( String.format( "For region %s,for partition %s, num-buckets are not same (%s, %s)across nodes.", this.pr.getName(), fpa.getPartitionName(), fpa.getNumBuckets(), otherfpa.getNumBuckets())); "For region %s, number of secondary partitions %s of a partition %s should never exceed number of redundant copies %s.", this.pr.getName(), numSecondaries, fpa.getPartitionName(), this.pr.getRedundantCopies()));
public static FixedPartitionAttributesImpl getFixedPartitionAttributesForBucket( PartitionedRegion pr, int bucketId) { List<FixedPartitionAttributesImpl> localFPAs = pr.getFixedPartitionAttributesImpl(); if (localFPAs != null) { for (FixedPartitionAttributesImpl fpa : localFPAs) { if (fpa.hasBucket(bucketId)) { return fpa; } } } List<FixedPartitionAttributesImpl> remoteFPAs = pr.getRegionAdvisor().adviseAllFixedPartitionAttributes(); for (FixedPartitionAttributesImpl fpa : remoteFPAs) { if (fpa.hasBucket(bucketId)) { return fpa; } } Object[] prms = new Object[] {pr.getName(), bucketId}; throw new PartitionNotAvailableException( String.format( "For FixedPartitionedRegion %s, Fixed partition is not defined for bucket id %s on any datastore", prms)); }
FixedPartitionAttributesImpl fpa = PartitionedRegionHelper.getFixedPartitionAttributesForBucket(this, bucketId); partitionName = fpa.getPartitionName(); int startBucketId = fpa.getStartingBucketID(); if (startBucketId == -1) { throw new PartitionNotAvailableException(
@Override public boolean include(final Profile profile) { if (profile instanceof PartitionProfile) { final PartitionProfile pp = (PartitionProfile) profile; List<FixedPartitionAttributesImpl> fpaList = pp.fixedPAttrs; if (fpaList != null) { for (FixedPartitionAttributesImpl fpa : fpaList) { if (fpa.isPrimary()) { remotePrimaryFPAs.add(fpa); return true; } } } } return false; } });
totalFPABuckets += fpa.getNumBuckets(); attrList.add(fpa.getNumBuckets()); attrList.add(((FixedPartitionAttributesImpl) fpa).getStartingBucketID()); fixedPAMap.put(fpa.getPartitionName(), attrList);
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(); }
@Test public void testEqualsAndHashCodeForEqualInstances() { this.fixedPartitionAttributes = new FixedPartitionAttributesImpl(); this.fixedPartitionAttributes.setPartitionName("setPartitionName"); PartitionAttributesImpl instance = new PartitionAttributesImpl(); fillInForEqualityTest(instance); instance.addFixedPartitionAttributes(this.fixedPartitionAttributes); PartitionAttributesImpl other = new PartitionAttributesImpl(); fillInForEqualityTest(other); other.addFixedPartitionAttributes(this.fixedPartitionAttributes); assertEquals(instance.hashCode(), other.hashCode()); assertEquals(instance, other); }
if (fpa.getPartitionName().equals(partition)) { isPartitionAvailable = true; partitionNumBuckets = fpa.getNumBuckets(); startingBucketID = fpa.getStartingBucketID(); break; pr.getRegionAdvisor().adviseAllFixedPartitionAttributes(); for (FixedPartitionAttributesImpl fpa : remoteFPAs) { if (fpa.getPartitionName().equals(partition)) { isPartitionAvailable = true; partitionNumBuckets = fpa.getNumBuckets(); startingBucketID = fpa.getStartingBucketID(); break;
public boolean equals(final Object obj) { if (obj == null) { return false; } if (this == obj) { return true; } if (!(obj instanceof FixedPartitionAttributesImpl)) { return false; } FixedPartitionAttributesImpl spr = (FixedPartitionAttributesImpl) obj; if (spr.getPartitionName().equals(this.getPartitionName())) { return true; } return false; }