forked from linkedin/dr-elephant
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated getMaxMemoryBytesUsedForTaskType so that it will check if oth…
…er tasks have metrics rather than stopping on the first task without metrics
- Loading branch information
Anthony Hsu
committed
May 21, 2019
1 parent
7cf4953
commit ba3b68b
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.linkedin.drelephant.tony.util; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.linkedin.drelephant.tony.data.TonyTaskData; | ||
import com.linkedin.tony.Constants; | ||
import com.linkedin.tony.events.Metric; | ||
import java.util.Map; | ||
import java.util.TreeMap; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
|
||
public class TonyUtilsTest { | ||
/** | ||
* Worker 0 is missing metrics, but worker 1 has metrics; we should use worker 1's | ||
* max memory metrics. | ||
*/ | ||
@Test | ||
public void testGetMaxMemorySomeTasksMissingMetrics() { | ||
Map<Integer, TonyTaskData> taskDataMap = new TreeMap<>(); | ||
TonyTaskData worker0Data = new TonyTaskData("worker", 0); | ||
TonyTaskData worker1Data = new TonyTaskData("worker", 1); | ||
double worker1MaxMemoryBytes = 123d; | ||
worker1Data.setMetrics(ImmutableList.of(new Metric(Constants.MAX_MEMORY_BYTES, worker1MaxMemoryBytes))); | ||
|
||
taskDataMap.put(0, worker0Data); | ||
taskDataMap.put(1, worker1Data); | ||
|
||
Assert.assertEquals(worker1MaxMemoryBytes, | ||
TonyUtils.getMaxMemoryBytesUsedForTaskType(ImmutableMap.of("worker", taskDataMap), "worker"), 0); | ||
} | ||
} |