Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinston Prakash2012-10-16 17:50:40 -0400
committerWinston Prakash2012-10-16 17:50:40 -0400
commit9d6126dc82a9165a0673cf4d324575239fd85898 (patch)
treeaa818a92b716e6327c7791d5e82023e28ab51830
parentfa832379f68f8f6512a86bf0020057c1e33259de (diff)
downloadorg.eclipse.hudson.core-9d6126dc82a9165a0673cf4d324575239fd85898.tar.gz
org.eclipse.hudson.core-9d6126dc82a9165a0673cf4d324575239fd85898.tar.xz
org.eclipse.hudson.core-9d6126dc82a9165a0673cf4d324575239fd85898.zip
Remove unused groovy script
-rw-r--r--hudson-core/src/main/groovy/hudson/util/LoadMonitor.groovy106
1 files changed, 0 insertions, 106 deletions
diff --git a/hudson-core/src/main/groovy/hudson/util/LoadMonitor.groovy b/hudson-core/src/main/groovy/hudson/util/LoadMonitor.groovy
deleted file mode 100644
index 89a7dd2a..00000000
--- a/hudson-core/src/main/groovy/hudson/util/LoadMonitor.groovy
+++ /dev/null
@@ -1,106 +0,0 @@
-/**************************************************************************
-#
-# Copyright (C) 2004-2009 Oracle Corporation
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Kohsuke Kawaguchi
-#
-#**************************************************************************/
-
-package hudson.util
-
-import hudson.model.Computer
-import hudson.model.Hudson
-import hudson.model.Label
-import hudson.model.Queue.BlockedItem
-import hudson.model.Queue.BuildableItem
-import hudson.model.Queue.WaitingItem
-import hudson.triggers.SafeTimerTask
-import java.text.DateFormat
-import hudson.triggers.Trigger;
-
-/**
- * Spits out the load information.
- *
- * <p>
- * I'm using this code to design the auto scaling feature.
- * In future this might be useful data to expose to the UI.
- *
- * @author Kohsuke Kawaguchi
- */
-public class LoadMonitorImpl extends SafeTimerTask {
-
- private final File dataFile;
- private List<String> labels;
-
- public LoadMonitorImpl(File dataFile) {
- this.dataFile = dataFile;
- labels = Hudson.getInstance().labels*.name;
- printHeaders();
- Trigger.timer.scheduleAtFixedRate(this,0,10*1000);
- }
-
- private String quote(Object s) { "\"${s}\""; }
-
- protected void printHeaders() {
- def headers = ["# of executors","# of busy executors","BuildableItems in Q","BuildableItem avg wait time"];
- def data = ["timestamp"];
- data += headers;
- data += ["WaitingItems in Q","BlockedItems in Q"];
-
- for( String label : labels)
- data += headers.collect { "${it} (${label}}" }
-
- dataFile.append(data.collect({ quote(it) }).join(",")+"\n");
- }
-
- @Override
- protected void doRun() {
- def now = new Date();
- def data = [];
- data.add(quote(FORMATTER.format(now)));
-
- def h = Hudson.getInstance();
-
- def items = h.queue.items;
- def filterByType = {Class type -> items.findAll { type.isInstance(it) } }
-
- def builder = {List<Computer> cs, Closure itemFilter ->
- // number of total executor, number of busy executor
- data.add(cs.sum { it.isOffline() ? 0 : it.numExecutors });
- data.add(cs.sum {Computer c ->
- c.executors.findAll { !it.isIdle() }.size()
- });
-
- // queue statistics
- def is = filterByType(BuildableItem).findAll(itemFilter);
- data.add(is.size());
- data.add(is.sum {BuildableItem bi -> now.time - bi.buildableStartMilliseconds }?:0 / Math.max(1,is.size()) );
- };
-
-
- // for the whole thing
- builder(Arrays.asList(h.computers),{ it->true });
-
- data.add(filterByType(WaitingItem).size());
- data.add(filterByType(BlockedItem).size());
-
- // per label stats
- for (String label : labels) {
- Label l = h.getLabel(label)
- builder(l.nodes.collect { it.toComputer() }) { BuildableItem bi -> bi.task.assignedLabel==l };
- }
-
- dataFile.append(data.join(",")+"\n");
- }
-
- private static final DateFormat FORMATTER = DateFormat.getDateTimeInstance();
-}
-
-new LoadMonitorImpl(new File("/files/hudson/load.txt"));
-

Back to the top