summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Lynggaard Hansen2012-07-10 15:18:41 (EDT)
committer Henrik Lynggaard Hansen2012-07-10 15:18:41 (EDT)
commit086424616eb3b238fd7f980ab1591e88fc185169 (patch)
tree945c97e82988cb5e4676c66ea5ad48212628fd37
parent6b2a021db07f935226235132973fb64223c07d91 (diff)
downloadorg.eclipse.hudson.core-086424616eb3b238fd7f980ab1591e88fc185169.zip
org.eclipse.hudson.core-086424616eb3b238fd7f980ab1591e88fc185169.tar.gz
org.eclipse.hudson.core-086424616eb3b238fd7f980ab1591e88fc185169.tar.bz2
Reformat of diagnosis and fsp package.refs/changes/96/6696/1
Change-Id: I04387473d384e829ae2924671cc9de52a1721f0a Signed-off-by: Henrik Lynggaard Hansen <henrik@hlyh.dk>
-rw-r--r--hudson-core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageChecker.java22
-rw-r--r--hudson-core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageMonitor.java40
-rw-r--r--hudson-core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java29
-rw-r--r--hudson-core/src/main/java/hudson/diagnosis/OldDataMonitor.java131
-rw-r--r--hudson-core/src/main/java/hudson/diagnosis/ReverseProxySetupMonitor.java29
-rw-r--r--hudson-core/src/main/java/hudson/diagnosis/TooManyJobsButNoView.java26
-rw-r--r--hudson-core/src/main/java/hudson/fsp/WorkspaceSnapshotSCM.java66
7 files changed, 198 insertions, 145 deletions
diff --git a/hudson-core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageChecker.java b/hudson-core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageChecker.java
index 13cf481..5d7fc8b 100644
--- a/hudson-core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageChecker.java
+++ b/hudson-core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageChecker.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -23,13 +23,14 @@ import hudson.model.PeriodicWork;
import java.util.logging.Logger;
/**
- * Periodically checks the disk usage of <tt>HUDSON_HOME</tt>,
- * and activate {@link HudsonHomeDiskUsageMonitor} if necessary.
+ * Periodically checks the disk usage of <tt>HUDSON_HOME</tt>, and activate
+ * {@link HudsonHomeDiskUsageMonitor} if necessary.
*
* @author Kohsuke Kawaguchi
*/
@Extension
public class HudsonHomeDiskUsageChecker extends PeriodicWork {
+
public long getRecurrencePeriod() {
return HOUR;
}
@@ -38,34 +39,31 @@ public class HudsonHomeDiskUsageChecker extends PeriodicWork {
try {
long free = Hudson.getInstance().getRootDir().getUsableSpace();
long total = Hudson.getInstance().getRootDir().getTotalSpace();
- if(free<=0 || total<=0) {
+ if (free <= 0 || total <= 0) {
// information unavailable. pointless to try.
LOGGER.info("HUDSON_HOME disk usage information isn't available. aborting to monitor");
cancel();
return;
}
- LOGGER.fine("Monitoring disk usage of HUDSON_HOME. total="+total+" free="+free);
+ LOGGER.fine("Monitoring disk usage of HUDSON_HOME. total=" + total + " free=" + free);
// if it's more than 90% full and less than the minimum, activate
// it's AND and not OR so that small Hudson home won't get a warning,
// and similarly, if you have a 1TB disk, you don't get a warning when you still have 100GB to go.
- HudsonHomeDiskUsageMonitor.get().activated = (total/free>10 && free< FREE_SPACE_THRESHOLD);
+ HudsonHomeDiskUsageMonitor.get().activated = (total / free > 10 && free < FREE_SPACE_THRESHOLD);
} catch (LinkageError _) {
// pre Mustang
LOGGER.info("Not on JDK6. Cannot monitor HUDSON_HOME disk usage");
cancel();
}
}
-
private static final Logger LOGGER = Logger.getLogger(HudsonHomeDiskUsageChecker.class.getName());
-
/**
* Gets the minimum amount of space to check for, with a default of 1GB
*/
public static long FREE_SPACE_THRESHOLD = Long.getLong(
HudsonHomeDiskUsageChecker.class.getName() + ".freeSpaceThreshold",
- 1024L*1024*1024);
-
+ 1024L * 1024 * 1024);
}
diff --git a/hudson-core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageMonitor.java b/hudson-core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageMonitor.java
index 9cc2c49..2093005 100644
--- a/hudson-core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageMonitor.java
+++ b/hudson-core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageMonitor.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -30,12 +30,14 @@ import java.io.IOException;
import java.util.List;
/**
- * Monitors the disk usage of <tt>HUDSON_HOME</tt>, and if it's almost filled up, warn the user.
+ * Monitors the disk usage of <tt>HUDSON_HOME</tt>, and if it's almost filled
+ * up, warn the user.
*
* @author Kohsuke Kawaguchi
*/
@Extension
public final class HudsonHomeDiskUsageMonitor extends AdministrativeMonitor {
+
/**
* Value updated by {@link HudsonHomeDiskUsageChecker}.
*/
@@ -50,10 +52,11 @@ public final class HudsonHomeDiskUsageMonitor extends AdministrativeMonitor {
}
/**
- * Depending on whether the user said "yes" or "no", send him to the right place.
+ * Depending on whether the user said "yes" or "no", send him to the right
+ * place.
*/
public HttpResponse doAct(@QueryParameter String no) throws IOException {
- if(no!=null) {
+ if (no != null) {
disable(true);
return HttpResponses.redirectViaContextPath("/manage");
} else {
@@ -69,9 +72,11 @@ public final class HudsonHomeDiskUsageMonitor extends AdministrativeMonitor {
* Binds a solution to the URL.
*/
public Solution getSolution(String id) {
- for( Solution s : Solution.all() )
- if(s.id.equals(id))
+ for (Solution s : Solution.all()) {
+ if (s.id.equals(id)) {
return s;
+ }
+ }
return null;
}
@@ -85,20 +90,17 @@ public final class HudsonHomeDiskUsageMonitor extends AdministrativeMonitor {
/**
* Extension point for suggesting solutions for full HUDSON_HOME.
*
- * <h3>Views</h3>
- * <dl>
- * <dt>message.jelly</dt>
- * <dd>
- * This view is rendered inside an LI tag as a possible solution to the full HUDSON_HOME problem.
- * </dd>
- * </dl>
+ * <h3>Views</h3> <dl> <dt>message.jelly</dt> <dd> This view is rendered
+ * inside an LI tag as a possible solution to the full HUDSON_HOME problem.
+ * </dd> </dl>
*/
public static abstract class Solution extends AbstractModelObject implements ExtensionPoint {
+
/**
- * Human-readable ID of this monitor, which needs to be unique within the system.
+ * Human-readable ID of this monitor, which needs to be unique within
+ * the system.
*
- * <p>
- * This ID is used to remember persisted setting for this monitor,
+ * <p> This ID is used to remember persisted setting for this monitor,
* so the ID should remain consistent beyond the Hudson JVM lifespan.
*/
public final String id;
@@ -115,7 +117,7 @@ public final class HudsonHomeDiskUsageMonitor extends AdministrativeMonitor {
* Returns the URL of this monitor, relative to the context path.
*/
public String getUrl() {
- return HudsonHomeDiskUsageMonitor.get().getUrl()+"/solution/"+id;
+ return HudsonHomeDiskUsageMonitor.get().getUrl() + "/solution/" + id;
}
/**
diff --git a/hudson-core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java b/hudson-core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java
index 7599ee1..25844ae 100644
--- a/hudson-core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java
+++ b/hudson-core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi, Winston Prakash
- *
+ *
*******************************************************************************/
package hudson.diagnosis;
@@ -40,26 +40,28 @@ import org.kohsuke.stapler.QueryParameter;
*/
@Extension
public final class MemoryUsageMonitor extends PeriodicWork {
+
/**
- * A memory group is conceptually a set of memory pools.
+ * A memory group is conceptually a set of memory pools.
*/
public final class MemoryGroup {
- private final List<MemoryPoolMXBean> pools = new ArrayList<MemoryPoolMXBean>();
+ private final List<MemoryPoolMXBean> pools = new ArrayList<MemoryPoolMXBean>();
/**
- * Trend of the memory usage, after GCs.
- * So this shows the accurate snapshot of the footprint of live objects.
+ * Trend of the memory usage, after GCs. So this shows the accurate
+ * snapshot of the footprint of live objects.
*/
- public final MultiStageTimeSeries used = new MultiStageTimeSeries(Messages._MemoryUsageMonitor_USED(), ColorPalette.RED, 0,0);
+ public final MultiStageTimeSeries used = new MultiStageTimeSeries(Messages._MemoryUsageMonitor_USED(), ColorPalette.RED, 0, 0);
/**
* Trend of the maximum memory size, after GCs.
*/
- public final MultiStageTimeSeries max = new MultiStageTimeSeries(Messages._MemoryUsageMonitor_TOTAL(), ColorPalette.BLUE, 0,0);
+ public final MultiStageTimeSeries max = new MultiStageTimeSeries(Messages._MemoryUsageMonitor_TOTAL(), ColorPalette.BLUE, 0, 0);
private MemoryGroup(List<MemoryPoolMXBean> pools, MemoryType type) {
for (MemoryPoolMXBean pool : pools) {
- if (pool.getType() == type)
+ if (pool.getType() == type) {
this.pools.add(pool);
+ }
}
}
@@ -69,9 +71,11 @@ public final class MemoryUsageMonitor extends PeriodicWork {
// long cur = 0;
for (MemoryPoolMXBean pool : pools) {
MemoryUsage usage = pool.getCollectionUsage();
- if(usage==null) continue; // not available
+ if (usage == null) {
+ continue; // not available
+ }
used += usage.getUsed();
- max += usage.getMax();
+ max += usage.getMax();
// usage = pool.getUsage();
// if(usage==null) continue; // not available
@@ -93,10 +97,9 @@ public final class MemoryUsageMonitor extends PeriodicWork {
* Generates the memory usage statistics graph.
*/
public TrendChart doGraph(@QueryParameter String type) throws IOException {
- return MultiStageTimeSeries.createTrendChart(TimeScale.parse(type),used,max);
+ return MultiStageTimeSeries.createTrendChart(TimeScale.parse(type), used, max);
}
}
-
public final MemoryGroup heap;
public final MemoryGroup nonHeap;
diff --git a/hudson-core/src/main/java/hudson/diagnosis/OldDataMonitor.java b/hudson-core/src/main/java/hudson/diagnosis/OldDataMonitor.java
index f0516f0..a66d59d 100644
--- a/hudson-core/src/main/java/hudson/diagnosis/OldDataMonitor.java
+++ b/hudson-core/src/main/java/hudson/diagnosis/OldDataMonitor.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Alan Harder
- *
+ *
*
*******************************************************************************/
@@ -54,9 +54,9 @@ import org.kohsuke.stapler.HttpResponses;
*/
@Extension
public class OldDataMonitor extends AdministrativeMonitor {
- private static Logger LOGGER = Logger.getLogger(OldDataMonitor.class.getName());
- private HashMap<Saveable,VersionRange> data = new HashMap<Saveable,VersionRange>();
+ private static Logger LOGGER = Logger.getLogger(OldDataMonitor.class.getName());
+ private HashMap<Saveable, VersionRange> data = new HashMap<Saveable, VersionRange>();
private boolean updating = false;
public OldDataMonitor() {
@@ -72,23 +72,25 @@ public class OldDataMonitor extends AdministrativeMonitor {
return !data.isEmpty();
}
- public synchronized Map<Saveable,VersionRange> getData() {
+ public synchronized Map<Saveable, VersionRange> getData() {
return Collections.unmodifiableMap(data);
}
private static void remove(Saveable obj, boolean isDelete) {
- OldDataMonitor odm = (OldDataMonitor)Hudson.getInstance().getAdministrativeMonitor("OldData");
+ OldDataMonitor odm = (OldDataMonitor) Hudson.getInstance().getAdministrativeMonitor("OldData");
synchronized (odm) {
- if (odm.updating) return; // Skip during doUpgrade or doDiscard
+ if (odm.updating) {
+ return; // Skip during doUpgrade or doDiscard
+ }
odm.data.remove(obj);
- if (isDelete && obj instanceof Job<?,?>)
- for (Run r : ((Job<?,?>)obj).getBuilds())
+ if (isDelete && obj instanceof Job<?, ?>) {
+ for (Run r : ((Job<?, ?>) obj).getBuilds()) {
odm.data.remove(r);
+ }
+ }
}
}
-
// Listeners to remove data here if resaved or deleted in regular Hudson usage
-
@Extension
public static final SaveableListener changeListener = new SaveableListener() {
@Override
@@ -96,7 +98,6 @@ public class OldDataMonitor extends AdministrativeMonitor {
remove(obj, false);
}
};
-
@Extension
public static final ItemListener itemDeleteListener = new ItemListener() {
@Override
@@ -104,7 +105,6 @@ public class OldDataMonitor extends AdministrativeMonitor {
remove(item, true);
}
};
-
@Extension
public static final RunListener<Run> runDeleteListener = new RunListener<Run>() {
@Override
@@ -114,19 +114,23 @@ public class OldDataMonitor extends AdministrativeMonitor {
};
/**
- * Inform monitor that some data in a deprecated format has been loaded,
- * and converted in-memory to a new structure.
+ * Inform monitor that some data in a deprecated format has been loaded, and
+ * converted in-memory to a new structure.
+ *
* @param obj Saveable object; calling save() on this object will persist
- * the data in its new format to disk.
+ * the data in its new format to disk.
* @param version Hudson release when the data structure changed.
*/
public static void report(Saveable obj, String version) {
- OldDataMonitor odm = (OldDataMonitor)Hudson.getInstance().getAdministrativeMonitor("OldData");
+ OldDataMonitor odm = (OldDataMonitor) Hudson.getInstance().getAdministrativeMonitor("OldData");
synchronized (odm) {
try {
VersionRange vr = odm.data.get(obj);
- if (vr != null) vr.add(version);
- else odm.data.put(obj, new VersionRange(version, null));
+ if (vr != null) {
+ vr.add(version);
+ } else {
+ odm.data.put(obj, new VersionRange(version, null));
+ }
} catch (IllegalArgumentException ex) {
LOGGER.log(Level.WARNING, "Bad parameter given to OldDataMonitor", ex);
}
@@ -134,8 +138,10 @@ public class OldDataMonitor extends AdministrativeMonitor {
}
/**
- * Inform monitor that some data in a deprecated format has been loaded, during
- * XStream unmarshalling when the Saveable containing this object is not available.
+ * Inform monitor that some data in a deprecated format has been loaded,
+ * during XStream unmarshalling when the Saveable containing this object is
+ * not available.
+ *
* @param context XStream unmarshalling context
* @param version Hudson release when the data structure changed.
*/
@@ -144,7 +150,9 @@ public class OldDataMonitor extends AdministrativeMonitor {
}
private static class ReportException extends Exception {
+
private String version;
+
private ReportException(String version) {
this.version = version;
}
@@ -152,32 +160,42 @@ public class OldDataMonitor extends AdministrativeMonitor {
/**
* Inform monitor that some unreadable data was found while loading.
- * @param obj Saveable object; calling save() on this object will discard the unreadable data.
- * @param errors Exception(s) thrown while loading, regarding the unreadable classes/fields.
+ *
+ * @param obj Saveable object; calling save() on this object will discard
+ * the unreadable data.
+ * @param errors Exception(s) thrown while loading, regarding the unreadable
+ * classes/fields.
*/
public static void report(Saveable obj, Collection<Throwable> errors) {
StringBuilder buf = new StringBuilder();
int i = 0;
for (Throwable e : errors) {
if (e instanceof ReportException) {
- report(obj, ((ReportException)e).version);
+ report(obj, ((ReportException) e).version);
} else {
- if (++i > 1) buf.append(", ");
+ if (++i > 1) {
+ buf.append(", ");
+ }
buf.append(e.getClass().getSimpleName()).append(": ").append(e.getMessage());
}
}
- if (buf.length() == 0) return;
- OldDataMonitor odm = (OldDataMonitor)Hudson.getInstance().getAdministrativeMonitor("OldData");
+ if (buf.length() == 0) {
+ return;
+ }
+ OldDataMonitor odm = (OldDataMonitor) Hudson.getInstance().getAdministrativeMonitor("OldData");
synchronized (odm) {
VersionRange vr = odm.data.get(obj);
- if (vr != null) vr.extra = buf.toString();
- else odm.data.put(obj, new VersionRange(null, buf.toString()));
+ if (vr != null) {
+ vr.extra = buf.toString();
+ } else {
+ odm.data.put(obj, new VersionRange(null, buf.toString()));
+ }
}
}
public static class VersionRange {
- private static VersionNumber currentVersion = Hudson.getVersion();
+ private static VersionNumber currentVersion = Hudson.getVersion();
VersionNumber min, max;
boolean single = true;
//TODO: review and check whether we can do it private
@@ -194,22 +212,32 @@ public class OldDataMonitor extends AdministrativeMonitor {
public void add(String version) {
VersionNumber ver = new VersionNumber(version);
- if (min==null) { min = max = ver; }
- else {
- if (ver.isOlderThan(min)) { min = ver; single = false; }
- if (ver.isNewerThan(max)) { max = ver; single = false; }
+ if (min == null) {
+ min = max = ver;
+ } else {
+ if (ver.isOlderThan(min)) {
+ min = ver;
+ single = false;
+ }
+ if (ver.isNewerThan(max)) {
+ max = ver;
+ single = false;
+ }
}
}
@Override
public String toString() {
- return min==null ? "" : min.toString() + (single ? "" : " - " + max.toString());
+ return min == null ? "" : min.toString() + (single ? "" : " - " + max.toString());
}
/**
- * Does this version range contain a version more than the given number of releases ago?
+ * Does this version range contain a version more than the given number
+ * of releases ago?
+ *
* @param threshold Number of releases
- * @return True if the major version# differs or the minor# differs by >= threshold
+ * @return True if the major version# differs or the minor# differs by
+ * >= threshold
*/
public boolean isOld(int threshold) {
return currentVersion != null && min != null && (currentVersion.digit(0) > min.digit(0)
@@ -219,17 +247,22 @@ public class OldDataMonitor extends AdministrativeMonitor {
}
/**
- * Sorted list of unique max-versions in the data set. For select list in jelly.
+ * Sorted list of unique max-versions in the data set. For select list in
+ * jelly.
*/
public synchronized Iterator<VersionNumber> getVersionList() {
TreeSet<VersionNumber> set = new TreeSet<VersionNumber>();
- for (VersionRange vr : data.values())
- if (vr.max!=null) set.add(vr.max);
+ for (VersionRange vr : data.values()) {
+ if (vr.max != null) {
+ set.add(vr.max);
+ }
+ }
return set.iterator();
}
/**
- * Depending on whether the user said "yes" or "no", send him to the right place.
+ * Depending on whether the user said "yes" or "no", send him to the right
+ * place.
*/
public HttpResponse doAct(StaplerRequest req, StaplerResponse rsp) throws IOException {
if (req.hasParameter("no")) {
@@ -241,15 +274,15 @@ public class OldDataMonitor extends AdministrativeMonitor {
}
/**
- * Save all or some of the files to persist data in the new forms.
- * Remove those items from the data map.
+ * Save all or some of the files to persist data in the new forms. Remove
+ * those items from the data map.
*/
public synchronized HttpResponse doUpgrade(StaplerRequest req, StaplerResponse rsp) throws IOException {
String thruVerParam = req.getParameter("thruVer");
VersionNumber thruVer = thruVerParam.equals("all") ? null : new VersionNumber(thruVerParam);
updating = true;
- for (Iterator<Map.Entry<Saveable,VersionRange>> it = data.entrySet().iterator(); it.hasNext();) {
- Map.Entry<Saveable,VersionRange> entry = it.next();
+ for (Iterator<Map.Entry<Saveable, VersionRange>> it = data.entrySet().iterator(); it.hasNext();) {
+ Map.Entry<Saveable, VersionRange> entry = it.next();
VersionNumber version = entry.getValue().max;
if (version != null && (thruVer == null || !version.isNewerThan(thruVer))) {
entry.getKey().save();
@@ -261,13 +294,13 @@ public class OldDataMonitor extends AdministrativeMonitor {
}
/**
- * Save all files containing only unreadable data (no data upgrades), which discards this data.
- * Remove those items from the data map.
+ * Save all files containing only unreadable data (no data upgrades), which
+ * discards this data. Remove those items from the data map.
*/
public synchronized HttpResponse doDiscard(StaplerRequest req, StaplerResponse rsp) throws IOException {
updating = true;
- for (Iterator<Map.Entry<Saveable,VersionRange>> it = data.entrySet().iterator(); it.hasNext();) {
- Map.Entry<Saveable,VersionRange> entry = it.next();
+ for (Iterator<Map.Entry<Saveable, VersionRange>> it = data.entrySet().iterator(); it.hasNext();) {
+ Map.Entry<Saveable, VersionRange> entry = it.next();
if (entry.getValue().max == null) {
entry.getKey().save();
it.remove();
diff --git a/hudson-core/src/main/java/hudson/diagnosis/ReverseProxySetupMonitor.java b/hudson-core/src/main/java/hudson/diagnosis/ReverseProxySetupMonitor.java
index e097c55..852a8e0 100644
--- a/hudson-core/src/main/java/hudson/diagnosis/ReverseProxySetupMonitor.java
+++ b/hudson-core/src/main/java/hudson/diagnosis/ReverseProxySetupMonitor.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -28,18 +28,21 @@ import org.kohsuke.stapler.WebMethod;
import java.io.IOException;
/**
- * Looks out for a broken reverse proxy setup that doesn't rewrite the location header correctly.
+ * Looks out for a broken reverse proxy setup that doesn't rewrite the location
+ * header correctly.
*
- * <p>
- * Have the JavaScript make an AJAX call, to which we respond with 302 redirect. If the reverse proxy
- * is done correctly, this will be handled by {@link #doFoo()}, but otherwise we'll report that as an error.
- * Unfortunately, {@code XmlHttpRequest} doesn't expose properties that allow the client-side JavaScript
- * to learn the details of the failure, so we have to make do with limited information.
+ * <p> Have the JavaScript make an AJAX call, to which we respond with 302
+ * redirect. If the reverse proxy is done correctly, this will be handled by
+ * {@link #doFoo()}, but otherwise we'll report that as an error. Unfortunately,
+ * {@code XmlHttpRequest} doesn't expose properties that allow the client-side
+ * JavaScript to learn the details of the failure, so we have to make do with
+ * limited information.
*
* @author Kohsuke Kawaguchi
*/
@Extension
public class ReverseProxySetupMonitor extends AdministrativeMonitor {
+
@Override
public boolean isActivated() {
// return true to always inject an HTML fragment to perform a test
@@ -50,16 +53,17 @@ public class ReverseProxySetupMonitor extends AdministrativeMonitor {
return new HttpRedirect("test-for-reverse-proxy-setup");
}
- @WebMethod(name="test-for-reverse-proxy-setup")
+ @WebMethod(name = "test-for-reverse-proxy-setup")
public FormValidation doFoo() {
return FormValidation.ok();
}
/**
- * Depending on whether the user said "yes" or "no", send him to the right place.
+ * Depending on whether the user said "yes" or "no", send him to the right
+ * place.
*/
public HttpResponse doAct(@QueryParameter String no) throws IOException {
- if(no!=null) { // dismiss
+ if (no != null) { // dismiss
disable(true);
// of course the irony is that this redirect won't work
return HttpResponses.redirectViaContextPath("/manage");
@@ -68,4 +72,3 @@ public class ReverseProxySetupMonitor extends AdministrativeMonitor {
}
}
}
-
diff --git a/hudson-core/src/main/java/hudson/diagnosis/TooManyJobsButNoView.java b/hudson-core/src/main/java/hudson/diagnosis/TooManyJobsButNoView.java
index df6d15b..093b1b2 100644
--- a/hudson-core/src/main/java/hudson/diagnosis/TooManyJobsButNoView.java
+++ b/hudson-core/src/main/java/hudson/diagnosis/TooManyJobsButNoView.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -25,31 +25,33 @@ import org.kohsuke.stapler.StaplerResponse;
import java.io.IOException;
/**
- * If Hudson is run with a lot of jobs but no views, suggest the user that they can create views.
+ * If Hudson is run with a lot of jobs but no views, suggest the user that they
+ * can create views.
*
- * <p>
- * I noticed at an user visit that some users didn't notice the '+' icon in the tab bar.
+ * <p> I noticed at an user visit that some users didn't notice the '+' icon in
+ * the tab bar.
*
* @author Kohsuke Kawaguchi
*/
@Extension
public class TooManyJobsButNoView extends AdministrativeMonitor {
+
public boolean isActivated() {
Hudson h = Hudson.getInstance();
- return h.getViews().size()==1 && h.getItemMap().size()> THRESHOLD;
+ return h.getViews().size() == 1 && h.getItemMap().size() > THRESHOLD;
}
/**
- * Depending on whether the user said "yes" or "no", send him to the right place.
+ * Depending on whether the user said "yes" or "no", send him to the right
+ * place.
*/
public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException {
- if(req.hasParameter("no")) {
+ if (req.hasParameter("no")) {
disable(true);
- rsp.sendRedirect(req.getContextPath()+"/manage");
+ rsp.sendRedirect(req.getContextPath() + "/manage");
} else {
- rsp.sendRedirect(req.getContextPath()+"/newView");
+ rsp.sendRedirect(req.getContextPath() + "/newView");
}
}
-
public static final int THRESHOLD = 16;
}
diff --git a/hudson-core/src/main/java/hudson/fsp/WorkspaceSnapshotSCM.java b/hudson-core/src/main/java/hudson/fsp/WorkspaceSnapshotSCM.java
index 8b629ad..be3ff22 100644
--- a/hudson-core/src/main/java/hudson/fsp/WorkspaceSnapshotSCM.java
+++ b/hudson-core/src/main/java/hudson/fsp/WorkspaceSnapshotSCM.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -39,18 +39,21 @@ import java.io.File;
import org.kohsuke.stapler.DataBoundConstructor;
/**
- * {@link SCM} that inherits the workspace from another build through {@link WorkspaceSnapshot}
+ * {@link SCM} that inherits the workspace from another build through
+ * {@link WorkspaceSnapshot}
*
* @author Kohsuke Kawaguchi
*/
public class WorkspaceSnapshotSCM extends SCM {
+
/**
* The job name from which we inherit the workspace.
*/
//TODO: review and check whether we can do it private
public String jobName;
/**
- * The permalink name indicating the build from which to inherit the workspace.
+ * The permalink name indicating the build from which to inherit the
+ * workspace.
*/
public String permalink;
@@ -69,57 +72,66 @@ public class WorkspaceSnapshotSCM extends SCM {
}
/**
- * {@link Exception} indicating that the resolution of the job/permalink failed.
+ * {@link Exception} indicating that the resolution of the job/permalink
+ * failed.
*/
private final class ResolvedFailedException extends Exception {
+
private ResolvedFailedException(String message) {
super(message);
}
}
private static class Snapshot {
+
final WorkspaceSnapshot snapshot;
- final AbstractBuild<?,?> owner;
- private Snapshot(WorkspaceSnapshot snapshot, AbstractBuild<?,?> owner) {
+ final AbstractBuild<?, ?> owner;
+
+ private Snapshot(WorkspaceSnapshot snapshot, AbstractBuild<?, ?> owner) {
this.snapshot = snapshot;
this.owner = owner;
}
- void restoreTo(FilePath dst,TaskListener listener) throws IOException, InterruptedException {
- snapshot.restoreTo(owner,dst,listener);
+ void restoreTo(FilePath dst, TaskListener listener) throws IOException, InterruptedException {
+ snapshot.restoreTo(owner, dst, listener);
}
}
+
/**
- * Obtains the {@link WorkspaceSnapshot} object that this {@link SCM} points to,
- * or throws {@link ResolvedFailedException} upon failing.
+ * Obtains the {@link WorkspaceSnapshot} object that this {@link SCM} points
+ * to, or throws {@link ResolvedFailedException} upon failing.
*
* @return never null.
*/
public Snapshot resolve() throws ResolvedFailedException {
Hudson h = Hudson.getInstance();
- AbstractProject<?,?> job = h.getItemByFullName(jobName, AbstractProject.class);
- if(job==null) {
- if(h.getItemByFullName(jobName)==null) {
+ AbstractProject<?, ?> job = h.getItemByFullName(jobName, AbstractProject.class);
+ if (job == null) {
+ if (h.getItemByFullName(jobName) == null) {
AbstractProject nearest = AbstractProject.findNearest(jobName);
- throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoSuchJob(jobName,nearest.getFullName()));
- } else
+ throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoSuchJob(jobName, nearest.getFullName()));
+ } else {
throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_IncorrectJobType(jobName));
+ }
}
PermalinkList permalinks = job.getPermalinks();
Permalink p = permalinks.get(permalink);
- if(p==null)
- throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoSuchPermalink(permalink,jobName));
+ if (p == null) {
+ throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoSuchPermalink(permalink, jobName));
+ }
- AbstractBuild<?,?> b = (AbstractBuild<?,?>)p.resolve(job);
- if(b==null)
- throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoBuild(permalink,jobName));
+ AbstractBuild<?, ?> b = (AbstractBuild<?, ?>) p.resolve(job);
+ if (b == null) {
+ throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoBuild(permalink, jobName));
+ }
WorkspaceSnapshot snapshot = b.getAction(WorkspaceSnapshot.class);
- if(snapshot==null)
- throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoWorkspace(jobName,permalink));
+ if (snapshot == null) {
+ throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoWorkspace(jobName, permalink));
+ }
- return new Snapshot(snapshot,b);
+ return new Snapshot(snapshot, b);
}
public SCMRevisionState calcRevisionsFromBuild(AbstractBuild<?, ?> build, Launcher launcher, TaskListener listener) throws IOException, InterruptedException {
@@ -132,7 +144,7 @@ public class WorkspaceSnapshotSCM extends SCM {
public boolean checkout(AbstractBuild build, Launcher launcher, FilePath workspace, BuildListener listener, File changelogFile) throws IOException, InterruptedException {
try {
- resolve().restoreTo(workspace,listener);
+ resolve().restoreTo(workspace, listener);
return true;
} catch (ResolvedFailedException e) {
listener.error(e.getMessage()); // stack trace is meaningless