Package hudson.model
Class FingerprintMap
- java.lang.Object
-
- hudson.util.KeyedDataStorage<Fingerprint,hudson.model.FingerprintMap.FingerprintParams>
-
- hudson.model.FingerprintMap
-
public final class FingerprintMap extends KeyedDataStorage<Fingerprint,hudson.model.FingerprintMap.FingerprintParams>
Cache ofFingerprints.This implementation makes sure that no two
Fingerprintobjects lie around for the same hash code, and that unusedFingerprintwill be adequately GC-ed to prevent memory leak.- Author:
- Kohsuke Kawaguchi
- See Also:
Jenkins.getFingerprintMap()
-
-
Field Summary
-
Fields inherited from class hudson.util.KeyedDataStorage
cacheHit, loadFailure, totalQuery, weakRefLost
-
-
Constructor Summary
Constructors Constructor Description FingerprintMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Fingerprintcreate(String md5sum, hudson.model.FingerprintMap.FingerprintParams createParams)Creates a new data object.protected Fingerprintget(String md5sum, boolean createIfNotExist, hudson.model.FingerprintMap.FingerprintParams createParams)Implementation of get/getOrCreate.FingerprintgetOrCreate(AbstractBuild build, String fileName, byte[] md5sum)FingerprintgetOrCreate(AbstractBuild build, String fileName, String md5sum)FingerprintgetOrCreate(Run build, String fileName, String md5sum)booleanisReady()Returns true if there's some data in the fingerprint database.protected Fingerprintload(String key)Attempts to load an existing data object from disk.-
Methods inherited from class hudson.util.KeyedDataStorage
get, getOrCreate, getPerformanceStats, resetPerformanceStats
-
-
-
-
Method Detail
-
isReady
public boolean isReady()
Returns true if there's some data in the fingerprint database.
-
getOrCreate
@NonNull public Fingerprint getOrCreate(@CheckForNull AbstractBuild build, @NonNull String fileName, @NonNull byte[] md5sum) throws IOException
- Parameters:
build- set to non-null ifFingerprintto be created (if so) will have this build as the owner. Otherwise null, to indicate an owner-less build.- Throws:
IOException- Loading error
-
getOrCreate
@NonNull public Fingerprint getOrCreate(@CheckForNull AbstractBuild build, @NonNull String fileName, @NonNull String md5sum) throws IOException
- Throws:
IOException
-
getOrCreate
@NonNull public Fingerprint getOrCreate(@CheckForNull Run build, @NonNull String fileName, @NonNull String md5sum) throws IOException
- Throws:
IOException
-
get
protected Fingerprint get(String md5sum, boolean createIfNotExist, hudson.model.FingerprintMap.FingerprintParams createParams) throws IOException
Description copied from class:KeyedDataStorageImplementation of get/getOrCreate.- Overrides:
getin classKeyedDataStorage<Fingerprint,hudson.model.FingerprintMap.FingerprintParams>- Returns:
- Item with the specified
key - Throws:
IOException- Loading error
-
create
@NonNull protected Fingerprint create(@NonNull String md5sum, @NonNull hudson.model.FingerprintMap.FingerprintParams createParams) throws IOException
Description copied from class:KeyedDataStorageCreates a new data object.This method is called by
KeyedDataStorage.getOrCreate(String,Object)if the data that matches the specified key does not exist.Because of concurrency, another thread might call
KeyedDataStorage.get(String)as soon as a new data object is created, so it's important that this method returns a properly initialized "valid" object.- Specified by:
createin classKeyedDataStorage<Fingerprint,hudson.model.FingerprintMap.FingerprintParams>- Returns:
- Created item. If construction fails, abort with an exception.
- Throws:
IOException- if the method fails to create a new data object, it can throwIOException(or any other exception) and that will be propagated to the caller.
-
load
@CheckForNull protected Fingerprint load(@NonNull String key) throws IOException
Description copied from class:KeyedDataStorageAttempts to load an existing data object from disk.KeyedDataStorageclass serializes the requests so that no two threads call theKeyedDataStorage.load(String)method with the same parameter concurrently. This ensures that there's only up to one data object for any key.- Specified by:
loadin classKeyedDataStorage<Fingerprint,hudson.model.FingerprintMap.FingerprintParams>- Returns:
- null if no such data exists.
- Throws:
IOException- if load operation fails. This exception will be propagated to the caller.
-
-