Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure vertx-cache to allow multiple applications with launched by multiple users #15541

Merged
merged 3 commits into from Mar 10, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -13,6 +13,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -51,6 +52,7 @@
public class VertxCoreRecorder {

private static final Logger LOGGER = Logger.getLogger(VertxCoreRecorder.class.getName());
public static final String VERTX_CACHE = "vertx-cache";

static volatile VertxSupplier vertx;

Expand Down Expand Up @@ -227,8 +229,24 @@ private static VertxOptions convertToVertxOptions(VertxConfiguration conf, Vertx
initializeClusterOptions(conf, options);
}

String fileCacheDir = System.getProperty(CACHE_DIR_BASE_PROP_NAME,
System.getProperty("java.io.tmpdir", ".") + File.separator + "vertx-cache");
String fileCacheDir = System.getProperty(CACHE_DIR_BASE_PROP_NAME);
if (fileCacheDir == null) {
File tmp = new File(System.getProperty("java.io.tmpdir", ".") + File.separator + VERTX_CACHE);
if (!tmp.isDirectory()) {
if (!tmp.mkdirs()) {
LOGGER.warnf("Unable to create Vert.x cache directory : %s", tmp.getAbsolutePath());
}
if (!(tmp.setReadable(true, false) && tmp.setWritable(true, false))) {
LOGGER.warnf("Unable to make the Vert.x cache directory (%s) world readable and writable",
tmp.getAbsolutePath());
}
}

long random = UUID.randomUUID().getMostSignificantBits();
File cache = new File(tmp, Long.toString(random));
LOGGER.debugf("Vert.x Cache configured to: %s", cache.getAbsolutePath());
fileCacheDir = cache.getAbsolutePath();
}

options.setFileSystemOptions(new FileSystemOptions()
.setFileCachingEnabled(conf.caching)
Expand Down