public class AsyncLocalizer extends Object implements AutoCloseable
Downloads and caches blobs locally.
Modifier and Type | Field and Description |
---|---|
protected long |
cacheTargetSize |
protected ConcurrentHashMap<String,ConcurrentHashMap<String,LocalizedResource>> |
userArchives |
protected ConcurrentHashMap<String,ConcurrentHashMap<String,LocalizedResource>> |
userFiles |
Constructor and Description |
---|
AsyncLocalizer(Map<String,Object> conf,
StormMetricsRegistry metricsRegistry) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected ClientBlobStore |
getClientBlobStore() |
void |
recoverRunningTopology(LocalAssignment currentAssignment,
int port,
BlobChangingCallback cb)
Do everything needed to recover the state in the AsyncLocalizer for a running topology.
|
void |
releaseSlotFor(LocalAssignment assignment,
int port)
Remove this assignment/port as blocking resources from being cleaned up.
|
CompletableFuture<Void> |
requestDownloadTopologyBlobs(LocalAssignment assignment,
int port,
BlobChangingCallback cb)
Request that all of the blobs necessary for this topology be downloaded.
|
void |
start()
Start any background threads needed.
|
protected final ConcurrentHashMap<String,ConcurrentHashMap<String,LocalizedResource>> userFiles
protected final ConcurrentHashMap<String,ConcurrentHashMap<String,LocalizedResource>> userArchives
protected long cacheTargetSize
public AsyncLocalizer(Map<String,Object> conf, StormMetricsRegistry metricsRegistry) throws IOException
IOException
public CompletableFuture<Void> requestDownloadTopologyBlobs(LocalAssignment assignment, int port, BlobChangingCallback cb) throws IOException
Request that all of the blobs necessary for this topology be downloaded. Note that this adds references to blobs asynchronously in background threads.
assignment
- the assignment that needs the blobsport
- the port the assignment is a part ofcb
- a callback for when the blobs change. This is only for blobs that are tied to the lifetime of the worker.IOException
- if there was an error while trying doing it.public void start()
Start any background threads needed. This includes updating blobs and cleaning up unused blobs over the configured size limit.
public void close() throws InterruptedException
close
in interface AutoCloseable
InterruptedException
public void recoverRunningTopology(LocalAssignment currentAssignment, int port, BlobChangingCallback cb) throws IOException
Do everything needed to recover the state in the AsyncLocalizer for a running topology.
currentAssignment
- the assignment for the topology.port
- the port the assignment is on.cb
- a callback for when the blobs are updated. This will only be for blobs that indicate that if they change the worker should be restarted.IOException
- on any error trying to recover the state.public void releaseSlotFor(LocalAssignment assignment, int port) throws IOException
Remove this assignment/port as blocking resources from being cleaned up.
assignment
- the assignment the resources are forport
- the port the topology is running onIOException
- on any errorprotected ClientBlobStore getClientBlobStore()
Copyright © 2022 The Apache Software Foundation. All rights reserved.