Skip to content

Commit

Permalink
Check filesystem for mount point
Browse files Browse the repository at this point in the history
### What changes are proposed in this pull request?

Fix #17158.

pr-link: #17159
change-id: cid-341bd1e1a2a23530da4ab97161704b5b22c8f0ed
  • Loading branch information
Haoning-Sun committed Mar 31, 2023
1 parent 50c4c29 commit a600f12
Showing 1 changed file with 18 additions and 6 deletions.
Expand Up @@ -160,19 +160,20 @@ private UnderFileSystem getOrAddWithRecorder(AlluxioURI ufsUri,
if (useManagedBlocking) {
fs = new ManagedBlockingUfsForwarder(fs);
}

if (mUnderFileSystemMap.putIfAbsent(key, fs) != null) {
// This shouldn't occur unless our synchronization is incorrect
LOG.warn("UFS already existed in UFS manager");
}
mCloser.register(fs);
try {
connectUfs(fs);
} catch (IOException e) {
tryUseFileSystem(fs, ufsUri.getPath());
} catch (Exception e) {
String message = String.format(
"Failed to perform initial connect to UFS %s: %s", ufsUri, e);
recorder.record(message);
LOG.warn(message);
throw new RuntimeException(e);
}
if (mUnderFileSystemMap.putIfAbsent(key, fs) != null) {
// This shouldn't occur unless our synchronization is incorrect
LOG.warn("UFS already existed in UFS manager");
}
return fs;
}
Expand All @@ -185,6 +186,17 @@ private UnderFileSystem getOrAddWithRecorder(AlluxioURI ufsUri,
*/
protected abstract void connectUfs(UnderFileSystem fs) throws IOException;

/**
* To check whether the filesystem is available by calling exists.
*
* @param fs the filesystem
* @param ufsPath the UFS path
* @throws Exception
*/
private void tryUseFileSystem(UnderFileSystem fs, String ufsPath) throws Exception {
fs.exists(ufsPath);
}

@Override
public void addMount(long mountId, final AlluxioURI ufsUri,
final UnderFileSystemConfiguration ufsConf) {
Expand Down

0 comments on commit a600f12

Please sign in to comment.