com.sonyericsson.hudson.plugins.gerrit.trigger.dependency
Class DependencyQueueTaskDispatcher

java.lang.Object
  extended by hudson.model.queue.QueueTaskDispatcher
      extended by com.sonyericsson.hudson.plugins.gerrit.trigger.dependency.DependencyQueueTaskDispatcher
All Implemented Interfaces:
GerritEventLifecycleListener, com.sonymobile.tools.gerrit.gerritevents.GerritEventListener, hudson.ExtensionPoint

@Extension
public class DependencyQueueTaskDispatcher
extends hudson.model.queue.QueueTaskDispatcher
implements GerritEventLifecycleListener, com.sonymobile.tools.gerrit.gerritevents.GerritEventListener

Blocks builds from running until the projects on which they depend have finished building. This applies on a per-event basis, so for each event, the plugin will wait for dependency projects (i.e., projects on which it depends) which also trigger for the same event, to finish building before building a dependent project.

Author:
Yannick Bréhon <yannick.brehon@smartmatic.com>

Nested Class Summary
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Constructor Summary
DependencyQueueTaskDispatcher()
          Default constructor.
 
Method Summary
 void allBuildsCompleted(com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent event)
          Called when all builds triggered by the event are completed.
 void buildCompleted(com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent event, hudson.model.AbstractBuild build)
          Called when a build is completed.
 void buildStarted(com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent event, hudson.model.AbstractBuild build)
          Called when a build has started.
 hudson.model.queue.CauseOfBlockage canRun(hudson.model.Queue.Item item)
           
 void gerritEvent(com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent event)
          Process lifecycle events.
protected  List<hudson.model.AbstractProject> getBlockingDependencyProjects(List<hudson.model.AbstractProject> dependencies, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
          Gets the subset of projects which have a building element needing to complete for the same event.
static DependencyQueueTaskDispatcher getInstance()
          Returns the registered instance of this class from the list of all listeners.
static List<hudson.model.AbstractProject> getProjectsFromString(String projects, hudson.model.Item context)
          Return a list of Abstract Projects from their string names.
 void onDoneTriggeringAll(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
          Signals this event is done retriggering all its projects.
 void onTriggeringAll(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
          Signals this event started retriggering all its projects.
 void projectTriggered(com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent event, hudson.model.AbstractProject project)
          Called when the trigger of a project has decided to trigger on the event.
 void triggerScanDone(com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent event)
          Called after all triggers has been enumerated.
 void triggerScanStarting(com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent event)
          Called before any triggers are enumerated.
 
Methods inherited from class hudson.model.queue.QueueTaskDispatcher
all, canTake, canTake
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DependencyQueueTaskDispatcher

public DependencyQueueTaskDispatcher()
Default constructor.

Method Detail

getInstance

public static DependencyQueueTaskDispatcher getInstance()
Returns the registered instance of this class from the list of all listeners.

Returns:
the instance.

canRun

public hudson.model.queue.CauseOfBlockage canRun(hudson.model.Queue.Item item)
Overrides:
canRun in class hudson.model.queue.QueueTaskDispatcher

getBlockingDependencyProjects

protected List<hudson.model.AbstractProject> getBlockingDependencyProjects(List<hudson.model.AbstractProject> dependencies,
                                                                           com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Gets the subset of projects which have a building element needing to complete for the same event.

Parameters:
dependencies - The list of projects which need to be checked
event - The event should have also caused the blocking builds.
Returns:
the sublist of dependencies which need to be completed before this event is resolved.

getProjectsFromString

public static List<hudson.model.AbstractProject> getProjectsFromString(String projects,
                                                                       hudson.model.Item context)
Return a list of Abstract Projects from their string names.

Parameters:
projects - The string containing the projects, comma-separated.
context - The context in which to read the string
Returns:
the list of projects

onTriggeringAll

public void onTriggeringAll(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Signals this event started retriggering all its projects. In the meantime, no builds with dependencies should be allowed to start.

Parameters:
event - the event triggering

onDoneTriggeringAll

public void onDoneTriggeringAll(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Signals this event is done retriggering all its projects. Builds with dependencies may be allowed to start once their dependencies are built..

Parameters:
event - the event done triggering

gerritEvent

public void gerritEvent(com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent event)
Process lifecycle events. We register to these events so we can get notified of the beginning of the scanning and end of scanning.

Specified by:
gerritEvent in interface com.sonymobile.tools.gerrit.gerritevents.GerritEventListener
Parameters:
event - the event to which we subscribe.

triggerScanStarting

public void triggerScanStarting(com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent event)
Description copied from interface: GerritEventLifecycleListener
Called before any triggers are enumerated.

Specified by:
triggerScanStarting in interface GerritEventLifecycleListener
Parameters:
event - the event.

triggerScanDone

public void triggerScanDone(com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent event)
Description copied from interface: GerritEventLifecycleListener
Called after all triggers has been enumerated.

Specified by:
triggerScanDone in interface GerritEventLifecycleListener
Parameters:
event - the event.

projectTriggered

public void projectTriggered(com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent event,
                             hudson.model.AbstractProject project)
Description copied from interface: GerritEventLifecycleListener
Called when the trigger of a project has decided to trigger on the event.

Specified by:
projectTriggered in interface GerritEventLifecycleListener
Parameters:
event - the event.
project - the project that was triggered.

buildStarted

public void buildStarted(com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent event,
                         hudson.model.AbstractBuild build)
Description copied from interface: GerritEventLifecycleListener
Called when a build has started.

Specified by:
buildStarted in interface GerritEventLifecycleListener
Parameters:
event - the event.
build - the build.

buildCompleted

public void buildCompleted(com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent event,
                           hudson.model.AbstractBuild build)
Description copied from interface: GerritEventLifecycleListener
Called when a build is completed.

Specified by:
buildCompleted in interface GerritEventLifecycleListener
Parameters:
event - the event.
build - the build.

allBuildsCompleted

public void allBuildsCompleted(com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent event)
Description copied from interface: GerritEventLifecycleListener
Called when all builds triggered by the event are completed.

Specified by:
allBuildsCompleted in interface GerritEventLifecycleListener
Parameters:
event - the event.


Copyright © 2004-2014. All Rights Reserved.