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

Improve resource deallocation in FUSE #18206

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions dora/integration/fuse/src/main/java/alluxio/fuse/AlluxioFuse.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
Expand Down Expand Up @@ -106,12 +107,20 @@ protected void startCommon(AlluxioConfiguration conf,
setupFuseFileSystem(fuseFileSystem);
launchFuse(fuseFileSystem, fsContext, fuseOptions, true); // This will block until umount
} catch (Throwable t) {
if (executor != null) {
executor.shutdown();
}
// TODO(lu) FUSE unmount gracefully
LOG.error("Failed to launch FUSE", t);
System.exit(-1);
} finally {
if (executor != null) {
executor.shutdown();
try {
executor.awaitTermination(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
LOG.warn("Interrupted while terminating the update checker thread");
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
}
}
}

Expand All @@ -132,19 +141,20 @@ protected void stopCommon() {
* @param conf configuration
* @throws ParseException
*/
public void start(AlluxioConfiguration conf) throws ParseException {
public void start(AlluxioConfiguration conf) throws ParseException, IOException {
FuseOptions fuseOptions = FuseOptions.Builder.fromConfig(conf).build();

FileSystemContext fsContext = FileSystemContext.create(conf);
if (!fuseOptions.getFileSystemOptions().getUfsFileSystemOptions().isPresent()
&& !fuseOptions.getFileSystemOptions().isDoraCacheEnabled()) {
// cases other than standalone fuse sdk
conf = AlluxioFuseUtils.tryLoadingConfigFromMaster(fsContext);
}
try (FileSystemContext fsContext = FileSystemContext.create(conf)) {
if (!fuseOptions.getFileSystemOptions().getUfsFileSystemOptions().isPresent()
&& !fuseOptions.getFileSystemOptions().isDoraCacheEnabled()) {
// cases other than standalone fuse sdk
conf = AlluxioFuseUtils.tryLoadingConfigFromMaster(fsContext);
}

startCommon(conf, fuseOptions, fsContext); // This will be blocked until quitting
startCommon(conf, fuseOptions, fsContext); // This will be blocked until quitting

stopCommon();
stopCommon();
}
}

/**
Expand All @@ -154,7 +164,7 @@ public void start(AlluxioConfiguration conf) throws ParseException {
*
* @param args arguments to run the command line
*/
public static void main(String[] args) throws ParseException {
public static void main(String[] args) throws ParseException, IOException {
AlluxioFuse alluxioFuse = new AlluxioFuse();
FuseCliOptions fuseCliOptions = new FuseCliOptions();
JCommander jCommander = JCommander.newBuilder()
Expand Down
Loading