threads all plumbed thru

Threads all setup and plumbed thru to get gearman executors and
management works running

Change-Id: I0d6534c18b1dea23c02021afe2f325b03d3e9cb0
This commit is contained in:
Khai Do 2013-01-15 16:55:04 -08:00
parent 03a6f97c37
commit 38788bdf69
6 changed files with 511 additions and 335 deletions

622
pom.xml
View File

@ -17,322 +17,336 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.460</version><!-- which version of Jenkins is this plugin built against? -->
</parent>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.460</version><!-- which version of Jenkins is this plugin built against? -->
</parent>
<artifactId>gearman-plugin</artifactId>
<packaging>hpi</packaging>
<artifactId>gearman-plugin</artifactId>
<packaging>hpi</packaging>
<name>Gearman Plugin</name>
<url>http://wiki.jenkins-ci.org/display/JENKINS/Gearman+Plugin</url>
<name>Gearman Plugin</name>
<url>http://wiki.jenkins-ci.org/display/JENKINS/Gearman+Plugin</url>
<licenses>
<license>
<name>Apache License Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<licenses>
<license>
<name>Apache License Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
</license>
</licenses>
<developers>
<developer>
<id>khaido</id>
<name>Khai Do</name>
<email>do.khai@gmail.com</email>
</developer>
</developers>
<developers>
<developer>
<id>khaido</id>
<name>Khai Do</name>
<email>do.khai@gmail.com</email>
</developer>
</developers>
<scm>
<connection>scm:git:git://github.com/openstack-infra/gearman-plugin.git</connection>
<developerConnection>scm:git:git@github.com:openstack-infra/gearman-plugin.git</developerConnection>
<url>https://github.com/openstack-infra/gearman-plugin</url>
</scm>
<scm>
<connection>scm:git:git://github.com/openstack-infra/gearman-plugin.git</connection>
<developerConnection>scm:git:git@github.com:openstack-infra/gearman-plugin.git</developerConnection>
<url>https://github.com/openstack-infra/gearman-plugin</url>
</scm>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
<repository>
<id>dev.nightlabs.org</id>
<url>http://dev.nightlabs.org/maven-repository/repo/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<repository>
<id>java.net-m2-repository</id>
<url>http://maven.jenkins-ci.org/content/repositories/releases/</url>
</repository>
<site>
<id>github-project-site</id>
<url>gitsite:git@github.com/openstack-infra/gearman-plugin</url>
</site>
</distributionManagement>
<distributionManagement>
<repository>
<id>java.net-m2-repository</id>
<url>http://maven.jenkins-ci.org/content/repositories/releases/</url>
</repository>
<site>
<id>github-project-site</id>
<url>gitsite:git@github.com/openstack-infra/gearman-plugin</url>
</site>
</distributionManagement>
<properties>
<!-- http://docs.codehaus.org/display/MAVENUSER/POM+Element+for+Source+File+Encoding -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<compileTarget>1.6</compileTarget>
<!-- define all plugin versions -->
<maven.version>3.0.1</maven.version>
<maven-antrun-plugin.version>1.6</maven-antrun-plugin.version>
<maven-assembly-plugin.version>2.2</maven-assembly-plugin.version>
<maven-changelog-plugin.version>2.2</maven-changelog-plugin.version>
<maven-checkstyle-plugin.version>2.6</maven-checkstyle-plugin.version>
<maven-clean-plugin.version>2.4.1</maven-clean-plugin.version>
<maven-compiler-plugin.version>2.3.2</maven-compiler-plugin.version>
<maven-dependency-plugin.version>2.1</maven-dependency-plugin.version>
<maven-deploy-plugin.version>2.5</maven-deploy-plugin.version>
<maven-doap-plugin.version>1.0</maven-doap-plugin.version>
<maven-eclipse-plugin.version>2.8</maven-eclipse-plugin.version>
<maven-enforcer-plugin.version>1.0</maven-enforcer-plugin.version>
<maven-help-plugin.version>2.1.1</maven-help-plugin.version>
<maven-install-plugin.version>2.3.1</maven-install-plugin.version>
<maven-javadoc-plugin.version>2.7</maven-javadoc-plugin.version>
<maven-jar-plugin.version>2.3.1</maven-jar-plugin.version>
<maven-jetty-plugin.version>6.1.26</maven-jetty-plugin.version>
<maven-jxr-plugin.version>2.2</maven-jxr-plugin.version>
<maven-pmd-plugin.version>2.5</maven-pmd-plugin.version>
<maven-project-info-reports-plugin.version>2.3.1</maven-project-info-reports-plugin.version>
<maven-plugin-plugin.version>2.4.3</maven-plugin-plugin.version>
<maven-reactor-plugin.version>1.0</maven-reactor-plugin.version>
<maven-release-plugin.version>2.1</maven-release-plugin.version>
<maven-remote-resources-plugin.version>1.1</maven-remote-resources-plugin.version>
<maven-resources-plugin.version>2.4.3</maven-resources-plugin.version>
<maven-site-plugin.version>2.1.1</maven-site-plugin.version>
<maven-source-plugin.version>2.1.2</maven-source-plugin.version>
<maven-surefire-plugin.version>2.7.2</maven-surefire-plugin.version>
<maven-surefire-report-plugin.version>2.7.2</maven-surefire-report-plugin.version>
<maven-war-plugin.version>2.1.1</maven-war-plugin.version>
<apt-maven-plugin.version>1.0-alpha-4</apt-maven-plugin.version>
<axistools-maven-plugin.version>1.4</axistools-maven-plugin.version>
<buildnumber-maven-plugin.version>1.0-beta-4</buildnumber-maven-plugin.version>
<build-helper-maven-plugin.version>1.5</build-helper-maven-plugin.version>
<cargo-maven2-plugin.version>1.0.5</cargo-maven2-plugin.version>
<cobertura-maven-plugin.version>2.4</cobertura-maven-plugin.version>
<exec-maven-plugin.version>1.2</exec-maven-plugin.version>
<findbugs-maven-plugin.version>2.3.1</findbugs-maven-plugin.version>
<gwt-maven-plugin.version>2.1.0-1</gwt-maven-plugin.version>
<javancss-maven-plugin.version>2.0</javancss-maven-plugin.version>
<jdepend-maven-plugin.version>2.0-beta-2</jdepend-maven-plugin.version>
<openjpa-maven-plugin.version>1.2</openjpa-maven-plugin.version>
<taglist-maven-plugin.version>2.4</taglist-maven-plugin.version>
<versions-maven-plugin.version>1.2</versions-maven-plugin.version>
<xml-maven-plugin.version>1.0-beta-3</xml-maven-plugin.version>
</properties>
<properties>
<!-- http://docs.codehaus.org/display/MAVENUSER/POM+Element+for+Source+File+Encoding -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<compileTarget>1.6</compileTarget>
<!-- define all plugin versions -->
<maven.version>3.0.1</maven.version>
<maven-antrun-plugin.version>1.6</maven-antrun-plugin.version>
<maven-assembly-plugin.version>2.2</maven-assembly-plugin.version>
<maven-changelog-plugin.version>2.2</maven-changelog-plugin.version>
<maven-checkstyle-plugin.version>2.6</maven-checkstyle-plugin.version>
<maven-clean-plugin.version>2.4.1</maven-clean-plugin.version>
<maven-compiler-plugin.version>2.3.2</maven-compiler-plugin.version>
<maven-dependency-plugin.version>2.1</maven-dependency-plugin.version>
<maven-deploy-plugin.version>2.5</maven-deploy-plugin.version>
<maven-doap-plugin.version>1.0</maven-doap-plugin.version>
<maven-eclipse-plugin.version>2.8</maven-eclipse-plugin.version>
<maven-enforcer-plugin.version>1.0</maven-enforcer-plugin.version>
<maven-help-plugin.version>2.1.1</maven-help-plugin.version>
<maven-install-plugin.version>2.3.1</maven-install-plugin.version>
<maven-javadoc-plugin.version>2.7</maven-javadoc-plugin.version>
<maven-jar-plugin.version>2.3.1</maven-jar-plugin.version>
<maven-jetty-plugin.version>6.1.26</maven-jetty-plugin.version>
<maven-jxr-plugin.version>2.2</maven-jxr-plugin.version>
<maven-pmd-plugin.version>2.5</maven-pmd-plugin.version>
<maven-project-info-reports-plugin.version>2.3.1</maven-project-info-reports-plugin.version>
<maven-plugin-plugin.version>2.4.3</maven-plugin-plugin.version>
<maven-reactor-plugin.version>1.0</maven-reactor-plugin.version>
<maven-release-plugin.version>2.1</maven-release-plugin.version>
<maven-remote-resources-plugin.version>1.1</maven-remote-resources-plugin.version>
<maven-resources-plugin.version>2.4.3</maven-resources-plugin.version>
<maven-site-plugin.version>2.1.1</maven-site-plugin.version>
<maven-source-plugin.version>2.1.2</maven-source-plugin.version>
<maven-surefire-plugin.version>2.7.2</maven-surefire-plugin.version>
<maven-surefire-report-plugin.version>2.7.2</maven-surefire-report-plugin.version>
<maven-war-plugin.version>2.1.1</maven-war-plugin.version>
<apt-maven-plugin.version>1.0-alpha-4</apt-maven-plugin.version>
<axistools-maven-plugin.version>1.4</axistools-maven-plugin.version>
<buildnumber-maven-plugin.version>1.0-beta-4</buildnumber-maven-plugin.version>
<build-helper-maven-plugin.version>1.5</build-helper-maven-plugin.version>
<cargo-maven2-plugin.version>1.0.5</cargo-maven2-plugin.version>
<cobertura-maven-plugin.version>2.4</cobertura-maven-plugin.version>
<exec-maven-plugin.version>1.2</exec-maven-plugin.version>
<findbugs-maven-plugin.version>2.3.1</findbugs-maven-plugin.version>
<gwt-maven-plugin.version>2.1.0-1</gwt-maven-plugin.version>
<javancss-maven-plugin.version>2.0</javancss-maven-plugin.version>
<jdepend-maven-plugin.version>2.0-beta-2</jdepend-maven-plugin.version>
<openjpa-maven-plugin.version>1.2</openjpa-maven-plugin.version>
<taglist-maven-plugin.version>2.4</taglist-maven-plugin.version>
<versions-maven-plugin.version>1.2</versions-maven-plugin.version>
<xml-maven-plugin.version>1.0-beta-3</xml-maven-plugin.version>
</properties>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.3</version>
</extension>
<extension>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-manager-plexus</artifactId>
<version>1.3</version>
</extension>
<extension>
<groupId>org.kathrynhuxtable.maven.wagon</groupId>
<artifactId>wagon-gitsite</artifactId>
<version>0.3.1</version>
</extension>
</extensions>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>${maven-clean-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${compileSource}</source>
<target>${compileTarget}</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>${maven-deploy-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${maven-enforcer-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>${maven-install-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>${maven-release-plugin.version}</version>
<configuration>
<allowTimestampedSnapshots>true</allowTimestampedSnapshots>
<autoVersionSubmodules>true</autoVersionSubmodules>
<goals>clean deploy</goals>
<preparationGoals>clean deploy</preparationGoals>
<releaseProfiles>release</releaseProfiles>
</configuration>
</plugin>
<plugin>
<artifactId>maven-remote-resources-plugin</artifactId>
<version>${maven-remote-resources-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven-resources-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>${maven-site-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<parallel>methods</parallel>
<testFailureIgnore>true</testFailureIgnore>
<threadCount>4</threadCount>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-doap-plugin</artifactId>
<version>${maven-doap-plugin.version}</version>
<executions>
<execution>
<id>site</id>
<phase>pre-site</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<doapFile>${project.reporting.outputDirectory}/doap.rdf</doapFile>
<asfExtOptions>
<included>false</included>
</asfExtOptions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>${maven-site-plugin.version}</version>
</plugin>
</plugins>
</build>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.3</version>
</extension>
<extension>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-manager-plexus</artifactId>
<version>1.3</version>
</extension>
<extension>
<groupId>org.kathrynhuxtable.maven.wagon</groupId>
<artifactId>wagon-gitsite</artifactId>
<version>0.3.1</version>
</extension>
</extensions>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>${maven-clean-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${compileSource}</source>
<target>${compileTarget}</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>${maven-deploy-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${maven-enforcer-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>${maven-install-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>${maven-release-plugin.version}</version>
<configuration>
<allowTimestampedSnapshots>true</allowTimestampedSnapshots>
<autoVersionSubmodules>true</autoVersionSubmodules>
<goals>clean deploy</goals>
<preparationGoals>clean deploy</preparationGoals>
<releaseProfiles>release</releaseProfiles>
</configuration>
</plugin>
<plugin>
<artifactId>maven-remote-resources-plugin</artifactId>
<version>${maven-remote-resources-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven-resources-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>${maven-site-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<parallel>methods</parallel>
<testFailureIgnore>true</testFailureIgnore>
<threadCount>4</threadCount>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-doap-plugin</artifactId>
<version>${maven-doap-plugin.version}</version>
<executions>
<execution>
<id>site</id>
<phase>pre-site</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<doapFile>${project.reporting.outputDirectory}/doap.rdf</doapFile>
<asfExtOptions>
<included>false</included>
</asfExtOptions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>${maven-site-plugin.version}</version>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<artifactId>maven-changelog-plugin</artifactId>
<version>${maven-changelog-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-jxr-plugin</artifactId>
<version>${maven-jxr-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-pmd-plugin</artifactId>
<version>${maven-pmd-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>${maven-plugin-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>${maven-project-info-reports-plugin.version}</version>
<reportSets>
<reportSet>
<reports>
<report>cim</report>
<report>distribution-management</report>
<report>index</report>
<report>issue-tracking</report>
<report>license</report>
<report>mailing-list</report>
<report>project-team</report>
<report>scm</report>
<report>summary</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>${maven-surefire-report-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>${cobertura-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javancss-maven-plugin</artifactId>
<version>${javancss-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId>
<version>${jdepend-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>taglist-maven-plugin</artifactId>
<version>${taglist-maven-plugin.version}</version>
</plugin>
</plugins>
</reporting>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.2</version>
</dependency>
</dependencies>
<reporting>
<plugins>
<plugin>
<artifactId>maven-changelog-plugin</artifactId>
<version>${maven-changelog-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-jxr-plugin</artifactId>
<version>${maven-jxr-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-pmd-plugin</artifactId>
<version>${maven-pmd-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>${maven-plugin-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>${maven-project-info-reports-plugin.version}</version>
<reportSets>
<reportSet>
<reports>
<report>cim</report>
<report>distribution-management</report>
<report>index</report>
<report>issue-tracking</report>
<report>license</report>
<report>mailing-list</report>
<report>project-team</report>
<report>scm</report>
<report>summary</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>${maven-surefire-report-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>${cobertura-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javancss-maven-plugin</artifactId>
<version>${javancss-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId>
<version>${jdepend-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>taglist-maven-plugin</artifactId>
<version>${taglist-maven-plugin.version}</version>
</plugin>
</plugins>
</reporting>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>org.gearman</groupId>
<artifactId>gearman-java</artifactId>
<version>0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2</version>
</dependency>
</dependencies>
</project>

View File

@ -19,57 +19,74 @@
package hudson.plugins.gearman;
import java.util.Date;
import java.util.UUID;
import org.gearman.common.GearmanNIOJobServerConnection;
import org.gearman.worker.GearmanWorker;
import org.gearman.worker.GearmanWorkerImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AbstractWorkerThread implements Runnable {
/*
* Thread to run gearman worker
*/
public static final String DEFAULT_NAME = "anonymous";
public static final String DEFAULT_HOST = "localhost";
public static final int DEFAULT_PORT = 4730;
public abstract class AbstractWorkerThread implements Runnable {
public static final String DEFAULT_EXECUTOR_NAME = "anonymous";
private static final Logger logger = LoggerFactory
.getLogger(AbstractWorkerThread.class);
.getLogger(Constants.PLUGIN_EXECTUOR_LOGGER_NAME);
protected String host;
protected int port;
protected String name;
protected GearmanWorker worker;
private GearmanNIOJobServerConnection conn;
private Thread thread;
public AbstractWorkerThread() {
this(DEFAULT_HOST, DEFAULT_PORT, DEFAULT_NAME);
}
public AbstractWorkerThread(String host, int port) {
this(host, port, DEFAULT_NAME);
}
public AbstractWorkerThread(String host, int port, String name) {
this.name = name;
this.host = host;
this.port = port;
worker = new GearmanWorkerImpl();
conn = new GearmanNIOJobServerConnection(host, port);
}
/*
* Register jobs with the gearman worker. This method should be overriden.
*/
public void registerJobs() {
logger.info("----- AbstractorWorker registerJobs function ----");
}
/*
* Start the thread
*/
public void start() {
thread = new Thread(this);
thread.start();
}
/*
* Stop the thread
*/
public void stop() {
// Interrupt the thread so it unblocks any blocking call
logger.info("Stopping " + name + " (" + new Date().toString() + ")");
if (worker.isRunning()) {
logger.info("Stopping " + name + " (" + new Date().toString() + ")");
worker.stop();
logger.info("Stopped " + name + " (" + new Date().toString() + ")");
}
thread.interrupt();
// Wait until the thread exits
try {
thread.join();
} catch (InterruptedException ex) {
// Unexpected interruption
@ -77,14 +94,24 @@ public class AbstractWorkerThread implements Runnable {
System.exit(1);
}
logger.info("Stopped " + name + " (" + new Date().toString() + ")");
}
/*
* Execute the thread (non-Javadoc)
*
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
logger.info("Starting Worker "+ name +" ("+new Date().toString()+")");
if (!worker.isRunning()) {
logger.info("Starting Worker " + name + " ("
+ new Date().toString() + ")");
worker.setWorkerID(UUID.randomUUID().toString());
worker.addServer(conn);
// blocking call.. https://answers.launchpad.net/gearman-java/+question/219175
worker.work();
}
while (!Thread.interrupted()) {
@ -92,8 +119,8 @@ public class AbstractWorkerThread implements Runnable {
logger.info("Running Worker "+ name +" ("+new Date().toString()+")");
try {
Thread.sleep(1000);
} catch(InterruptedException ex) {
Thread.sleep(5000);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}

View File

@ -0,0 +1,32 @@
/*
*
* Copyright 2013 Hewlett-Packard Development Company, L.P.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package hudson.plugins.gearman;
/*
* Constants for the Gearman Plugin
*/
public interface Constants {
/* Defines. */
public static final String GEARMAN_DEFAULT_TCP_HOST = "127.0.0.1";
public static final int GEARMAN_DEFAULT_TCP_PORT = 4730;
public static final String PLUGIN_LOGGER_NAME = "hudson.plugins.gearman.logger";
public static final String PLUGIN_EXECTUOR_LOGGER_NAME = "hudson.plugins.gearman.executor.logger";
}

View File

@ -18,26 +18,61 @@
package hudson.plugins.gearman;
import java.util.Date;
import hudson.model.Node;
import java.util.List;
import jenkins.model.Jenkins;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ExecutorWorkerThread extends AbstractWorkerThread {
/*
* This is thread to run gearman executors
* Executors are used to initiate jenkins builds
*/
public class ExecutorWorkerThread extends AbstractWorkerThread{
private static final Logger logger = LoggerFactory
.getLogger(AbstractWorkerThread.class);
public ExecutorWorkerThread(String host, int port, String name) {
private Node node;
public ExecutorWorkerThread(String host, int port, String nodeName){
super(host, port, nodeName);
this.node = findNode(nodeName);
}
/*
* This function finds the node with the corresponding node name Returns the
* node if found, otherwise returns null
*/
private Node findNode(String nodeName){
Jenkins jenkins = Jenkins.getInstance();
List<Node> nodes = jenkins.getNodes();
Node myNode = null;
for (Node node : nodes) {
if (node.getNodeName().equals(nodeName)){
myNode = node;
}
}
return myNode;
}
public ExecutorWorkerThread(String host, int port, String name, Node node){
super(host, port, name);
this.node = node;
}
@Override
public void registerJobs() {
logger.info("----- ExecutorWorkerThread registerJobs function ----");
logger.info("----- Register executor jobs here ----");
logger.info("----- Registering executor jobs on " + name + " ----");
}

View File

@ -18,11 +18,16 @@
package hudson.plugins.gearman;
import java.util.List;
import java.util.Stack;
import hudson.Launcher;
import hudson.Extension;
import hudson.model.Build;
import hudson.model.BuildListener;
import hudson.model.AbstractBuild;
import hudson.model.Computer;
import hudson.model.Node;
import hudson.tasks.Builder;
import hudson.tasks.BuildStepDescriptor;
@ -34,6 +39,8 @@ import org.slf4j.LoggerFactory;
import javax.management.Descriptor;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
/**
@ -49,7 +56,7 @@ import net.sf.json.JSONObject;
public class GearmanPlugin extends Builder {
private static final Logger logger = LoggerFactory
.getLogger(GearmanPlugin.class);
.getLogger(Constants.PLUGIN_LOGGER_NAME);
private final String name;
@DataBoundConstructor
@ -79,13 +86,25 @@ public class GearmanPlugin extends Builder {
BuildStepDescriptor<Builder> {
private static final Logger logger = LoggerFactory
.getLogger(DescriptorImpl.class);
.getLogger(Constants.PLUGIN_LOGGER_NAME);
private boolean launchWorker; // launchWorker state (from UI checkbox)
private String host; // gearman server host
private int port; // gearman server port
private Jenkins jenkins;
public static Stack<AbstractWorkerThread> gewtHandles; // handles to
// executor
// workers
public static Stack<AbstractWorkerThread> gmwtHandles; // handles to
// management
// workers
public DescriptorImpl() {
logger.info("--- DescriptorImpl Constructor ---");
jenkins = Jenkins.getInstance();
gewtHandles = new Stack<AbstractWorkerThread>();
gmwtHandles = new Stack<AbstractWorkerThread>();
logger.info("--- DescriptorImpl Constructor ---" + host);
logger.info("--- DescriptorImpl Constructor ---" + port);
@ -125,7 +144,7 @@ public class GearmanPlugin extends Builder {
"Error getting the gearman host name");
}
// user input vaerification
// user input verification
if (StringUtils.isEmpty(host) || StringUtils.isBlank(host))
throw new RuntimeException("Invalid gearman host name");
@ -146,6 +165,52 @@ public class GearmanPlugin extends Builder {
logger.info("--- DescriptorImpl Configure function ---"
+ this.getPort());
/*
* Purpose here is to create a 1:1 mapping of 'gearman
* worker':'jenkins node' then use the gearman worker to execute
* builds on that jenkins node
*/
List<Node> nodes = jenkins.getNodes();
if (launchWorker && !nodes.isEmpty()) {
AbstractWorkerThread gwt = null;
for (Node node : nodes) {
Computer c = node.toComputer();
if (c.isOnline()) {
// create a gearman executor for every node
gwt = new ExecutorWorkerThread(host, port,
node.getNodeName());
gwt.registerJobs();
gwt.start();
gewtHandles.push(gwt);
}
}
/*
* Create one additional worker as a management node. This
* worker will be used to abort builds.
*/
if (!gewtHandles.isEmpty()) {
gwt = new ManagementWorkerThread(host, port, host);
gwt.registerJobs();
gwt.start();
gmwtHandles.push(gwt);
}
} else if (!launchWorker) { // stop worker threads
while (!gewtHandles.isEmpty()) { // stop executors
AbstractWorkerThread task = gewtHandles.pop();
task.stop();
}
while (!gmwtHandles.isEmpty()) { // stop management
AbstractWorkerThread task = gmwtHandles.pop();
task.stop();
}
}
save();
return true;
}

View File

@ -18,11 +18,15 @@
package hudson.plugins.gearman;
import java.util.Date;
import org.gearman.worker.DefaultGearmanFunctionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* This is a thread to manage gearman executors
* This is used to abort/delete jenkins jobs.
*/
public class ManagementWorkerThread extends AbstractWorkerThread {
private static final Logger logger = LoggerFactory
@ -37,8 +41,7 @@ public class ManagementWorkerThread extends AbstractWorkerThread {
@Override
public void registerJobs() {
logger.info("----- ManagementWorkerThread registerJobs function ----");
logger.info("----- Register management jobs here ----");
logger.info("----- Registering management jobs on " + name + " ----");
}