Skip to content

Commit

Permalink
[GC] Fix unstable elastic-heap tests
Browse files Browse the repository at this point in the history
Summary: fix unstable elastic-heap tests

Test Plan: jtreg elastic-heap tests

Reviewed-by: Yude Lin, Mao Liang

Issue: dragonwell-project/dragonwell8#288
  • Loading branch information
leveretconey committed Jan 26, 2022
1 parent 534d3cb commit fe392b3
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions test/elastic-heap/TestElasticHeapMTSetError.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,20 @@
*/

class ElasticHeapMTSetErrorSetter implements Runnable {
private int youngGenCommitPercent;

public ElasticHeapMTSetErrorSetter(int youngGenCommitPercent) {
this.youngGenCommitPercent = youngGenCommitPercent;
}

public void run() {
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
try {
ElasticHeapMXBean elasticHeapMXBean = ManagementFactory.newPlatformMXBeanProxy(server,
"com.alibaba.management:type=ElasticHeap",
ElasticHeapMXBean.class);
elasticHeapMXBean.setYoungGenCommitPercent(50);
System.out.println(Thread.currentThread().getName() + " setYoungGenCommitPercent");
elasticHeapMXBean.setYoungGenCommitPercent(youngGenCommitPercent);
} catch (Exception e) {
System.out.println("Error: "+ e.getMessage());
}
Expand Down Expand Up @@ -85,17 +92,9 @@ public static void main(String[] args) throws Exception {
arr = new byte[200*1024];
Thread.sleep(1);
}
ElasticHeapMTSetErrorSetter setter = new ElasticHeapMTSetErrorSetter();
Thread t1 = new Thread(setter, "t1");
Thread t2 = new Thread(setter, "t2");
Thread t3 = new Thread(setter, "t3");
Thread t4 = new Thread(setter, "t4");
Thread t5 = new Thread(setter, "t5");
t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
for (int i = 0; i < 10; i++) {
new Thread(new ElasticHeapMTSetErrorSetter(60 - i), "t" + i).start();
}
for (int i = 0; i < 1000 * 5; i++) {
arr = new byte[200*1024];
Thread.sleep(1);
Expand Down

0 comments on commit fe392b3

Please sign in to comment.