public final class FileSystemContextReinitializer extends Object implements Closeable
FileSystemContext
inside BaseFileSystem
.
A daemon heartbeat thread periodically fetches configuration hashes from meta master,
if they differ from the hashes in the ClientContext
backing the
FileSystemContext
, it tries to reinitialize the FileSystemContext
.
Each RPC needs to call block()
to mark its lifetime, when there
are ongoing RPCs executing between these two methods, reinitialization is blocked.
Reinitialization starts when there are no ongoing RPCs, after starting, all further RPCs
are blocked until the reinitialization finishes or until timeout. If it succeeds, future RPCs
will use the reinitialized context, otherwise, an exception is thrown from
block()
.Modifier and Type | Class and Description |
---|---|
static class |
FileSystemContextReinitializer.ReinitAllowerResource
This resource allows reinitialization.
|
static class |
FileSystemContextReinitializer.ReinitBlockerResource
This resource blocks reinitialization until close.
|
Constructor and Description |
---|
FileSystemContextReinitializer(FileSystemContext context)
Creates a new reinitializer for the context.
|
Modifier and Type | Method and Description |
---|---|
FileSystemContextReinitializer.ReinitAllowerResource |
allow()
Acquires the resource to allow reinitialization.
|
FileSystemContextReinitializer.ReinitBlockerResource |
block()
Acquires the resource to block reinitialization.
|
void |
close()
Shuts down the heartbeat thread immediately.
|
void |
onSuccess()
Notifies that the reinitialization has succeeded.
|
public FileSystemContextReinitializer(FileSystemContext context)
context
- the context to be reinitializedpublic void onSuccess()
public FileSystemContextReinitializer.ReinitBlockerResource block() throws IOException, InterruptedException
IOException
- when reinitialization fails before or during this methodInterruptedException
- if interrupted during being blockedpublic FileSystemContextReinitializer.ReinitAllowerResource allow()
block()
.
When it returns, further calls to block()
block until the
returned resource is closed.public void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2023. All Rights Reserved.