private PartitionMemberInfoImpl buildDetails(InternalDistributedMember id, float weight, long localMaxMemory, long[] loads, long[] primaryLoads) { PRLoad load1 = new PRLoad(loads.length, weight); int size = 0; int primaryCount = 0; int bucketCount = 0; long[] bucketSizes = new long[loads.length]; for(int i = 0; i < loads.length; i++) { load1.addBucket(i, loads[i], primaryLoads[i]); bucketSizes[i] = loads[i]; size+= bucketSizes[i]; if(loads[i] != 0) { bucketCount++; } if(primaryLoads[i] != 0) { primaryCount++; } } PartitionMemberInfoImpl details1 = new PartitionMemberInfoImpl(id, localMaxMemory, size, bucketCount, primaryCount, load1, bucketSizes); return details1; }
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { super.fromData(in); byte flag = in.readByte(); if (flag != NO_PARTITION) { this.configuredMaxMemory = in.readLong(); this.size = in.readLong(); this.bucketCount = in.readInt(); this.primaryCount = in.readInt(); if (flag == OK_INTERNAL) { this.prLoad = PRLoad.createFromDataInput(in); this.bucketSizes = DataSerializer.readLongArray(in); this.offlineDetails = new OfflineMemberDetailsImpl(); InternalDataSerializer.invokeFromData(this.offlineDetails, in); } } }
memberDetails.getPRLoad().getWeight(), memberDetails.getConfiguredMaxMemory(), isCritical, enforceLocalMaxMemory); regionMember.put(memberId, member); if(load.getReadLoad(i) > 0) { Bucket bucket = regionBuckets[i]; if(bucket == null) { Set<PersistentMemberID> offlineMembers = offlineDetails.getOfflineMembers(i); bucket = new Bucket(i, load.getReadLoad(i), memberDetails.getBucketSize(i), offlineMembers); regionBuckets[i] = bucket; if(load.getWriteLoad(i) > 0) { if(bucket.getPrimary() == null) { bucket.setPrimary(member, load.getWriteLoad(i)); } else if(!bucket.getPrimary().equals(member)) { bucket.setPrimary(INVALID_MEMBER, 1);
/** * Creates a new immutable instance of PRLoad from the provided DataInput. * Actually {@link #addBucket(int, float, float)} will allow the bucket * loads to be mutated. * * @param in the input stream to gather state from * @return new immutable instance of PRLoad * @throws IOException if DataSerializer failed to read object from input * stream * @throws ClassNotFoundException if DataSerializer failed to find class to * read object from input */ public static PRLoad createFromDataInput(DataInput in) throws IOException, ClassNotFoundException { float weight = in.readFloat(); float[] bucketReadLoads = DataSerializer.readFloatArray(in); float[] bucketWriteLoads = DataSerializer.readFloatArray(in); return new PRLoad(weight, bucketReadLoads, bucketWriteLoads); }
assertNotNull(load); assertEquals((float)localMaxMemory[membersIdx], load.getWeight()); assertEquals((float)bucketBytes, load.getReadLoad(bid)); if (load.getWriteLoad(bid) > 0) { // found a primary primaryCount++;
/** * Creates a new immutable instance of PRLoad from the provided DataInput. * Actually {@link #addBucket(int, float, float)} will allow the bucket * loads to be mutated. * * @param in the input stream to gather state from * @return new immutable instance of PRLoad * @throws IOException if DataSerializer failed to read object from input * stream * @throws ClassNotFoundException if DataSerializer failed to find class to * read object from input */ public static PRLoad createFromDataInput(DataInput in) throws IOException, ClassNotFoundException { float weight = in.readFloat(); float[] bucketReadLoads = DataSerializer.readFloatArray(in); float[] bucketWriteLoads = DataSerializer.readFloatArray(in); return new PRLoad(weight, bucketReadLoads, bucketWriteLoads); }
memberDetails.getPRLoad().getWeight(), memberDetails.getConfiguredMaxMemory(), isCritical, enforceLocalMaxMemory); regionMember.put(memberId, member); if(load.getReadLoad(i) > 0) { Bucket bucket = regionBuckets[i]; if(bucket == null) { Set<PersistentMemberID> offlineMembers = offlineDetails.getOfflineMembers(i); bucket = new Bucket(i, load.getReadLoad(i), memberDetails.getBucketSize(i), offlineMembers); regionBuckets[i] = bucket; if(load.getWriteLoad(i) > 0) { if(bucket.getPrimary() == null) { bucket.setPrimary(member, load.getWriteLoad(i)); } else if(!bucket.getPrimary().equals(member)) { bucket.setPrimary(INVALID_MEMBER, 1);
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; }
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { super.fromData(in); byte flag = in.readByte(); if (flag != NO_PARTITION) { this.configuredMaxMemory = in.readLong(); this.size = in.readLong(); this.bucketCount = in.readInt(); this.primaryCount = in.readInt(); if (flag == OK_INTERNAL) { this.prLoad = PRLoad.createFromDataInput(in); this.bucketSizes = DataSerializer.readLongArray(in); this.offlineDetails = new OfflineMemberDetailsImpl(); InternalDataSerializer.invokeFromData(this.offlineDetails, in); } } }
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; }
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; }
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; }