From f7edbbab3b80092a177844b0f102e5ef7ea30393 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Mon, 15 Mar 2010 19:05:07 +0000 Subject: [PATCH] Merged revisions 28543-28546,28548,28551,28625,28627-28629,28631,28635 via svnmerge from https://svn.dev.java.net/svn/hudson/branches/rc ........ r28543 | kohsuke | 2010-03-12 16:07:55 -0800 (Fri, 12 Mar 2010) | 1 line fixed a regression caused by HUDSON-5780 ........ r28544 | kohsuke | 2010-03-12 16:09:25 -0800 (Fri, 12 Mar 2010) | 1 line fixed a regression caused by HUDSON-5780 ........ r28545 | kohsuke | 2010-03-12 16:24:14 -0800 (Fri, 12 Mar 2010) | 1 line fixed a regression caused by HUDSON-5780 ........ r28546 | kohsuke | 2010-03-12 16:52:36 -0800 (Fri, 12 Mar 2010) | 1 line [maven-release-plugin] prepare release hudson-1_350 ........ r28548 | kohsuke | 2010-03-12 16:52:58 -0800 (Fri, 12 Mar 2010) | 1 line [maven-release-plugin] prepare for next development iteration ........ r28551 | kohsuke | 2010-03-12 17:36:02 -0800 (Fri, 12 Mar 2010) | 1 line updated changelog as a part of the release ........ r28625 | abayer | 2010-03-15 09:54:14 -0700 (Mon, 15 Mar 2010) | 1 line Fixing regression that resulted in all but latest build artifacts getting deleted ........ r28627 | kohsuke | 2010-03-15 10:09:52 -0700 (Mon, 15 Mar 2010) | 1 line touch up ........ r28628 | kohsuke | 2010-03-15 10:10:23 -0700 (Mon, 15 Mar 2010) | 1 line another pointless array conversion ........ r28629 | kohsuke | 2010-03-15 10:45:13 -0700 (Mon, 15 Mar 2010) | 1 line [maven-release-plugin] prepare release hudson-1_351 ........ r28631 | kohsuke | 2010-03-15 10:45:50 -0700 (Mon, 15 Mar 2010) | 1 line [maven-release-plugin] prepare for next development iteration ........ r28635 | kohsuke | 2010-03-15 11:29:03 -0700 (Mon, 15 Mar 2010) | 1 line updated changelog as a part of the release ........ git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@28639 71c3de6d-444a-0410-be80-ed276b4c234a --- cli/pom.xml | 2 +- core/pom.xml | 2 +- .../java/hudson/slaves/NodeProvisioner.java | 2 +- .../main/java/hudson/tasks/LogRotator.java | 66 +++++++++++-------- debian/changelog | 12 ++++ maven-agent/pom.xml | 2 +- maven-interceptor/pom.xml | 2 +- maven-plugin/pom.xml | 2 +- pom.xml | 2 +- remoting/pom.xml | 2 +- test/pom.xml | 2 +- .../hudson/slaves/NodeProvisionerTest.java | 5 ++ war/pom.xml | 2 +- 13 files changed, 66 insertions(+), 37 deletions(-) diff --git a/cli/pom.xml b/cli/pom.xml index 6968ae4ab7..6eb8617420 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -4,7 +4,7 @@ pom org.jvnet.hudson.main - 1.350-SNAPSHOT + 1.352-SNAPSHOT cli Hudson CLI diff --git a/core/pom.xml b/core/pom.xml index 88d3ab4ebd..e90168a6c3 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.350-SNAPSHOT + 1.352-SNAPSHOT ../pom.xml diff --git a/core/src/main/java/hudson/slaves/NodeProvisioner.java b/core/src/main/java/hudson/slaves/NodeProvisioner.java index 5872903bb8..21c19fcbf8 100644 --- a/core/src/main/java/hudson/slaves/NodeProvisioner.java +++ b/core/src/main/java/hudson/slaves/NodeProvisioner.java @@ -221,7 +221,7 @@ public class NodeProvisioner { } } - private static final float MARGIN = (float)(Integer.getInteger(NodeProvisioner.class.getName()+".MARGIN",10)/100); + private static final float MARGIN = Integer.getInteger(NodeProvisioner.class.getName()+".MARGIN",10)/100f; private static final Logger LOGGER = Logger.getLogger(NodeProvisioner.class.getName()); // TODO: picker should be selectable diff --git a/core/src/main/java/hudson/tasks/LogRotator.java b/core/src/main/java/hudson/tasks/LogRotator.java index 72c7264149..23b9796875 100644 --- a/core/src/main/java/hudson/tasks/LogRotator.java +++ b/core/src/main/java/hudson/tasks/LogRotator.java @@ -36,6 +36,8 @@ import java.util.Calendar; import java.util.GregorianCalendar; import static java.util.logging.Level.FINE; import static java.util.logging.Level.FINER; + +import java.util.List; import java.util.logging.Logger; /** @@ -59,19 +61,23 @@ public class LogRotator implements Describable { private final int numToKeep; /** - * If not -1, artifacts are only kept up to this days. + * If not -1 nor null, artifacts are only kept up to this days. + * Null handling is necessary to remain data compatible with old versions. + * @since 1.350 */ - private final int artifactDaysToKeep; + private final Integer artifactDaysToKeep; /** - * If not -1, only this number of builds have their artifacts kept. + * If not -1 nor null, only this number of builds have their artifacts kept. + * Null handling is necessary to remain data compatible with old versions. + * @since 1.350 */ - private final int artifactNumToKeep; + private final Integer artifactNumToKeep; @DataBoundConstructor public LogRotator (String logrotate_days, String logrotate_nums, String logrotate_artifact_days, String logrotate_artifact_nums) { this (parse(logrotate_days),parse(logrotate_nums), - parse(logrotate_artifact_days),parse(logrotate_artifact_nums)); + parse(logrotate_artifact_days),parse(logrotate_artifact_nums)); } public static int parse(String p) { @@ -84,7 +90,8 @@ public class LogRotator implements Describable { } /** - * @deprecated since 1.350 + * @deprecated since 1.350. + * Use {@link #LogRotator(int, int, int, int)} */ public LogRotator(int daysToKeep, int numToKeep) { this(daysToKeep, numToKeep, -1, -1); @@ -95,19 +102,19 @@ public class LogRotator implements Describable { this.numToKeep = numToKeep; this.artifactDaysToKeep = artifactDaysToKeep; this.artifactNumToKeep = artifactNumToKeep; + } public void perform(Job job) throws IOException, InterruptedException { LOGGER.log(FINE,"Running the log rotation for "+job.getFullDisplayName()); - + // keep the last successful build regardless of the status Run lsb = job.getLastSuccessfulBuild(); Run lstb = job.getLastStableBuild(); if(numToKeep!=-1) { - Run[] builds = job.getBuilds().toArray(new Run[0]); - for( int i=numToKeep; i> builds = job.getBuilds(); + for (Run r : builds.subList(Math.min(builds.size(),numToKeep),builds.size())) { if (r.isKeepLog()) { LOGGER.log(FINER,r.getFullDisplayName()+" is not GC-ed because it's marked as a keeper"); continue; @@ -128,7 +135,7 @@ public class LogRotator implements Describable { Calendar cal = new GregorianCalendar(); cal.add(Calendar.DAY_OF_YEAR,-daysToKeep); // copy it to the array because we'll be deleting builds as we go. - for( Run r : job.getBuilds().toArray(new Run[0]) ) { + for( Run r : job.getBuilds() ) { if (r.isKeepLog()) { LOGGER.log(FINER,r.getFullDisplayName()+" is not GC-ed because it's marked as a keeper"); continue; @@ -149,10 +156,9 @@ public class LogRotator implements Describable { } } - if(artifactNumToKeep!=-1) { - Run[] builds = job.getBuilds().toArray(new Run[0]); - for( int i=artifactNumToKeep; i> builds = job.getBuilds(); + for (Run r : builds.subList(Math.min(builds.size(),artifactNumToKeep),builds.size())) { if (r.isKeepLog()) { LOGGER.log(FINER,r.getFullDisplayName()+" is not purged of artifacts because it's marked as a keeper"); continue; @@ -169,11 +175,11 @@ public class LogRotator implements Describable { } } - if(artifactDaysToKeep!=-1) { + if(artifactDaysToKeep!=null && artifactDaysToKeep!=-1) { Calendar cal = new GregorianCalendar(); cal.add(Calendar.DAY_OF_YEAR,-artifactDaysToKeep); // copy it to the array because we'll be deleting builds as we go. - for( Run r : job.getBuilds().toArray(new Run[0]) ) { + for( Run r : job.getBuilds() ) { if (r.isKeepLog()) { LOGGER.log(FINER,r.getFullDisplayName()+" is not purged of artifacts because it's marked as a keeper"); continue; @@ -205,33 +211,39 @@ public class LogRotator implements Describable { } public int getArtifactDaysToKeep() { - return artifactDaysToKeep; + return unbox(artifactDaysToKeep); } public int getArtifactNumToKeep() { - return artifactNumToKeep; + return unbox(artifactNumToKeep); } public String getDaysToKeepStr() { - if(daysToKeep==-1) return ""; - else return String.valueOf(daysToKeep); + return toString(daysToKeep); } public String getNumToKeepStr() { - if(numToKeep==-1) return ""; - else return String.valueOf(numToKeep); + return toString(numToKeep); } public String getArtifactDaysToKeepStr() { - if(artifactDaysToKeep==-1) return ""; - else return String.valueOf(artifactDaysToKeep); + return toString(artifactDaysToKeep); } public String getArtifactNumToKeepStr() { - if(artifactNumToKeep==-1) return ""; - else return String.valueOf(artifactNumToKeep); + return toString(artifactNumToKeep); } + private int unbox(Integer i) { + return i==null ? -1: i; + } + + private String toString(Integer i) { + if (i==null || i==-1) return ""; + return String.valueOf(i); + } + + public LRDescriptor getDescriptor() { return DESCRIPTOR; } diff --git a/debian/changelog b/debian/changelog index 50e6e7641e..e906bc85dd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +hudson (1.351) unstable; urgency=low + + * See http://hudson.dev.java.net/changelog.html for more details. + + -- Kohsuke Kawaguchi Mon, 15 Mar 2010 11:26:57 -0700 + +hudson (1.350) unstable; urgency=low + + * See http://hudson.dev.java.net/changelog.html for more details. + + -- Kohsuke Kawaguchi Fri, 12 Mar 2010 17:34:12 -0800 + hudson (1.349) unstable; urgency=low * See http://hudson.dev.java.net/changelog.html for more details. diff --git a/maven-agent/pom.xml b/maven-agent/pom.xml index 7865082ff2..6f3cdd8f72 100644 --- a/maven-agent/pom.xml +++ b/maven-agent/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.350-SNAPSHOT + 1.352-SNAPSHOT ../pom.xml diff --git a/maven-interceptor/pom.xml b/maven-interceptor/pom.xml index 7672f7718a..e61cba942a 100644 --- a/maven-interceptor/pom.xml +++ b/maven-interceptor/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.350-SNAPSHOT + 1.352-SNAPSHOT ../pom.xml diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml index 59df526415..68562290f1 100644 --- a/maven-plugin/pom.xml +++ b/maven-plugin/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.350-SNAPSHOT + 1.352-SNAPSHOT maven-plugin diff --git a/pom.xml b/pom.xml index 8efd1e8f0f..8c3610d3e8 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.350-SNAPSHOT + 1.352-SNAPSHOT pom Hudson main module diff --git a/remoting/pom.xml b/remoting/pom.xml index 598bae1872..7eb516d406 100644 --- a/remoting/pom.xml +++ b/remoting/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.350-SNAPSHOT + 1.352-SNAPSHOT ../pom.xml diff --git a/test/pom.xml b/test/pom.xml index d932f2e7b2..a7f39842f1 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. pom org.jvnet.hudson.main - 1.350-SNAPSHOT + 1.352-SNAPSHOT 4.0.0 org.jvnet.hudson.main diff --git a/test/src/test/java/hudson/slaves/NodeProvisionerTest.java b/test/src/test/java/hudson/slaves/NodeProvisionerTest.java index dc4a080973..aff97acc4c 100644 --- a/test/src/test/java/hudson/slaves/NodeProvisionerTest.java +++ b/test/src/test/java/hudson/slaves/NodeProvisionerTest.java @@ -26,6 +26,7 @@ package hudson.slaves; import hudson.BulkChange; import hudson.Launcher; import hudson.model.*; +import hudson.slaves.NodeProvisioner.NodeProvisionerInvoker; import hudson.tasks.Builder; import org.jvnet.hudson.test.HudsonTestCase; import org.jvnet.hudson.test.SleepBuilder; @@ -48,6 +49,8 @@ public class NodeProvisionerTest extends HudsonTestCase { protected void setUp() throws Exception { original = LoadStatistics.CLOCK; LoadStatistics.CLOCK = 10; // run x1000 the regular speed to speed up the test + NodeProvisionerInvoker.INITIALDELAY = 100; + NodeProvisionerInvoker.RECURRENCEPERIOD = 10; super.setUp(); } @@ -55,6 +58,8 @@ public class NodeProvisionerTest extends HudsonTestCase { protected void tearDown() throws Exception { super.tearDown(); LoadStatistics.CLOCK = original; + NodeProvisionerInvoker.INITIALDELAY = original*10; + NodeProvisionerInvoker.RECURRENCEPERIOD = original; } /** diff --git a/war/pom.xml b/war/pom.xml index 446517d6ac..6a210961da 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -27,7 +27,7 @@ THE SOFTWARE. org.jvnet.hudson.main pom - 1.350-SNAPSHOT + 1.352-SNAPSHOT ../pom.xml