com.sonyericsson.hudson.plugins.gerrit.trigger.gerritnotifier.model
Class BuildMemory

java.lang.Object
  extended by com.sonyericsson.hudson.plugins.gerrit.trigger.gerritnotifier.model.BuildMemory

public class BuildMemory
extends java.lang.Object

Keeps track of what builds have been triggered and if all builds are done for specific events.

Author:
Robert Sandell <robert.sandell@sonyericsson.com>

Nested Class Summary
static class BuildMemory.MemoryImprint
          A holder for all builds triggered by one event.
static class BuildMemory.PatchSetKey
          The Key to use to map events and builds.
 
Constructor Summary
BuildMemory()
           
 
Method Summary
 BuildMemory.PatchSetKey completed(PatchsetCreated event, hudson.model.AbstractBuild build)
          Sets the memory that a build is completed for an event.
 void forget(BuildMemory.PatchSetKey key)
          Removes the memory for the provided key.
 java.util.List<hudson.model.AbstractBuild> getBuilds(BuildMemory.PatchSetKey key)
          Returns all started builds in memory for the given key.
 BuildsStartedStats getBuildsStartedStats(BuildMemory.PatchSetKey key)
          Gets the statistics of started builds for a specific memory imprint.
 BuildMemory.MemoryImprint getMemoryImprint(BuildMemory.PatchSetKey key)
          Gets the memory of a specific key.
 java.lang.String getStatusReport(BuildMemory.PatchSetKey key)
          Returns the status report for the given MemoryImprint.
 boolean isAllBuildsCompleted(BuildMemory.PatchSetKey key)
          Tells if all triggered builds have started for a specific memory imprint.
 boolean isAllBuildsCompleted(PatchsetCreated event)
          Tells if all triggered builds have started for a specific event.
 boolean isAllBuildsStarted(BuildMemory.PatchSetKey key)
          Tells if all triggered builds have started for a specific memory imprint.
 boolean isAllBuildsStarted(PatchsetCreated event)
          Tells if all triggered builds have started for a specific event.
 boolean isBuilding(PatchsetCreated event)
          Checks if the provided event exists in this memory.
 boolean isBuilding(PatchsetCreated event, hudson.model.AbstractProject project)
          Checks in memory if the project is building the event.
 BuildMemory.PatchSetKey retriggered(PatchsetCreated event, hudson.model.AbstractProject project, java.util.List<hudson.model.AbstractBuild> otherBuilds)
          Adds a new memory about a build that has been retriggered.
 void setEntryFailureMessage(BuildMemory.PatchSetKey key, hudson.model.AbstractBuild r, java.lang.String failureMessage)
          Records the failure message for the given build.
 BuildMemory.PatchSetKey started(PatchsetCreated event, hudson.model.AbstractBuild build)
          Sets the memory that a build has started for an event.
 BuildMemory.PatchSetKey triggered(PatchsetCreated event, hudson.model.AbstractProject project)
          Adds a new memory about a build that has been/will be triggered.
 void updateTriggerContext(BuildMemory.PatchSetKey key, GerritCause cause, hudson.model.AbstractBuild r)
          Updates the TriggerContext for the provided key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BuildMemory

public BuildMemory()
Method Detail

getMemoryImprint

public BuildMemory.MemoryImprint getMemoryImprint(BuildMemory.PatchSetKey key)
Gets the memory of a specific key.

Parameters:
key - the key
Returns:
the memory.

isAllBuildsCompleted

public boolean isAllBuildsCompleted(PatchsetCreated event)
Tells if all triggered builds have started for a specific event. This is a bit slower than isAllBuildsCompleted(PatchSetKey) since an internal key needs to be created.

Parameters:
event - the event.
Returns:
true if it is so.

isAllBuildsCompleted

public boolean isAllBuildsCompleted(BuildMemory.PatchSetKey key)
Tells if all triggered builds have started for a specific memory imprint.

Parameters:
key - the key to the memory.
Returns:
true if it is so.

getBuildsStartedStats

