hudson.model
Class RunMap<R extends Run<?,R>>

java.lang.Object
  extended by java.util.AbstractMap<Integer,R>
      extended by jenkins.model.lazy.AbstractLazyLoadRunMap<R>
          extended by hudson.model.RunMap<R>
All Implemented Interfaces:
Iterable<R>, Map<Integer,R>, SortedMap<Integer,R>

public final class RunMap<R extends Run<?,R>>
extends AbstractLazyLoadRunMap<R>
implements Iterable<R>

Map from build number to Run.

This class is multi-thread safe by using copy-on-write technique, and it also updates the bi-directional links within Run accordingly.

Author:
Kohsuke Kawaguchi

Nested Class Summary
static interface RunMap.Constructor<R extends Run<?,R>>
          Run factory.
 
Nested classes/interfaces inherited from class jenkins.model.lazy.AbstractLazyLoadRunMap
AbstractLazyLoadRunMap.Direction
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
static Comparator<Comparable> COMPARATOR
          Deprecated. as of 1.485 Use ReverseComparator
 
Constructor Summary
RunMap()
          Deprecated. as of 1.485 Use RunMap(File, Constructor).
RunMap(File baseDir, RunMap.Constructor cons)
           
 
Method Summary
protected  FilenameFilter createDirectoryFilter()
          Lists the actual data directory
protected  BuildReference<R> createReference(R r)
          Reuses the same reference as much as we can.
protected  String getIdOf(R r)
          Subtype to provide Run.getId() so that this class doesn't have to depend on it.
protected  int getNumberOf(R r)
          Subtype to provide Run.getNumber() so that this class doesn't have to depend on it.
 SortedMap<Integer,R> getView()
          Gets the read-only view of this map.
 Iterator<R> iterator()
          Walks through builds, newer ones first.
 void load(Job job, RunMap.Constructor<R> cons)
          Deprecated. as of 1.485 Use RunMap(File, Constructor)
 R newestValue()
          This is the newest build (with the biggest build number)
 R oldestValue()
          This is the oldest build (with the smallest build number)
 R put(R r)
           
 boolean remove(R run)
           
 boolean removeValue(R run)
           
protected  R retrieve(File d)
          Parses R instance from data in the specified directory.
 
Methods inherited from class jenkins.model.lazy.AbstractLazyLoadRunMap
_put, baseDirInitialized, comparator, entrySet, equals, firstKey, get, get, getById, getByNumber, getLoadedBuilds, hashCode, headMap, initBaseDir, isEmpty, lastKey, load, load, load, newestBuild, oldestBuild, purgeCache, put, putAll, reset, search, subMap, tailMap
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, keySet, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.SortedMap
keySet, values
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, remove, size
 

Field Detail

COMPARATOR

public static final Comparator<Comparable> COMPARATOR
Deprecated. as of 1.485 Use ReverseComparator
Constructor Detail

RunMap

public RunMap()
Deprecated. as of 1.485 Use RunMap(File, Constructor).


RunMap

public RunMap(File baseDir,
              RunMap.Constructor cons)
Parameters:
cons - Used to create new instance of Run.
Method Detail

remove

public boolean remove(R run)

iterator

public Iterator<R> iterator()
Walks through builds, newer ones first.

Specified by:
iterator in interface Iterable<R extends Run<?,R>>

removeValue

public boolean removeValue(R run)
Overrides:
removeValue in class AbstractLazyLoadRunMap<R extends Run<?,R>>

getView

public SortedMap<Integer,R> getView()
Gets the read-only view of this map.


newestValue

public R newestValue()
This is the newest build (with the biggest build number)


oldestValue

public R oldestValue()
This is the oldest build (with the smallest build number)


getNumberOf

protected final int getNumberOf(R r)
Description copied from class: AbstractLazyLoadRunMap
Subtype to provide Run.getNumber() so that this class doesn't have to depend on it.

Specified by:
getNumberOf in class AbstractLazyLoadRunMap<R extends Run<?,R>>

getIdOf

protected final String getIdOf(R r)
Description copied from class: AbstractLazyLoadRunMap
Subtype to provide Run.getId() so that this class doesn't have to depend on it.

Specified by:
getIdOf in class AbstractLazyLoadRunMap<R extends Run<?,R>>

put

public R put(R r)
Overrides:
put in class AbstractLazyLoadRunMap<R extends Run<?,R>>

createReference

protected BuildReference<R> createReference(R r)
Reuses the same reference as much as we can.

If concurrency ends up creating a few extra, that's OK, because we are really just trying to reduce the # of references we create.

Overrides:
createReference in class AbstractLazyLoadRunMap<R extends Run<?,R>>

createDirectoryFilter

protected FilenameFilter createDirectoryFilter()
Description copied from class: AbstractLazyLoadRunMap
Lists the actual data directory

Specified by:
createDirectoryFilter in class AbstractLazyLoadRunMap<R extends Run<?,R>>

retrieve

protected R retrieve(File d)
                               throws IOException
Description copied from class: AbstractLazyLoadRunMap
Parses R instance from data in the specified directory.

Specified by:
retrieve in class AbstractLazyLoadRunMap<R extends Run<?,R>>
Returns:
null if the parsing failed.
Throws:
IOException - if the parsing failed. This is just like returning null except the caller will catch the exception and report it.

load

public void load(Job job,
                 RunMap.Constructor<R> cons)
Deprecated. as of 1.485 Use RunMap(File, Constructor)

Backward compatibility method that notifies RunMap of who the owner is. Traditionally, this method blocked and loaded all the build records on the disk, but now all the actual loading happens lazily.

Parameters:
job - Job that owns this map.
cons - Used to create new instance of Run.


Copyright © 2004-2013. All Rights Reserved.