From 2f131ae79ad6d1cb8eac49e33b5dd683dad0752f Mon Sep 17 00:00:00 2001 From: Jean-Philippe Briend Date: Fri, 6 Sep 2013 18:27:11 +0200 Subject: [PATCH] Configure time out for calculation disk usage of workspace --- .gitignore | 3 ++- .../DiskUsageProjectActionFactory.java | 26 +++++++++++++++++++ .../plugins/disk_usage/DiskUsageThread.java | 2 +- .../global.jelly | 5 ++++ .../global.properties | 1 + .../global_fr.properties | 1 + 6 files changed, 36 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f9b6a863..19eea633 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ target work *.iml -.DS_Store \ No newline at end of file +.DS_Store +.idea \ No newline at end of file diff --git a/src/main/java/hudson/plugins/disk_usage/DiskUsageProjectActionFactory.java b/src/main/java/hudson/plugins/disk_usage/DiskUsageProjectActionFactory.java index 28d794f7..20075b29 100644 --- a/src/main/java/hudson/plugins/disk_usage/DiskUsageProjectActionFactory.java +++ b/src/main/java/hudson/plugins/disk_usage/DiskUsageProjectActionFactory.java @@ -41,6 +41,9 @@ public DescriptorImpl() { // Number of days in history private int historyLength = 183; + // Timeout for a single Project's workspace analyze (in mn) + private int timeoutWorkspace = 5; + List history = new LinkedList(){ private static final long serialVersionUID = 1L; @@ -67,7 +70,10 @@ public DiskUsageProjectActionFactory newInstance(StaplerRequest req, JSONObject @Override public boolean configure(StaplerRequest req, JSONObject formData) throws FormException { + // Configure showGraph showGraph = req.getParameter("disk_usage.showGraph") != null; + + // Configure historyLength String histlen = req.getParameter("disk_usage.historyLength"); if(histlen != null ){ try{ @@ -78,6 +84,18 @@ public boolean configure(StaplerRequest req, JSONObject formData) throws FormExc }else{ historyLength = 183; } + + // Configure timeoutWorkspace + String timeoutWks = req.getParameter("disk_usage.timeoutWorkspace"); + if (timeoutWks != null ) { + try { + timeoutWorkspace = Integer.parseInt(timeoutWks); + } catch (NumberFormatException ex) { + timeoutWorkspace = 5; + } + } else { + timeoutWorkspace = 5; + } save(); return super.configure(req, formData); } @@ -98,6 +116,14 @@ public int getHistoryLength() { public void setHistoryLength(Integer historyLength) { this.historyLength = historyLength; } + + public int getTimeoutWorkspace() { + return timeoutWorkspace; + } + + public void setTimeoutWorkspace(Integer timeoutWorkspace) { + this.timeoutWorkspace = timeoutWorkspace; + } } } diff --git a/src/main/java/hudson/plugins/disk_usage/DiskUsageThread.java b/src/main/java/hudson/plugins/disk_usage/DiskUsageThread.java index fa77f7c3..60a550b3 100644 --- a/src/main/java/hudson/plugins/disk_usage/DiskUsageThread.java +++ b/src/main/java/hudson/plugins/disk_usage/DiskUsageThread.java @@ -30,7 +30,7 @@ public class DiskUsageThread extends AsyncPeriodicWork { //trigger disk usage thread each 6 hours public static final int COUNT_INTERVAL_MINUTES = 60*6; - public static final int WORKSPACE_TIMEOUT = 1000*60*5; + public static final int WORKSPACE_TIMEOUT = 1000*60*DiskUsageProjectActionFactory.DESCRIPTOR.getTimeoutWorkspace(); public DiskUsageThread() { diff --git a/src/main/resources/hudson/plugins/disk_usage/DiskUsageProjectActionFactory/global.jelly b/src/main/resources/hudson/plugins/disk_usage/DiskUsageProjectActionFactory/global.jelly index 9f798e06..52719b4f 100644 --- a/src/main/resources/hudson/plugins/disk_usage/DiskUsageProjectActionFactory/global.jelly +++ b/src/main/resources/hudson/plugins/disk_usage/DiskUsageProjectActionFactory/global.jelly @@ -9,5 +9,10 @@ ${%OverallGraphHistoryLength} + + + ${%TimeoutWorkspace} + + \ No newline at end of file diff --git a/src/main/resources/hudson/plugins/disk_usage/DiskUsageProjectActionFactory/global.properties b/src/main/resources/hudson/plugins/disk_usage/DiskUsageProjectActionFactory/global.properties index 24c5ca48..4bf8315d 100644 --- a/src/main/resources/hudson/plugins/disk_usage/DiskUsageProjectActionFactory/global.properties +++ b/src/main/resources/hudson/plugins/disk_usage/DiskUsageProjectActionFactory/global.properties @@ -21,3 +21,4 @@ # THE SOFTWARE. OverallGraphHistoryLength=Overall graph history length (days) +TimeoutWorkspace=Timeout to calculate size for a single project's workspace (minutes). diff --git a/src/main/resources/hudson/plugins/disk_usage/DiskUsageProjectActionFactory/global_fr.properties b/src/main/resources/hudson/plugins/disk_usage/DiskUsageProjectActionFactory/global_fr.properties index cf860515..fba48d9e 100644 --- a/src/main/resources/hudson/plugins/disk_usage/DiskUsageProjectActionFactory/global_fr.properties +++ b/src/main/resources/hudson/plugins/disk_usage/DiskUsageProjectActionFactory/global_fr.properties @@ -23,3 +23,4 @@ Disk\ usage=Utilisation du disque Show\ disk\ usage\ trend\ graph\ on\ the\ project\ page=Montrer le graphique de tendance d''utilisation du disque sur la page du projet OverallGraphHistoryLength=Taille du graphique d''historique (jours) +TimeoutWorkspace=Timeout pour calculer l''espace disque d''un workspace d''un projet (minutes).