Skip to content

Commit

Permalink
Merge pull request #4 from emsa23/master
Browse files Browse the repository at this point in the history
Adding Different Queue Sorting Strategies and Strategies to assign Priorities to Jobs.
  • Loading branch information
emsa23 committed Nov 11, 2013
2 parents 325aa49 + 48296a8 commit 9394253
Show file tree
Hide file tree
Showing 50 changed files with 2,747 additions and 102 deletions.
160 changes: 74 additions & 86 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,94 +1,82 @@
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.343</version><!-- which version of Hudson is this plugin built against? -->
<relativePath>../pom.xml</relativePath>
</parent>
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.520</version>
</parent>
<artifactId>PrioritySorter</artifactId>
<version>2.0-SNAPSHOT</version>
<packaging>hpi</packaging>
<name>Jenkins Priority Sorter Plugin</name>
<description>This plugin allows for the build queue to be sorted based on pre-assigned priorities for each job.</description>
<url>https://wiki.jenkins-ci.org/display/JENKINS/Priority+Sorter+Plugin</url>

<groupId>hudson.queueSorter</groupId>
<artifactId>PrioritySorter</artifactId>
<version>1.4-SNAPSHOT</version>
<packaging>hpi</packaging>
<name>Priority Sorter</name>
<description>This plugin allows for the build queue to be sorted based on pre-assigned priorities for each job.</description>
<url>http://wiki.hudson-ci.org/display/HUDSON/Priority+Sorter+Plugin</url>
<licenses>
<license>
<name>MIT</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
<comments>
Copyright 2013- Magnus Sandberg. All rights reserved.
Copyright 2010- Brad Larson. All rights reserved.
</comments>
</license>
</licenses>

<licenses>
<license>
<name>MIT</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
<comments>Copyright 2010 Brad Larson. All rights reserved.</comments>
</license>
</licenses>
<developers>
<developer>
<id>emsa23</id>
<name>Magnus Sandberg</name>
<email>[email protected]</email>
<roles>
<role>developer</role>
<role>maintainer</role>
</roles>
<timezone>CET</timezone>
</developer>
<developer>
<id>bklarson</id>
<name>Brad Larson</name>
<email>[email protected]</email>
<roles>
<role>developer</role>
<role>retired maintainer</role>
</roles>
<timezone>-6</timezone>
</developer>
</developers>

<developers>
<developer>
<id>bklarson</id>
<name>Brad Larson</name>
<email>[email protected]</email>
<roles>
<role>developer</role>
<role>maintainer</role>
</roles>
<timezone>-6</timezone>
</developer>
</developers>
<build>
<plugins>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<version>1.96</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>

<!-- get every artifact through maven.glassfish.org, which proxies all the artifacts that we need -->
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
<configuration>
<goals>deploy</goals>
</configuration>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>org.jvnet.wagon-svn</groupId>
<artifactId>wagon-svn</artifactId>
<version>1.9</version>
</extension>
</extensions>
</build>

<scm>
<connection>scm:git:git://github.com/jenkinsci/priority-sorter-plugin.git</connection>
<developerConnection>scm:git:[email protected]:jenkinsci/priority-sorter-plugin.git</developerConnection>
<url>http://github.com/jenkinsci/priority-sorter-plugin</url>
</scm>

<distributionManagement>
<repository>
<id>java.net-m2-repository</id>
<url>http://maven.jenkins-ci.org:8081/content/repositories/releases/</url>
</repository>
</distributionManagement>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

<distributionManagement>
<repository>
<id>maven.jenkins-ci.org</id>
<url>http://maven.jenkins-ci.org:8081/content/repositories/releases/</url>
</repository>
</distributionManagement>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class PrioritySorterDefaults {

final static int defaultPriority = 100;

static int getDefault() {
static public int getDefault() {
return defaultPriority;
}
}
24 changes: 17 additions & 7 deletions src/main/java/hudson/queueSorter/PrioritySorterJobColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,38 @@

import hudson.Extension;
import hudson.model.Job;
import hudson.views.ListViewColumnDescriptor;
import hudson.views.ListViewColumn;
import jenkins.advancedqueue.ActualAdvancedQueueSorterJobProperty;
import jenkins.advancedqueue.PrioritySorterConfiguration;

import hudson.views.ListViewColumnDescriptor;
import org.kohsuke.stapler.DataBoundConstructor;

/**
* Priority column on the jobs overview page. The column displays priority set
* for the job and is an easy way to compare the priorities of many jobs.
*/
public class PrioritySorterJobColumn extends ListViewColumn {

@DataBoundConstructor
public PrioritySorterJobColumn() {
}

public String getPriority(final Job<?, ?> job) {
final PrioritySorterJobProperty jp =
job.getProperty(PrioritySorterJobProperty.class);
if (jp != null) {
return Integer.toString(jp.priority);
if(PrioritySorterConfiguration.get().getLegacyMode()) {
final PrioritySorterJobProperty jp = job.getProperty(PrioritySorterJobProperty.class);
if (jp != null) {
return Integer.toString(jp.priority);
} else {
// No priority has been set for this job - use the default
return Integer.toString(PrioritySorterDefaults.getDefault());
}
} else {
// No priority has been set for this job - use the default
return Integer.toString(PrioritySorterDefaults.getDefault());
final ActualAdvancedQueueSorterJobProperty jp = job.getProperty(ActualAdvancedQueueSorterJobProperty.class);
if(jp == null) {
return "Pending"; // You need to run a Job
}
return Integer.toString(jp.getPriority());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package hudson.queueSorter;

import jenkins.advancedqueue.PrioritySorterConfiguration;
import hudson.Extension;
import hudson.model.JobProperty;
import hudson.model.JobPropertyDescriptor;
Expand Down Expand Up @@ -59,5 +60,9 @@ public String getDisplayName() {
public int getDefault() {
return PrioritySorterDefaults.getDefault();
}

public boolean isUsed() {
return PrioritySorterConfiguration.get().getLegacyMode();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package hudson.queueSorter;

import hudson.Extension;
import hudson.model.AbstractProject;
import hudson.model.Queue.BuildableItem;
import hudson.model.queue.QueueSorter;
Expand All @@ -32,7 +31,6 @@
import java.util.Comparator;
import java.util.List;

@Extension
public class PrioritySorterQueueSorter extends QueueSorter {

private static final class BuildableComparitor implements
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* The MIT License
*
* Copyright (c) 2013, Magnus Sandberg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package jenkins.advancedqueue;

import hudson.Extension;
import hudson.model.JobProperty;
import hudson.model.JobPropertyDescriptor;
import hudson.model.AbstractProject;

import org.kohsuke.stapler.DataBoundConstructor;

/**
* @author Magnus Sandberg
* @since 2.0
*/
public class ActualAdvancedQueueSorterJobProperty extends
JobProperty<AbstractProject<?, ?>> {

private int priority;

@DataBoundConstructor
public ActualAdvancedQueueSorterJobProperty(int priority) {
this.priority = priority;
}

public int getPriority() {
return priority;
}

public void setPriority(int priority) {
this.priority = priority;
}

@Override
public DescriptorImpl getDescriptor() {
return (DescriptorImpl) super.getDescriptor();
}

@Extension
public static final class DescriptorImpl extends JobPropertyDescriptor {

@Override
public String getDisplayName() {
return Messages.ActualAdvancedQueueSorterJobProperty_displayName();
}

}
}
Loading

0 comments on commit 9394253

Please sign in to comment.