use of hudson.model.Fingerprint.RangeSet in project hudson-2.x by hudson.
the class FingerprintTest method test.
public void test() {
RangeSet rs = new RangeSet();
assertFalse(rs.includes(0));
assertFalse(rs.includes(3));
assertFalse(rs.includes(5));
rs.add(3);
assertFalse(rs.includes(2));
assertTrue(rs.includes(3));
assertFalse(rs.includes(4));
assertEquals("[3,4)", rs.toString());
rs.add(4);
assertFalse(rs.includes(2));
assertTrue(rs.includes(3));
assertTrue(rs.includes(4));
assertFalse(rs.includes(5));
assertEquals("[3,5)", rs.toString());
rs.add(10);
assertEquals("[3,5),[10,11)", rs.toString());
rs.add(9);
assertEquals("[3,5),[9,11)", rs.toString());
rs.add(6);
assertEquals("[3,5),[6,7),[9,11)", rs.toString());
rs.add(5);
assertEquals("[3,7),[9,11)", rs.toString());
}
use of hudson.model.Fingerprint.RangeSet in project hudson-2.x by hudson.
the class AbstractBuild method getDownstreamRelationship.
/**
* Gets the dependency relationship from this build (as the source)
* and that project (as the sink.)
*
* @return
* range of build numbers that represent which downstream builds are using this build.
* The range will be empty if no build of that project matches this, but it'll never be null.
*/
public RangeSet getDownstreamRelationship(AbstractProject that) {
RangeSet rs = new RangeSet();
FingerprintAction f = getAction(FingerprintAction.class);
if (f == null)
return rs;
// look for fingerprints that point to this build as the source, and merge them all
for (Fingerprint e : f.getFingerprints().values()) {
if (upstreamCulprits) {
// With upstreamCulprits, we allow downstream relationships
// from intermediate jobs
rs.add(e.getRangeSet(that));
} else {
BuildPtr o = e.getOriginal();
if (o != null && o.is(this))
rs.add(e.getRangeSet(that));
}
}
return rs;
}
use of hudson.model.Fingerprint.RangeSet in project hudson-2.x by hudson.
the class AbstractBuild method getUpstreamRelationship.
/**
* Gets the dependency relationship from this build (as the sink)
* and that project (as the source.)
*
* @return
* Build number of the upstream build that feed into this build,
* or -1 if no record is available.
*/
public int getUpstreamRelationship(AbstractProject that) {
FingerprintAction f = getAction(FingerprintAction.class);
if (f == null)
return -1;
int n = -1;
// look for fingerprints that point to the given project as the source, and merge them all
for (Fingerprint e : f.getFingerprints().values()) {
if (upstreamCulprits) {
// With upstreamCulprits, we allow upstream relationships
// from intermediate jobs
Fingerprint.RangeSet rangeset = e.getRangeSet(that);
if (!rangeset.isEmpty()) {
n = Math.max(n, rangeset.listNumbersReverse().iterator().next());
}
} else {
BuildPtr o = e.getOriginal();
if (o != null && o.belongsTo(that))
n = Math.max(n, o.getNumber());
}
}
return n;
}
use of hudson.model.Fingerprint.RangeSet in project hudson-2.x by hudson.
the class AbstractProject method checkAndRecord.
/**
* Helper method for getDownstreamRelationship.
*
* For each given build, find the build number range of the given project and put that into the map.
*/
private void checkAndRecord(AbstractProject that, TreeMap<Integer, RangeSet> r, Collection<R> builds) {
for (R build : builds) {
RangeSet rs = build.getDownstreamRelationship(that);
if (rs == null || rs.isEmpty())
continue;
int n = build.getNumber();
RangeSet value = r.get(n);
if (value == null)
r.put(n, rs);
else
value.add(rs);
}
}
use of hudson.model.Fingerprint.RangeSet in project hudson-2.x by hudson.
the class FingerprintTest method testMerge2.
public void testMerge2() {
RangeSet x = new RangeSet();
x.add(1);
x.add(2);
x.add(5);
x.add(6);
assertEquals("[1,3),[5,7)", x.toString());
RangeSet y = new RangeSet();
y.add(3);
y.add(4);
assertEquals("[3,5)", y.toString());
x.add(y);
assertEquals("[1,7)", x.toString());
}
Aggregations