This commit is contained in:
parent
03605169f3
commit
aebfdf1477
|
@ -19,16 +19,12 @@ public class TestClusterCleanupOnShutdown implements Runnable {
|
|||
|
||||
private Set<ElasticsearchCluster> clustersToWatch = new HashSet<>();
|
||||
|
||||
public void watch(Collection<ElasticsearchCluster> cluster) {
|
||||
synchronized (clustersToWatch) {
|
||||
clustersToWatch.addAll(clustersToWatch);
|
||||
}
|
||||
public synchronized void watch(Collection<ElasticsearchCluster> clusters) {
|
||||
clustersToWatch.addAll(clusters);
|
||||
}
|
||||
|
||||
public void unWatch(Collection<ElasticsearchCluster> cluster) {
|
||||
synchronized (clustersToWatch) {
|
||||
clustersToWatch.removeAll(clustersToWatch);
|
||||
}
|
||||
public synchronized void unWatch(Collection<ElasticsearchCluster> clusters) {
|
||||
clustersToWatch.removeAll(clusters);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,7 +34,11 @@ public class TestClusterCleanupOnShutdown implements Runnable {
|
|||
Thread.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
} catch (InterruptedException interrupted) {
|
||||
synchronized (clustersToWatch) {
|
||||
shutdownClusters();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void shutdownClusters() {
|
||||
if (clustersToWatch.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -54,6 +54,4 @@ public class TestClusterCleanupOnShutdown implements Runnable {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ public class TestClustersCleanupExtension {
|
|||
executorService.submit(cleanupThread);
|
||||
}
|
||||
|
||||
|
||||
public static void createExtension(Project project) {
|
||||
if (project.getRootProject().getExtensions().findByType(TestClustersCleanupExtension.class) != null) {
|
||||
return;
|
||||
|
@ -43,7 +42,7 @@ public class TestClustersCleanupExtension {
|
|||
"__testclusters_rate_limit",
|
||||
TestClustersCleanupExtension.class
|
||||
);
|
||||
Thread shutdownHook = new Thread(ext.cleanupThread::run);
|
||||
Thread shutdownHook = new Thread(ext.cleanupThread::shutdownClusters);
|
||||
Runtime.getRuntime().addShutdownHook(shutdownHook);
|
||||
project.getGradle().buildFinished(buildResult -> {
|
||||
ext.executorService.shutdownNow();
|
||||
|
|
Loading…
Reference in New Issue