in ingest/src/main/java/com/microsoft/azure/kusto/ingest/resources/RankedStorageAccount.java [85:114]
public double getRank() {
if (buckets.isEmpty()) {
// Start assuming the account is good
return 1;
}
int bucketWeight = buckets.size() + 1;
double rank = 0;
double totalWeight = 0;
// For each bucket, calculate the success rate ( success / total ) and multiply it by the bucket weight.
// The older the bucket, the less weight it has. For example, if there are 3 buckets, the oldest bucket will have
// a weight of 1, the middle bucket will have a weight of 2 and the newest bucket will have a weight of 3.
try {
bucketsLock.readLock().lock();
for (Bucket bucket : buckets) {
if (bucket.totalCount == 0) {
bucketWeight--;
continue;
}
double successRate = (double) bucket.successCount / bucket.totalCount;
rank += successRate * bucketWeight;
totalWeight += bucketWeight;
bucketWeight--;
}
} finally {
bucketsLock.readLock().unlock();
}
return rank / totalWeight;
}