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 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.
 
Constructor Summary
BuildMemory()
           
 
Method Summary
 void completed(GerritTriggeredEvent event, hudson.model.AbstractBuild build)
          Sets the memory that a build is completed for an event.
 void forget(GerritTriggeredEvent event)
          Removes the memory for the event.
 List<hudson.model.AbstractBuild> getBuilds(GerritTriggeredEvent event)
          Returns all started builds in memory for the event.
 BuildsStartedStats getBuildsStartedStats(GerritTriggeredEvent event)
          Gets the statistics of started builds for a specific memory imprint.
 BuildMemory.MemoryImprint getMemoryImprint(GerritTriggeredEvent event)
          Gets the memory of a specific event.
 String getStatusReport(GerritTriggeredEvent event)
          Returns the status report for the given MemoryImprint.
 boolean isAllBuildsCompleted(GerritTriggeredEvent event)
          Tells if all triggered builds have started for a specific memory imprint.
 boolean isAllBuildsStarted(GerritTriggeredEvent event)
          Tells if all triggered builds have started for a specific memory imprint.
 boolean isBuilding(GerritTriggeredEvent event)
          Checks if the provided event exists in this memory.
 boolean isBuilding(GerritTriggeredEvent event, hudson.model.AbstractProject project)
          Checks in memory if the project is building the event.
 void retriggered(GerritTriggeredEvent event, hudson.model.AbstractProject project, List<hudson.model.AbstractBuild> otherBuilds)
          Adds a new memory about a build that has been retriggered.
 void setEntryFailureMessage(GerritTriggeredEvent event, hudson.model.AbstractBuild r, String failureMessage)
          Records the failure message for the given build.
 void started(GerritTriggeredEvent event, hudson.model.AbstractBuild build)
          Sets the memory that a build has started for an event.
 void triggered(GerritTriggeredEvent event, hudson.model.AbstractProject project)
          Adds a new memory about a build that has been/will be triggered.
 void updateTriggerContext(GerritCause cause, hudson.model.AbstractBuild r)
          Updates the TriggerContext for the event.
 
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(GerritTriggeredEvent event)
Gets the memory of a specific event.

Parameters:
event - the event.
Returns:
the memory.

isAllBuildsCompleted

public boolean isAllBuildsCompleted(GerritTriggeredEvent event)
Tells if all triggered builds have started for a specific memory imprint.

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

getBuildsStartedStats

public BuildsStartedStats getBuildsStartedStats(GerritTriggeredEvent event)
Gets the statistics of started builds for a specific memory imprint.

Parameters:
event - the event.
Returns:
the statistics.

getStatusReport

public String getStatusReport(GerritTriggeredEvent event)
Returns the status report for the given MemoryImprint.

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

isAllBuildsStarted

public boolean isAllBuildsStarted(GerritTriggeredEvent event)
Tells if all triggered builds have started for a specific memory imprint.

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

completed

public void completed(GerritTriggeredEvent event,
                      hudson.model.AbstractBuild build)
Sets the memory that a build is completed for an event.

Parameters:
event - the event
build - the build.

started

public void started(GerritTriggeredEvent event,
                    hudson.model.AbstractBuild build)
Sets the memory that a build has started for an event.

Parameters:
event - the event.
build - the build.

triggered

public void triggered(GerritTriggeredEvent 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.

retriggered

public void retriggered(GerritTriggeredEvent event,
                        hudson.model.AbstractProject project,
                        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.

forget

public void forget(GerritTriggeredEvent event)
Removes the memory for the event.

Parameters:
event - the event.

updateTriggerContext

public void updateTriggerContext(GerritCause cause,
                                 hudson.model.AbstractBuild r)
Updates the TriggerContext for the event. 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:
cause - the cause.
r - the build the cause is in.

isBuilding

public boolean isBuilding(GerritTriggeredEvent 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(GerritTriggeredEvent event)
Checks if the provided event exists in this memory.

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

getBuilds

public List<hudson.model.AbstractBuild> getBuilds(GerritTriggeredEvent event)
Returns all started builds in memory for the event.

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

setEntryFailureMessage

public void setEntryFailureMessage(GerritTriggeredEvent event,
                                   hudson.model.AbstractBuild r,
                                   String failureMessage)
Records the failure message for the given build.

Parameters:
event - the event.
r - the build that caused the failure.
failureMessage - the failure message


Copyright © 2004-2013. All Rights Reserved.