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