Skip to content

Commit

Permalink
[JENKINS-23538] Remove support for Legacy Sorter
Browse files Browse the repository at this point in the history
 * Removed the old Legacy Sorter
 * Removed various legacy-checks
 * Deprecated PrioritySorterJobProperty, kept enable conversion
 * Removed html-content for PrioritySorterJobProperty
 * Updated configuration page
  • Loading branch information
emsa23 committed Jun 23, 2014
1 parent e384e66 commit fc5e841
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 133 deletions.
18 changes: 4 additions & 14 deletions src/main/java/hudson/queueSorter/PrioritySorterJobColumn.java
Expand Up @@ -42,21 +42,11 @@ public PrioritySorterJobColumn() {
}

public String getPriority(final Job<?, ?> job) {
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 {
ItemInfo itemInfo = QueueItemCache.get().getItem(job.getName());
if(itemInfo == null) {
return "Pending"; // You need to run a Job
}
return Integer.toString(itemInfo.getPriority());
ItemInfo itemInfo = QueueItemCache.get().getItem(job.getName());
if(itemInfo == null) {
return "Pending"; // You need to run a Job
}
return Integer.toString(itemInfo.getPriority());
}

@Extension
Expand Down
Expand Up @@ -23,14 +23,14 @@
*/
package hudson.queueSorter;

import jenkins.advancedqueue.PrioritySorterConfiguration;
import hudson.Extension;
import hudson.model.AbstractProject;
import hudson.model.JobProperty;
import hudson.model.JobPropertyDescriptor;
import hudson.model.AbstractProject;

import org.kohsuke.stapler.DataBoundConstructor;

@Deprecated
public class PrioritySorterJobProperty extends
JobProperty<AbstractProject<?, ?>> {

Expand Down Expand Up @@ -62,7 +62,7 @@ public int getDefault() {
}

public boolean isUsed() {
return PrioritySorterConfiguration.get().getLegacyMode();
return false;
}
}
}
72 changes: 0 additions & 72 deletions src/main/java/hudson/queueSorter/PrioritySorterQueueSorter.java

This file was deleted.

Expand Up @@ -91,7 +91,7 @@ public ListBoxModel getPriorities() {

public boolean isUsed() {
PrioritySorterConfiguration configuration = PrioritySorterConfiguration.get();
return !configuration.getLegacyMode() && configuration.getAllowPriorityOnJobs();
return configuration.getAllowPriorityOnJobs();
}
}
}
Expand Up @@ -124,9 +124,6 @@ public String getUrlName() {

private boolean checkActive() {
PrioritySorterConfiguration configuration = PrioritySorterConfiguration.get();
if (configuration.getLegacyMode()) {
return false;
}
if (configuration.getOnlyAdminsMayEditPriorityConfiguration()) {
return Jenkins.getInstance().getACL().hasPermission(Jenkins.ADMINISTER);
}
Expand Down
Expand Up @@ -111,7 +111,7 @@ public boolean configure(StaplerRequest req, JSONObject json) throws FormExcepti
return true;
}

public final boolean getLegacyMode() {
private final boolean getLegacyMode() {
return legacyMode;
}

Expand Down
10 changes: 4 additions & 6 deletions src/main/java/jenkins/advancedqueue/PrioritySorterPlugin.java
Expand Up @@ -45,14 +45,12 @@ public class PrioritySorterPlugin extends Plugin {

@Initializer(after = JOB_LOADED)
public static void init() {
// Check for Legacy Mode and init the Configuration
// Check for any Legacy Configuration and init the Configuration
LOGGER.info("Configuring the Priority Sorter ...");
PrioritySorterConfiguration.init();
// If Legacy Mode - init the Queue and sort the loaded Queue items
if (!PrioritySorterConfiguration.get().getLegacyMode()) {
LOGGER.info("Sorting existing Queue ...");
AdvancedQueueSorter.init();
}
// Init the Queue and sort the loaded Queue items
LOGGER.info("Sorting existing Queue ...");
AdvancedQueueSorter.init();
}

}
Expand Up @@ -29,7 +29,6 @@
import hudson.model.Queue.Item;
import hudson.model.Queue.LeftItem;
import hudson.model.queue.QueueSorter;
import hudson.queueSorter.PrioritySorterQueueSorter;

import java.util.Collections;
import java.util.Comparator;
Expand Down Expand Up @@ -73,11 +72,7 @@ public int compare(BuildableItem o1, BuildableItem o2) {

@Override
public void sortBuildableItems(List<BuildableItem> items) {
// Handle Legacy mode
if (PrioritySorterConfiguration.get().getLegacyMode()) {
new PrioritySorterQueueSorter().sortBuildableItems(items);
}
// Sort

Collections.sort(items, new Comparator<BuildableItem>() {
public int compare(BuildableItem o1, BuildableItem o2) {
float o1weight = getCalculatedWeight(o1);
Expand Down
@@ -1,18 +1,3 @@
<j:jelly
xmlns:j="jelly:core"
xmlns:st="jelly:stapler"
xmlns:d="jelly:define"
xmlns:l="/lib/layout"
xmlns:t="/lib/hudson"
xmlns:f="/lib/form">

<j:if test="${descriptor.isUsed()}">
<f:entry title="Job Priority" field="priority">
<f:textbox name="prioritySorter.priority" value="${instance.priority}"
clazz="required number"
default="${descriptor.getDefault()}"
/>
</f:entry>
</j:if>
<j:jelly xmlns:j="jelly:core">

</j:jelly>

This file was deleted.

@@ -1,15 +1,9 @@
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form" xmlns:st="jelly:stapler">
<f:section title="Priority Sorter">
<j:if test="${instance.legacyMode}">
<h3>Priority Sorter found Legacy configuration data, please update the configuration to continue using the Priority Sorter</h3>
<f:optionalBlock title="${%Switch to Advanced Priority Sorter Mode}"
checked="false" inline="true" name="advanced">
<f:description>
<h3>Priority Sorter is currently in Legacy Mode. After switching to Advanced Mode
<li>you cannot switch back to Legacy Mode.</li>
<li>the legacy priority property on Jobs is no longer used.</li>
<li>the Configuration Slicing Plugin cannot be used to configure priorities.</li>
</h3>
</f:description>
<f:dropdownDescriptorSelector field="strategy" title="${%Strategy}"/>
<f:entry title="Allow priorities directly on Jobs" description="Check if you still want to have the ability to set priority directly on Jobs" field="allowPriorityOnJobs">
<f:checkbox id="ps_allowPriorityOnJobs" name="allowPriorityOnJobs" checked="${allowPriorityOnJobs}"/>
Expand Down

0 comments on commit fc5e841

Please sign in to comment.