Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use topic level throughput information when partition level information is unavailable. #871

Merged
merged 6 commits into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,15 @@ public Map<String, Set<DatastreamTask>> assignPartitions(
LoadBasedPartitionAssignmentStrategyConfig.DEFAULT_PARTITION_MESSAGES_IN_RATE, "");
newPartitions.forEach((task, partitions) -> {
int totalThroughput = partitions.stream()
.mapToInt(p -> partitionInfoMap.getOrDefault(p, defaultPartitionInfo).getBytesInKBRate())
.mapToInt(p -> {
int index = p.lastIndexOf('-');
String topic = p;
if (index > -1) {
topic = p.substring(0, index);
}
PartitionThroughputInfo defaultValue = partitionInfoMap.getOrDefault(topic, defaultPartitionInfo);
return partitionInfoMap.getOrDefault(p, defaultValue).getBytesInKBRate();
})
.sum();
taskThroughputMap.put(task, totalThroughput);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,15 @@ public int getTaskCount(ClusterThroughputInfo throughputInfo, List<String> assig
LoadBasedPartitionAssignmentStrategyConfig.DEFAULT_PARTITION_MESSAGES_IN_RATE, "");
// total throughput in KB/sec
int totalThroughput = allPartitions.stream()
.map(p -> throughputMap.getOrDefault(p, defaultThroughputInfo))
.mapToInt(PartitionThroughputInfo::getBytesInKBRate)
.mapToInt(p -> {
int index = p.lastIndexOf('-');
String topic = p;
if (index > -1) {
topic = p.substring(0, index);
}
PartitionThroughputInfo defaultValue = throughputMap.getOrDefault(topic, defaultThroughputInfo);
return throughputMap.getOrDefault(p, defaultValue).getBytesInKBRate();
})
.sum();
LOG.info("Total throughput in all {} partitions: {}KB/sec", allPartitions.size(), totalThroughput);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,15 @@ public void partitionsHaveDefaultWeightTest() {
int taskCount = estimator.getTaskCount(throughputInfo, assignedPartitions, unassignedPartitions);
Assert.assertTrue(taskCount > 0);
}

@Test
public void throughputTaskEstimatorWithTopicLevelInformation() {
ClusterThroughputInfo throughputInfo = _provider.getThroughputInfo("fruit");
List<String> assignedPartitions = Collections.emptyList();
List<String> unassignedPartitions = Arrays.asList("apple-0", "apple-1", "apple-2", "banana-0");
LoadBasedTaskCountEstimator estimator = new LoadBasedTaskCountEstimator(TASK_CAPACITY_MBPS,
TASK_CAPACITY_UTILIZATION_PCT);
int taskCount = estimator.getTaskCount(throughputInfo, assignedPartitions, unassignedPartitions);
Assert.assertEquals(taskCount, 4);
}
}
4 changes: 4 additions & 0 deletions datastream-server/src/test/resources/partitionThroughput.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@
"donut" : {
"BostonCreme-1" : "bytesInKB: 5000, msgIn:200",
"BostonCreme-2" : "bytesInKB: 5000, msgIn:200"
},
"fruit" : {
"apple" : "bytesInKB: 10000, msgIn:300",
"apple-2" : "bytesInKb: 8000, msgIn:200"
}
}
}