fix(distro-es): Ensure ES data directory not overwritten on Bootstrapper restart.
On Tomcat the data directory was being overwritten as ES distro was
being extracted in the same directory as the ES data we wanted to
preserve (and hence overwriting `data` to its initial state).
Fixes
@@ -73,14 +73,16 @@ public class Bootstrapper implements ServletContextListener {
String clusterName = "apiman";
try {
-
- URL url = resolveEsDistro(sce);
+ URL esDistroUrl = resolveEsDistro(sce);
+ File tmpDir = new File(getTempDir());
Builder builder = ApimanEmbeddedElastic.builder()
.withPort(config.getHttpPortRange())
- .withDownloadUrl(url)
+ .withDownloadUrl(esDistroUrl)
+ .withDownloadDirectory(tmpDir)
+ .withInstallationDirectory(tmpDir)
+ .withSetting("path.data", esHome)
.withCleanInstallationDirectoryOnStop(false)
- .withInstallationDirectory(esHome)
.withSetting(PopularProperties.TRANSPORT_TCP_PORT, config.getTransportPortRange())
.withSetting(PopularProperties.CLUSTER_NAME, clusterName)
.withStartTimeout(1, TimeUnit.MINUTES);
@@ -99,6 +101,13 @@ public class Bootstrapper implements ServletContextListener {
System.out.println("-----------------------------");
}
+ private static String getTempDir() {
+ if (System.getProperties().contains("jboss.server.temp.dir")) {
+ return System.getProperty("jboss.server.temp.dir");
+ }
+ return System.getProperty("java.io.tmpdir");
+ }
+
/**
* @return the ES data directory
*/