public BuildsStartedStats getBuildsStartedStats(BuildMemory.PatchSetKey key)
Gets the statistics of started builds for a specific memory imprint.

Parameters:
key - the memory key.
Returns:
the statistics.

getStatusReport

public java.lang.String getStatusReport(BuildMemory.PatchSetKey key)
Returns the status report for the given MemoryImprint.

Parameters:
key - the key to the memory.
Returns:
the status as it is now.
See Also:
BuildMemory.MemoryImprint.getStatusReport()

isAllBuildsStarted

public boolean isAllBuildsStarted(PatchsetCreated event)
Tells if all triggered builds have started for a specific event. This is a bit slower than isAllBuildsStarted(PatchSetKey) since an internal key needs to be created.

Parameters:
event - the event.
Returns:
true if it is so.

isAllBuildsStarted

public boolean isAllBuildsStarted(BuildMemory.PatchSetKey key)
Tells if all triggered builds have started for a specific memory imprint.

Parameters:
key - the key to the memory.
Returns:
true if it is so.

completed

public BuildMemory.PatchSetKey completed(PatchsetCreated event,
                                         hudson.model.AbstractBuild build)
Sets the memory that a build is completed for an event.

Parameters:
event - the event
build - the build.
Returns:
the key to the memory.

started

public BuildMemory.PatchSetKey started(PatchsetCreated event,
                                       hudson.model.AbstractBuild build)
Sets the memory that a build has started for an event.

Parameters:
event - the event.
build - the build.
Returns:
the key to the memory.

triggered

public BuildMemory.PatchSetKey triggered(PatchsetCreated event,
                                         hudson.model.AbstractProject project)
Adds a new memory about a build that has been/will be triggered.

Parameters:
event - the event that triggered it.
project - the project that was triggered.
Returns:
the key to the memory.

retriggered

public BuildMemory.PatchSetKey retriggered(PatchsetCreated event,
                                           hudson.model.AbstractProject project,
                                           java.util.List<hudson.model.AbstractBuild> otherBuilds)
Adds a new memory about a build that has been retriggered. If there is an active memory about the provided event, then the project is reset with no build info. Otherwise the memory is recreated from the list of other builds and their result.

Parameters:
event - the event to be retriggered.
project - the project that has been retriggered.
otherBuilds - the list of other builds that was in the "old" memory.
Returns:
the key to the memory.

forget

public void forget(BuildMemory.PatchSetKey key)
Removes the memory for the provided key.

Parameters:
key - the key to the memory.

updateTriggerContext

public void updateTriggerContext(BuildMemory.PatchSetKey key,
                                 GerritCause cause,
                                 hudson.model.AbstractBuild r)
Updates the TriggerContext for the provided key. The cause and build is the "focal point" for the update, but all memory entities will be updated, but only the current context will be TriggerContext.setThisBuild(hudson.model.AbstractBuild)updated.

Parameters:
key - the key to have as "focus" for the update.
cause - the cause.
r - the build the cause is in.

isBuilding

public boolean isBuilding(PatchsetCreated event,
                          hudson.model.AbstractProject project)
Checks in memory if the project is building the event.

Parameters:
event - the event.
project - the project.
Returns:
true if so.

isBuilding

public boolean isBuilding(PatchsetCreated event)
Checks if the provided event exists in this memory.

Parameters:
event - the event to look for.
Returns:
true if so.

getBuilds

public java.util.List<hudson.model.AbstractBuild> getBuilds(BuildMemory.PatchSetKey key)
Returns all started builds in memory for the given key.

Parameters:
key - the key for the memory.
Returns:
the list of builds, or null if there is no memory.

setEntryFailureMessage

public void setEntryFailureMessage(BuildMemory.PatchSetKey key,
                                   hudson.model.AbstractBuild r,
                                   java.lang.String failureMessage)
Records the failure message for the given build.

Parameters:
key - the key for the memory.
r - the build that caused the failure.
failureMessage - the failure message


Copyright © 2004-2012. All Rights Reserved.