Class BuildMemory
- java.lang.Object
-
- 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
Nested Classes Modifier and Type Class Description static class
BuildMemory.MemoryImprint
A holder for all builds triggered by one event.
-
Constructor Summary
Constructors Constructor Description BuildMemory()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
cancelled(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Job project)
Sets the status if a project to completed when queue is cancelled.void
completed(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Run build)
Sets the memory that a build is completed for an event.void
forget(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Removes the memory for the event.List<Run>
getBuilds(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Returns all started builds in memory for the event.BuildsStartedStats
getBuildsStartedStats(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Gets the statistics of started builds for a specific memory imprint.BuildMemory.MemoryImprint
getMemoryImprint(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Gets the memory of a specific event.String
getStatusReport(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Returns the status report for the given MemoryImprint.boolean
isAllBuildsCompleted(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Tells if all triggered builds have started for a specific memory imprint.boolean
isAllBuildsStarted(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Tells if all triggered builds have started for a specific memory imprint.boolean
isBuilding(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Checks if the provided event exists in this memory.boolean
isBuilding(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Job project)
Checks in memory if the project is building the event.boolean
isTriggered(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Job project)
Checks in memory if the project has been triggered for the event.void
removeProject(Job project)
Removes project from all memory imprints.BuildMemoryReport
report()
Creates a snapshot clone of the current coordination memory status.void
retriggered(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Job project, List<Run> otherBuilds)
Adds a new memory about a build that has been retriggered.void
setEntryCustomUrl(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Run r, String customUrl)
Records a custom URL for the given build.void
setEntryFailureMessage(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Run r, String failureMessage)
void
setEntryUnsuccessfulMessage(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Run r, String unsuccessfulMessage)
Records the unsuccessful message for the given build.void
started(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Run build)
Sets the memory that a build has started for an event.void
triggered(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Job project)
Adds a new memory about a build that has been/will be triggered.void
updateTriggerContext(GerritCause cause, Run r)
Updates theTriggerContext
for the event.
-
-
-
Method Detail
-
getMemoryImprint
public BuildMemory.MemoryImprint getMemoryImprint(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Gets the memory of a specific event.- Parameters:
event
- the event.- Returns:
- the memory.
-
isAllBuildsCompleted
public boolean isAllBuildsCompleted(com.sonymobile.tools.gerrit.gerritevents.dto.events.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(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Gets the statistics of started builds for a specific memory imprint.- Parameters:
event
- the event.- Returns:
- the statistics.
-
getStatusReport
public String getStatusReport(com.sonymobile.tools.gerrit.gerritevents.dto.events.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(com.sonymobile.tools.gerrit.gerritevents.dto.events.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(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Run build)
Sets the memory that a build is completed for an event.- Parameters:
event
- the eventbuild
- the build.
-
started
public void started(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Run build)
Sets the memory that a build has started for an event.- Parameters:
event
- the event.build
- the build.
-
triggered
public void triggered(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Job 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(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Job project, List<Run> 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.
-
cancelled
public void cancelled(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Job project)
Sets the status if a project to completed when queue is cancelled.- Parameters:
event
- the event to be retriggered.project
- the project that has been retriggered.
-
forget
public void forget(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Removes the memory for the event.- Parameters:
event
- the event.
-
updateTriggerContext
public void updateTriggerContext(GerritCause cause, Run r)
Updates theTriggerContext
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 beTriggerContext.setThisBuild(hudson.model.Run)
updated.- Parameters:
cause
- the cause.r
- the build the cause is in.
-
isTriggered
public boolean isTriggered(@NonNull com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, @NonNull Job project)
Checks in memory if the project has been triggered for the event.- Parameters:
event
- the event.project
- the project.- Returns:
- true if so.
-
isBuilding
public boolean isBuilding(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, @NonNull Job 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(com.sonymobile.tools.gerrit.gerritevents.dto.events.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<Run> getBuilds(com.sonymobile.tools.gerrit.gerritevents.dto.events.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.
-
setEntryCustomUrl
public void setEntryCustomUrl(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Run r, String customUrl)
Records a custom URL for the given build.- Parameters:
event
- the event.r
- the build that caused the failure.customUrl
- the URL.
-
setEntryUnsuccessfulMessage
public void setEntryUnsuccessfulMessage(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Run r, String unsuccessfulMessage)
Records the unsuccessful message for the given build.- Parameters:
event
- the event.r
- the build that caused the failure.unsuccessfulMessage
- the unsuccessful message
-
setEntryFailureMessage
@Deprecated public void setEntryFailureMessage(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Run r, String failureMessage)
Deprecated.Records the failure message for the given build.- Parameters:
event
- the event.r
- the build that caused the failure.failureMessage
- the failure message
-
removeProject
public void removeProject(Job project)
Removes project from all memory imprints.- Parameters:
project
- to be removed.
-
report
@NonNull public BuildMemoryReport report()
Creates a snapshot clone of the current coordination memory status.- Returns:
- the report
-
-