public abstract class PeepholePermalink extends PermalinkProjectAction.Permalink implements com.google.common.base.Predicate<Run<?,?>>
PermalinkProjectAction.Permalink
s that satisfy
certain properties.
For a permalink to be able to use this, it has to satisfy the following:
Given a job J, permalink is a function F that computes a build B. A peephole permalink is a subset of this function that can be deduced to the "peep-hole" function G(B)->bool:F(J) = { newest B | G(B)==true }
Intuitively speaking, a peep-hole permalink resolves to the latest build that satisfies a certain characteristics that can be determined solely by looking at the build and nothing else (most commonly its build result.)
This base class provides a file-based caching mechanism that avoids walking the long build history. The cache is a symlink to the build directory where symlinks are supported, and text file that contains the build number otherwise.
The implementation transparently tolerates G(B) that goes from true to false over time
(it simply scans the history till find the new matching build.) To tolerate G(B)
that goes from false to true, you need to be able to intercept whenever G(B) changes
from false to true, then call resolve(Job)
to check the current permalink target
is up to date, then call updateCache(Job, Run)
if it needs updating.
Modifier and Type | Class and Description |
---|---|
static class |
PeepholePermalink.RunListenerImpl |
BUILTIN, LAST_BUILD, LAST_FAILED_BUILD, LAST_STABLE_BUILD, LAST_SUCCESSFUL_BUILD, LAST_UNSTABLE_BUILD, LAST_UNSUCCESSFUL_BUILD
Constructor and Description |
---|
PeepholePermalink() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
apply(Run<?,?> run)
Checks if the given build satisfies the peep-hole criteria.
|
protected File |
getPermalinkFile(Job<?,?> job)
The file in which the permalink target gets recorded.
|
Run<?,?> |
resolve(Job<?,?> job)
Resolves the permalink by using the cache if possible.
|
protected void |
updateCache(Job<?,?> job,
Run<?,?> b)
Remembers the value 'n' in the cache for future
resolve(Job) . |
getDisplayName, getId
public abstract boolean apply(Run<?,?> run)
apply
in interface com.google.common.base.Predicate<Run<?,?>>
protected File getPermalinkFile(Job<?,?> job)
public Run<?,?> resolve(Job<?,?> job)
resolve
in class PermalinkProjectAction.Permalink
protected void updateCache(@Nonnull Job<?,?> job, @Nullable Run<?,?> b)
resolve(Job)
.Copyright © 2016. All rights reserved.