diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..cca619f --- /dev/null +++ b/README.rst @@ -0,0 +1,47 @@ +--------------------------------------------------------------------- +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. +--------------------------------------------------------------------- + +Installation +============ + +The plugin can be installed like any other Jenkins plugin. Please refer to the Jenkins documentation on installing plugins. + +Configuration +============= + +Configuration of the plugin can be done on the Jenkins configure page (i.e. http://localhost:8080/configure). Click on the help if needed. + +Developers +========== +Project site: + + * https://wiki.jenkins-ci.org/display/JENKINS/Gearman+Plugin + +Bug report: + + * https://bugs.launchpad.net/~gearman-plugin-core + +Cloning: + + * https://github.com/openstack-infra/gearman-plugin.git + +Patches are submitted via Gerrit at: + + * https://review.openstack.org/ + +More details on how you can contribute is available on our wiki at: + + * http://wiki.openstack.org/HowToContribute diff --git a/README.txt b/README.txt deleted file mode 100644 index f023371..0000000 --- a/README.txt +++ /dev/null @@ -1,61 +0,0 @@ ---------------------------------------------------------------------- -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. ---------------------------------------------------------------------- - -Jenkins does not support multiple masters. You can setup multiple Jenkins -masters but there is no coordination between them. - -One problem with scheduling builds on Jenkins master (“MasterA”) server -is that MasterA only knows about its connected slaves. If all slaves on -MasterA are busy then MasterA will just put the next scheduled build on -its queue. Now MasterA needs to wait for an available slave to run -the build. This will be very in-efficient if your builds take a long -time to run. So..what if there is another Jenkins master (“MasterB”) -that has free slaves to service the next scheduled build? Your probably -saying “Then slaves on MasterB should run the build”. However MasterB -will never service the builds on MasterA's queue. The client that schedules -the builds must know about MasterB and then schedule builds on MasterB. -This is what we mean by lack of coordination between masters. -The gearman-plugin attempts to fill this gap. - -This plugin integrates Gearman with Jenkins and will make it so that -any Jenkins slave on any Jenkins master can service a job in the queue. -It will essentially replace the Jenkins build queue with the Gearman -job queue. The job should stay in the gearman queue until there is a -Jenkins node that can run that job. - - -This is the typical workflow: - -1) On a 'Launch Workers', we spawn a Gearman worker for each Jenkins -executor. We'll call these "executor worker threads". - -Each executor worker thread is associated 1:1 with a Jenkins node (slave or master) - -2) Now we register jobs for each Gearman executor depending on -projects and nodes. View the image to see the mapping. - -3) On a 'Launch Workers', we spawn one more thread to be a Gearman -worker to handle job management for this Jenkins master. We'll call -it the "management worker thread" and register the following function: - - stop:$hostname - -4) Any Gearman client can connect to the Gearman server and send a -request to build a Jenkins project or cancel a project. View the -examples to see how this can be done. - -5) The Gearman workers will service any client request that come -through to start/cancel a Jenkins build. diff --git a/pom.xml b/pom.xml index c86a1f8..2ecf173 100644 --- a/pom.xml +++ b/pom.xml @@ -135,8 +135,6 @@ 2.4 1.2 1.0-beta-3 - 1.7.2 - 1.0.9 2.2.2 0.6-SNAPSHOT @@ -333,26 +331,6 @@ - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - slf4j-simple - ${slf4j.version} - - - ch.qos.logback - logback-classic - ${logback.version} - - - ch.qos.logback - logback-core - ${logback.version} - org.gearman gearman-java diff --git a/src/main/java/hudson/plugins/gearman/AbstractWorkerThread.java b/src/main/java/hudson/plugins/gearman/AbstractWorkerThread.java index e6dd2cd..f87887d 100644 --- a/src/main/java/hudson/plugins/gearman/AbstractWorkerThread.java +++ b/src/main/java/hudson/plugins/gearman/AbstractWorkerThread.java @@ -101,7 +101,7 @@ public abstract class AbstractWorkerThread implements Runnable { */ public void registerJobs() { - logger.info("----- AbstractorWorker registerJobs function ----"); + logger.info("---- AbstractorWorker registerJobs function ----"); } @@ -122,10 +122,10 @@ public abstract class AbstractWorkerThread implements Runnable { if (worker.isRunning()) { try { - logger.info("Stopping " + getName() + ":" + getId().toString() + + logger.info("---- Stopping " + getName() + ":" + getId().toString() + " (" + new Date().toString() + ")"); worker.unregisterAll(); - worker.stop(); + worker.shutdown(); } catch (Exception e) { e.printStackTrace(); } @@ -154,7 +154,7 @@ public abstract class AbstractWorkerThread implements Runnable { public void run() { if (!worker.isRunning()) { - logger.info("Starting Worker "+ getName() + ":" + getId().toString() + + logger.info("---- Starting Worker "+ getName() + ":" + getId().toString() + " ("+new Date().toString()+")"); worker.setWorkerID(name); worker.setJobUniqueIdRequired(true); diff --git a/src/main/java/hudson/plugins/gearman/ExecutorWorkerThread.java b/src/main/java/hudson/plugins/gearman/ExecutorWorkerThread.java index 5ccb4d9..cfe0864 100644 --- a/src/main/java/hudson/plugins/gearman/ExecutorWorkerThread.java +++ b/src/main/java/hudson/plugins/gearman/ExecutorWorkerThread.java @@ -135,7 +135,7 @@ public class ExecutorWorkerThread extends AbstractWorkerThread{ @Override public void registerJobs() { - logger.info("----- Registering executor jobs on " + name + " ----"); + logger.info("---- Registering executor jobs on " + name + " ----"); /* * We start with an empty worker. @@ -161,7 +161,7 @@ public class ExecutorWorkerThread extends AbstractWorkerThread{ if (label == null) { // project has no label -> so register // "build:projectName" on all nodes String jobFunctionName = "build:" + projectName; - logger.info("Registering job " + jobFunctionName + " on " + logger.info("---- Registering job " + jobFunctionName + " on " + name); worker.registerFunctionFactory(new CustomGearmanFunctionFactory( jobFunctionName, StartJobWorker.class.getName(), @@ -180,7 +180,7 @@ public class ExecutorWorkerThread extends AbstractWorkerThread{ if (projectLabelNodes.contains(this.node)) { String jobFunctionName = "build:" + projectName + ":" + projectLabel; - logger.info("Registering job " + jobFunctionName + logger.info("---- Registering job " + jobFunctionName + " on " + this.node.getNodeName()); // register with label (i.e. "build:$projectName:$projectLabel") worker.registerFunctionFactory(new CustomGearmanFunctionFactory( diff --git a/src/main/java/hudson/plugins/gearman/GearmanPluginConfig.java b/src/main/java/hudson/plugins/gearman/GearmanPluginConfig.java index 05b1b0d..0a0756f 100644 --- a/src/main/java/hudson/plugins/gearman/GearmanPluginConfig.java +++ b/src/main/java/hudson/plugins/gearman/GearmanPluginConfig.java @@ -53,7 +53,7 @@ public class GearmanPluginConfig extends GlobalConfiguration { * Constructor. */ public GearmanPluginConfig() { - logger.info("--- GearmanPluginConfig Constructor ---"); + logger.info("---- GearmanPluginConfig Constructor ---"); gearmanProxy = new GearmanProxy(); load(); @@ -96,7 +96,7 @@ public class GearmanPluginConfig extends GlobalConfiguration { if (launchWorker) { // check for a valid connection to gearman server - logger.info("--- Check connection to Gearman Server " + host + ":" + logger.info("---- Check connection to Gearman Server " + host + ":" + port); if (!GearmanPluginUtil.connectionIsAvailable(host, port, 5000)) { launchWorker = false; diff --git a/src/main/java/hudson/plugins/gearman/GearmanPluginUtil.java b/src/main/java/hudson/plugins/gearman/GearmanPluginUtil.java index c3cfd98..7168d4a 100644 --- a/src/main/java/hudson/plugins/gearman/GearmanPluginUtil.java +++ b/src/main/java/hudson/plugins/gearman/GearmanPluginUtil.java @@ -61,10 +61,10 @@ public class GearmanPluginUtil { } else { try { socket.connect(endPoint, timeout); - logger.info("Connection Success: " + endPoint); + logger.info("---- Connection Success: " + endPoint); return true; } catch (Exception e) { - logger.info("Connection Failure: " + endPoint + " message: " + logger.info("---- Connection Failure: " + endPoint + " message: " + e.getClass().getSimpleName() + " - " + e.getMessage()); } finally { if (socket != null) { diff --git a/src/main/java/hudson/plugins/gearman/GearmanProxy.java b/src/main/java/hudson/plugins/gearman/GearmanProxy.java index a4bdf91..572e81f 100644 --- a/src/main/java/hudson/plugins/gearman/GearmanProxy.java +++ b/src/main/java/hudson/plugins/gearman/GearmanProxy.java @@ -50,7 +50,7 @@ public class GearmanProxy { // constructor public GearmanProxy() { - logger.info("--- GearmanProxy Constructor ---"); + logger.info("---- GearmanProxy Constructor ---"); gewtHandles = new ArrayList(); gmwtHandles = new ArrayList(); @@ -94,9 +94,9 @@ public class GearmanProxy { try { masterNode = Computer.currentComputer().getNode(); } catch (NullPointerException npe) { - logger.info("--- Master is offline"); + logger.info("---- Master is offline"); } catch (Exception e) { - logger.info("--- Can't get Master"); + logger.info("---- Can't get Master"); e.printStackTrace(); } @@ -140,7 +140,7 @@ public class GearmanProxy { } } - logger.info("--- Num of executors running = " + getNumExecutors()); + logger.info("---- Num of executors running = " + getNumExecutors()); } @@ -160,7 +160,7 @@ public class GearmanProxy { gmwtHandles.clear(); numWorkerNodes = 0; - logger.info("--- Num of executors running = " + getNumExecutors()); + logger.info("---- Num of executors running = " + getNumExecutors()); } /* diff --git a/src/main/java/hudson/plugins/gearman/StartJobWorker.java b/src/main/java/hudson/plugins/gearman/StartJobWorker.java index fc2568e..d4a0639 100644 --- a/src/main/java/hudson/plugins/gearman/StartJobWorker.java +++ b/src/main/java/hudson/plugins/gearman/StartJobWorker.java @@ -75,7 +75,7 @@ public class StartJobWorker extends AbstractGearmanFunction { */ @Override public GearmanJobResult executeFunction() { - logger.info("----- Running executeFunction in " + name + " ----"); + logger.info("---- Running executeFunction in " + name + " ----"); // decode the uniqueId from the client String decodedUniqueId = null; @@ -125,7 +125,7 @@ public class StartJobWorker extends AbstractGearmanFunction { Action [] actions = {runNode, params}; // schedule jenkins to build project - logger.info("Scheduling "+project.getName()+" build #" + + logger.info("---- Scheduling "+project.getName()+" build #" + project.getNextBuildNumber()+" on " + runNodeName + " with UUID " + decodedUniqueId + " and build params " + buildParams); Future future = project.scheduleBuild2(0, new Cause.UserIdCause(), actions); diff --git a/src/main/java/hudson/plugins/gearman/StopJobWorker.java b/src/main/java/hudson/plugins/gearman/StopJobWorker.java index ad10047..ccfbbb2 100644 --- a/src/main/java/hudson/plugins/gearman/StopJobWorker.java +++ b/src/main/java/hudson/plugins/gearman/StopJobWorker.java @@ -71,7 +71,7 @@ public class StopJobWorker extends AbstractGearmanFunction { String jobResultMsg = ""; if (decodedUniqueId.isEmpty() || decodedUniqueId == null){ - logger.info("Client passed in an invalid UUID"); + logger.info("---- Client passed in an invalid UUID"); jobFailureMsg = "I need the job Id please"; jobResult = false; } else { @@ -131,7 +131,7 @@ public class StopJobWorker extends AbstractGearmanFunction { if (param.getUuid().equals(uuid)) { - logger.info("Aborting build : "+buildNum+": "+buildId+" on " + runNodeName + logger.info("---- Aborting build : "+buildNum+": "+buildId+" on " + runNodeName +" with UUID " + uuid + " and build params " + buildParams); // abort the running jenkins build @@ -174,7 +174,7 @@ public class StopJobWorker extends AbstractGearmanFunction { if (param.getUuid().equals(uuid)) { - logger.info("Aborting build : "+buildNum+": "+buildId+" on " + runNodeName + logger.info("---- Aborting build : "+buildNum+": "+buildId+" on " + runNodeName +" with UUID " + uuid + " and build params " + buildParams); // abort the running jenkins build diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml deleted file mode 100644 index 9b7a394..0000000 --- a/src/main/resources/logback.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - GearmanPlugin.log - true - - %d [%thread] %-5level %logger{35} - %msg%n - - - - - %d [%thread] %-5level %logger{35} - %msg%n - - - - - - - \ No newline at end of file