public abstract class AbstractAsynchronousCache extends Object implements ArtifactCache
| Modifier and Type | Class and Description |
|---|---|
static interface |
AbstractAsynchronousCache.CacheEventListener |
protected static class |
AbstractAsynchronousCache.FetchRequest |
static interface |
AbstractAsynchronousCache.StoreEvents |
| Constructor and Description |
|---|
AbstractAsynchronousCache(String name,
ArtifactCacheMode mode,
CacheReadMode cacheReadMode,
com.google.common.util.concurrent.ListeningExecutorService storeExecutorService,
com.google.common.util.concurrent.ListeningExecutorService fetchExecutorService,
AbstractAsynchronousCache.CacheEventListener eventListener,
Optional<Long> maxStoreSize,
ProjectFilesystem projectFilesystem) |
| Modifier and Type | Method and Description |
|---|---|
com.google.common.util.concurrent.ListenableFuture<CacheDeleteResult> |
deleteAsync(List<RuleKey> ruleKeys) |
protected abstract CacheDeleteResult |
deleteImpl(List<RuleKey> ruleKeys) |
com.google.common.util.concurrent.ListenableFuture<CacheResult> |
fetchAsync(BuildTarget target,
RuleKey ruleKey,
LazyPath output)
Fetch a cached artifact, keyed by ruleKey, save the artifact to path specified by output, and
return true on success.
|
protected abstract com.facebook.buck.artifact_cache.AbstractAsynchronousCache.FetchResult |
fetchImpl(BuildTarget target,
RuleKey ruleKey,
LazyPath output) |
CacheReadMode |
getCacheReadMode()
This method must return the same value over the lifetime of this object.
|
protected ArtifactCacheMode |
getMode() |
protected int |
getMultiFetchBatchSize(int pendingRequestsSize)
Used to compute the number of keys to include in every multiFetchRequest.
|
protected String |
getName() |
protected ProjectFilesystem |
getProjectFilesystem() |
protected boolean |
isMultiCheckEnabled() |
com.google.common.util.concurrent.ListenableFuture<com.google.common.collect.ImmutableMap<RuleKey,CacheResult>> |
multiContainsAsync(com.google.common.collect.ImmutableSet<RuleKey> ruleKeys)
Check if the cache contains the given artifacts, keyed by ruleKeys, without fetching them, and
return a map of results wrapped in a
ListenableFuture. |
protected abstract com.facebook.buck.artifact_cache.AbstractAsynchronousCache.MultiContainsResult |
multiContainsImpl(com.google.common.collect.ImmutableSet<RuleKey> ruleKeys) |
protected abstract com.facebook.buck.artifact_cache.AbstractAsynchronousCache.MultiFetchResult |
multiFetchImpl(Iterable<AbstractAsynchronousCache.FetchRequest> requests)
The MultiFetchResult should contain results in the same order as the requests.
|
void |
skipPendingAndFutureAsyncFetches()
All pending (and future) async fetches will be immediately marked as skipped.
|
com.google.common.util.concurrent.ListenableFuture<Unit> |
store(ArtifactInfo info,
BorrowablePath output)
Store the artifact at path specified by output to cache, such that it can later be fetched
using ruleKey as the lookup key.
|
com.google.common.util.concurrent.ListenableFuture<Unit> |
store(com.google.common.collect.ImmutableList<Pair<ArtifactInfo,BorrowablePath>> artifacts)
Store the list of artifacts at path specified by output to cache in passed order, such that it
can later be fetched using ruleKey as the lookup key.
|
protected abstract com.facebook.buck.artifact_cache.AbstractAsynchronousCache.StoreResult |
storeImpl(ArtifactInfo info,
Path file) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclosepublic AbstractAsynchronousCache(String name, ArtifactCacheMode mode, CacheReadMode cacheReadMode, com.google.common.util.concurrent.ListeningExecutorService storeExecutorService, com.google.common.util.concurrent.ListeningExecutorService fetchExecutorService, AbstractAsynchronousCache.CacheEventListener eventListener, Optional<Long> maxStoreSize, ProjectFilesystem projectFilesystem)
protected final String getName()
protected final ArtifactCacheMode getMode()
protected final ProjectFilesystem getProjectFilesystem()
protected abstract com.facebook.buck.artifact_cache.AbstractAsynchronousCache.FetchResult fetchImpl(@Nullable BuildTarget target, RuleKey ruleKey, LazyPath output) throws IOException
IOExceptionprotected abstract com.facebook.buck.artifact_cache.AbstractAsynchronousCache.MultiContainsResult multiContainsImpl(com.google.common.collect.ImmutableSet<RuleKey> ruleKeys) throws IOException
IOExceptionprotected abstract com.facebook.buck.artifact_cache.AbstractAsynchronousCache.StoreResult storeImpl(ArtifactInfo info, Path file) throws IOException
IOExceptionprotected abstract CacheDeleteResult deleteImpl(List<RuleKey> ruleKeys) throws IOException
IOExceptionprotected abstract com.facebook.buck.artifact_cache.AbstractAsynchronousCache.MultiFetchResult multiFetchImpl(Iterable<AbstractAsynchronousCache.FetchRequest> requests) throws IOException
IOExceptionprotected int getMultiFetchBatchSize(int pendingRequestsSize)
protected boolean isMultiCheckEnabled()
public void skipPendingAndFutureAsyncFetches()
ArtifactCacheskipPendingAndFutureAsyncFetches in interface ArtifactCachepublic final com.google.common.util.concurrent.ListenableFuture<CacheResult> fetchAsync(@Nullable BuildTarget target, RuleKey ruleKey, LazyPath output)
ArtifactCachefetchAsync in interface ArtifactCachetarget - rule for which this is an artifactruleKey - cache fetch keyoutput - Path to store artifact to. Path should not be accessed unless store operation is
guaranteed by the cache, to avoid potential extra disk I/O.CacheResultType.MISS (indicating a failure) or some type of
hit.public final com.google.common.util.concurrent.ListenableFuture<com.google.common.collect.ImmutableMap<RuleKey,CacheResult>> multiContainsAsync(com.google.common.collect.ImmutableSet<RuleKey> ruleKeys)
ArtifactCacheListenableFuture. This is supposed to be fast, but
best-effort, meaning that there will be false-positives.multiContainsAsync in interface ArtifactCacheruleKeys - Set of cache fetch keys.CacheResult which can be a CacheResultType.MISS / CacheResultType.ERROR (indicating a failure) or CacheResultType.CONTAINS.public final com.google.common.util.concurrent.ListenableFuture<Unit> store(ArtifactInfo info, BorrowablePath output)
ArtifactCacheThis is a noop if ArtifactCache.getCacheReadMode()} returns READONLY.
store in interface ArtifactCacheinfo - information to store with the artifactoutput - path to read artifact from. If its borrowable, you may freely move the file into
cache without obtaining a copy of the file.ListenableFuture that completes once the store has finished.public final com.google.common.util.concurrent.ListenableFuture<Unit> store(com.google.common.collect.ImmutableList<Pair<ArtifactInfo,BorrowablePath>> artifacts)
ArtifactCacheThis is a noop if ArtifactCache.getCacheReadMode()} returns READONLY.
store in interface ArtifactCacheartifacts - list of artifact info and path to be uploaded to the cache in given order.ListenableFuture that completes once the store has finished.public final com.google.common.util.concurrent.ListenableFuture<CacheDeleteResult> deleteAsync(List<RuleKey> ruleKeys)
deleteAsync in interface ArtifactCachepublic final CacheReadMode getCacheReadMode()
ArtifactCachegetCacheReadMode in interface ArtifactCacheArtifactCache supports storing artifacts.