Skip to content

Commit

Permalink
[AMORO-2376] Print right log info after calculating and sorting tables (
Browse files Browse the repository at this point in the history
#2377)

* [AMORO-2376] Print right log info after calculating and sorting tables

* change field type for schedulingpolicy
  • Loading branch information
tcodehuber authored Dec 4, 2023
1 parent dd316d4 commit 234874e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private TaskRuntime pollOrPlan() {
private void planTasks() {
long startTime = System.currentTimeMillis();
List<TableRuntime> scheduledTables = schedulingPolicy.scheduleTables();
LOG.debug("Calculating and sorting tables by quota : {}", scheduledTables);
LOG.debug("Calculating and sorting tables by {}: {}", schedulingPolicy.name(), scheduledTables);

if (scheduledTables.size() <= 0) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class SchedulingPolicy {
private static final String QUOTA = "quota";
private static final String BALANCED = "balanced";

private String policyName;

private final Map<ServerTableIdentifier, TableRuntime> tableRuntimeMap = new HashMap<>();
private Comparator<TableRuntime> tableSorter;
private final Lock tableLock = new ReentrantLock();
Expand All @@ -30,23 +32,27 @@ public SchedulingPolicy(ResourceGroup group) {
}

public void setTableSorterIfNeeded(ResourceGroup optimizerGroup) {
String schedulingPolicy =
policyName =
Optional.ofNullable(optimizerGroup.getProperties())
.orElseGet(Maps::newHashMap)
.getOrDefault(SCHEDULING_POLICY_PROPERTY_NAME, QUOTA);
if (schedulingPolicy.equalsIgnoreCase(QUOTA)) {
if (policyName.equalsIgnoreCase(QUOTA)) {
if (tableSorter == null || !(tableSorter instanceof QuotaOccupySorter)) {
tableSorter = new QuotaOccupySorter();
}
} else if (schedulingPolicy.equalsIgnoreCase(BALANCED)) {
} else if (policyName.equalsIgnoreCase(BALANCED)) {
if (tableSorter == null || !(tableSorter instanceof BalancedSorter)) {
tableSorter = new BalancedSorter();
}
} else {
throw new IllegalArgumentException("Illegal scheduling policy: " + schedulingPolicy);
throw new IllegalArgumentException("Illegal scheduling policy: " + policyName);
}
}

public String name() {
return policyName;
}

public List<TableRuntime> scheduleTables() {
tableLock.lock();
try {
Expand Down

0 comments on commit 234874e

Please sign in to comment.