public class Localizer extends Object
Class to download and manage files from the blobstore. It uses an LRU cache to determine which files to keep so they can be reused and which files to delete.
Modifier and Type | Field and Description |
---|---|
static String |
ARCHIVESDIR |
static String |
FILECACHE |
static String |
FILESDIR |
static org.slf4j.Logger |
LOG |
static String |
USERCACHE |
Constructor and Description |
---|
Localizer(Map<String,Object> conf,
String baseDir) |
Modifier and Type | Method and Description |
---|---|
protected void |
addLocalizedResourceInDir(String dir,
LocalizedResourceSet lrsrcSet,
boolean uncompress) |
void |
addReferences(List<LocalResource> localresource,
String user,
String topo) |
LocalizedResource |
getBlob(LocalResource localResource,
String user,
String topo,
File userFileDir)
This function either returns the blob in the existing cache or if it doesn’t exist in the cache, it will download the blob and will block until the download is complete.
|
List<LocalizedResource> |
getBlobs(List<LocalResource> localResources,
String user,
String topo,
File userFileDir)
This function either returns the blobs in the existing cache or if they don’t exist in the cache, it downloads them in parallel (up to SUPERVISOR_BLOBSTORE_DOWNLOAD_THREAD_COUNT) and will block until all of them have been downloaded
|
protected File |
getCacheDirForArchives(File dir) |
protected File |
getCacheDirForFiles(File dir) |
protected ClientBlobStore |
getClientBlobStore() |
protected File |
getLocalUserDir(String userName) |
File |
getLocalUserFileCacheDir(String userName) |
protected File |
getUserCacheDir() |
void |
handleCacheCleanup() |
protected boolean |
isLocalizedResourceDownloaded(LocalizedResource lrsrc) |
protected boolean |
isLocalizedResourceUpToDate(LocalizedResource lrsrc,
ClientBlobStore blobstore) |
protected File[] |
readCurrentBlobs(String location) |
protected File[] |
readDirContents(String location) |
protected void |
reconstructLocalizedResources() |
void |
removeBlobReference(String key,
String user,
String topo,
boolean uncompress) |
void |
setBlobPermissions(Map conf,
String user,
String path) |
protected void |
setTargetCacheSize(long size) |
void |
shutdown() |
void |
startCleaner() |
List<LocalizedResource> |
updateBlobs(List<LocalResource> localResources,
String user)
This function updates blobs on the supervisor.
|
public static final org.slf4j.Logger LOG
public static final String USERCACHE
public static final String FILECACHE
public static final String FILESDIR
public static final String ARCHIVESDIR
protected void setTargetCacheSize(long size)
public void startCleaner()
public void shutdown()
protected File getUserCacheDir()
protected void addLocalizedResourceInDir(String dir, LocalizedResourceSet lrsrcSet, boolean uncompress)
protected void reconstructLocalizedResources()
public void removeBlobReference(String key, String user, String topo, boolean uncompress) throws AuthorizationException, KeyNotFoundException
public void addReferences(List<LocalResource> localresource, String user, String topo)
public LocalizedResource getBlob(LocalResource localResource, String user, String topo, File userFileDir) throws AuthorizationException, KeyNotFoundException, IOException
This function either returns the blob in the existing cache or if it doesn’t exist in the cache, it will download the blob and will block until the download is complete.
protected boolean isLocalizedResourceDownloaded(LocalizedResource lrsrc)
protected boolean isLocalizedResourceUpToDate(LocalizedResource lrsrc, ClientBlobStore blobstore) throws AuthorizationException, KeyNotFoundException
protected ClientBlobStore getClientBlobStore()
public List<LocalizedResource> updateBlobs(List<LocalResource> localResources, String user) throws AuthorizationException, KeyNotFoundException, IOException
This function updates blobs on the supervisor. It uses a separate thread pool and runs asynchronously of the download and delete.
public List<LocalizedResource> getBlobs(List<LocalResource> localResources, String user, String topo, File userFileDir) throws AuthorizationException, KeyNotFoundException, IOException
This function either returns the blobs in the existing cache or if they don’t exist in the cache, it downloads them in parallel (up to SUPERVISOR_BLOBSTORE_DOWNLOAD_THREAD_COUNT) and will block until all of them have been downloaded
public void setBlobPermissions(Map conf, String user, String path) throws IOException
IOException
public void handleCacheCleanup()
Copyright © 2022 The Apache Software Foundation. All Rights Reserved.