/** * 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); }
/** * 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); }
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; }
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(); 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; }