@Override public int compare(InstanceTopicPartitionHolder o1, InstanceTopicPartitionHolder o2) { TopicWorkload workload1 = (o1 == null) ? new TopicWorkload(0, 0) : o1.totalWorkload(infoRetriever, weighter); TopicWorkload workload2 = (o2 == null) ? new TopicWorkload(0, 0) : o2.totalWorkload(infoRetriever, weighter); int cmp = workload1.compareTotal(workload2); if (cmp != 0) { return cmp; } // if workload is the same, compare them based on the number of partitions int size1 = (o1 == null) ? -1 : o1.getNumServingTopicPartitions(); int size2 = (o2 == null) ? -1 : o2.getNumServingTopicPartitions(); if (size1 != size2) { return size1 - size2; } else { return o1.getInstanceName().compareTo(o2.getInstanceName()); } } };
double weight = weighter.partitionWeight(tp); TopicWorkload tw = retriever.topicWorkload(tp.getTopic()); if (tw.compareTotal(averageWorkload) > 0) { excludeInstances++; totalWorkload.setMsgsPerSecond( if (workerWorkload.compareTotal(maxWorkload) <= 0) { break; highest.removeTopicPartition(tp); overloaded.add(tp); if (workloadToRemove.compareTotal(diff) >= 0) { break;