mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-18 06:22:29 +00:00
converting several DescriptorList in a new form
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15604 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
a625a103cf
commit
f592d33a7e
9 files changed
+38
-59
No files matched your search
@@ -141,7 +141,7 @@ public class UsageStatistics extends PageDecorator {
|
||||
n.put("jvm-version", System.getProperty("java.version"));
|
||||
}
|
||||
n.put("executors",c.getNumExecutors());
|
||||
n.put("os", ArchitectureMonitor.DESCRIPTOR.get(c));
|
||||
n.put("os", ((ArchitectureMonitor.DescriptorImpl)h.getDescriptor(ArchitectureMonitor.class)).get(c));
|
||||
nodes.add(n);
|
||||
}
|
||||
o.put("nodes",nodes);
|
||||
|
||||
@@ -24,7 +24,9 @@
|
||||
package hudson.node_monitors;
|
||||
|
||||
import hudson.model.Computer;
|
||||
import hudson.model.Descriptor.FormException;
|
||||
import hudson.remoting.Callable;
|
||||
import hudson.Extension;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
|
||||
@@ -36,11 +38,8 @@ import java.io.IOException;
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class ArchitectureMonitor extends NodeMonitor {
|
||||
public AbstractNodeMonitorDescriptor getDescriptor() {
|
||||
return DESCRIPTOR;
|
||||
}
|
||||
|
||||
public static final AbstractNodeMonitorDescriptor<String> DESCRIPTOR = new AbstractNodeMonitorDescriptor<String>() {
|
||||
@Extension
|
||||
public static final class DescriptorImpl extends AbstractNodeMonitorDescriptor<String> {
|
||||
protected String monitor(Computer c) throws IOException, InterruptedException {
|
||||
return c.getChannel().call(new GetArchTask());
|
||||
}
|
||||
@@ -52,7 +51,7 @@ public class ArchitectureMonitor extends NodeMonitor {
|
||||
public NodeMonitor newInstance(StaplerRequest req, JSONObject formData) throws FormException {
|
||||
return new ArchitectureMonitor();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the string that represents the architecture.
|
||||
@@ -66,8 +65,4 @@ public class ArchitectureMonitor extends NodeMonitor {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
static {
|
||||
LIST.add(DESCRIPTOR);
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import hudson.model.Computer;
|
||||
import hudson.model.Node;
|
||||
import hudson.model.Descriptor;
|
||||
import hudson.util.ClockDifference;
|
||||
import hudson.Extension;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -41,14 +42,11 @@ import net.sf.json.JSONObject;
|
||||
* @since 1.123
|
||||
*/
|
||||
public class ClockMonitor extends NodeMonitor {
|
||||
public AbstractNodeMonitorDescriptor getDescriptor() {
|
||||
return DESCRIPTOR;
|
||||
}
|
||||
|
||||
public ClockDifference getDifferenceFor(Computer c) {
|
||||
return DESCRIPTOR.get(c);
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static final AbstractNodeMonitorDescriptor<ClockDifference> DESCRIPTOR = new AbstractNodeMonitorDescriptor<ClockDifference>() {
|
||||
protected ClockDifference monitor(Computer c) throws IOException, InterruptedException {
|
||||
Node n = c.getNode();
|
||||
@@ -65,8 +63,4 @@ public class ClockMonitor extends NodeMonitor {
|
||||
return new ClockMonitor();
|
||||
}
|
||||
};
|
||||
|
||||
static {
|
||||
LIST.add(DESCRIPTOR);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,8 @@ package hudson.node_monitors;
|
||||
import hudson.FilePath;
|
||||
import hudson.FilePath.FileCallable;
|
||||
import hudson.Util;
|
||||
import hudson.Functions;
|
||||
import hudson.Extension;
|
||||
import hudson.model.Computer;
|
||||
import hudson.model.Hudson;
|
||||
import hudson.remoting.VirtualChannel;
|
||||
@@ -46,10 +48,6 @@ import java.util.logging.Logger;
|
||||
* @since 1.123
|
||||
*/
|
||||
public class DiskSpaceMonitor extends NodeMonitor {
|
||||
public AbstractNodeMonitorDescriptor getDescriptor() {
|
||||
return DESCRIPTOR;
|
||||
}
|
||||
|
||||
public Long getFreeSpace(Computer c) {
|
||||
return DESCRIPTOR.get(c);
|
||||
}
|
||||
@@ -101,6 +99,12 @@ public class DiskSpaceMonitor extends NodeMonitor {
|
||||
}
|
||||
};
|
||||
|
||||
@Extension
|
||||
public static AbstractNodeMonitorDescriptor<Long> install() {
|
||||
if(Functions.isMustangOrAbove()) return DESCRIPTOR;
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final class GetUsableSpace implements FileCallable<Long> {
|
||||
@IgnoreJRERequirement
|
||||
public Long invoke(File f, VirtualChannel channel) throws IOException {
|
||||
@@ -114,9 +118,5 @@ public class DiskSpaceMonitor extends NodeMonitor {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
static {
|
||||
LIST.add(DESCRIPTOR);
|
||||
}
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(DiskSpaceMonitor.class.getName());
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import hudson.model.Computer;
|
||||
import hudson.model.ComputerSet;
|
||||
import hudson.model.Describable;
|
||||
import hudson.model.Node;
|
||||
import hudson.model.Hudson;
|
||||
import hudson.util.DescriptorList;
|
||||
|
||||
import java.util.logging.Level;
|
||||
@@ -65,7 +66,9 @@ public abstract class NodeMonitor implements ExtensionPoint, Describable<NodeMon
|
||||
return getDescriptor().getDisplayName();
|
||||
}
|
||||
|
||||
public abstract AbstractNodeMonitorDescriptor<?> getDescriptor();
|
||||
public AbstractNodeMonitorDescriptor<?> getDescriptor() {
|
||||
return (AbstractNodeMonitorDescriptor<?>)Hudson.getInstance().getDescriptor(getClass());
|
||||
}
|
||||
|
||||
public Object data(Computer c) {
|
||||
return getDescriptor().get(c);
|
||||
@@ -96,18 +99,5 @@ public abstract class NodeMonitor implements ExtensionPoint, Describable<NodeMon
|
||||
/**
|
||||
* All registered {@link NodeMonitor}s.
|
||||
*/
|
||||
public static final DescriptorList<NodeMonitor> LIST = new DescriptorList<NodeMonitor>();
|
||||
|
||||
static {
|
||||
try {
|
||||
LIST.load(ClockMonitor.class);
|
||||
if(Functions.isMustangOrAbove())
|
||||
LIST.load(DiskSpaceMonitor.class);
|
||||
LIST.load(SwapSpaceMonitor.class);
|
||||
LIST.load(ResponseTimeMonitor.class);
|
||||
LIST.load(ArchitectureMonitor.class);
|
||||
} catch (Throwable e) {
|
||||
Logger.getLogger(NodeMonitor.class.getName()).log(Level.SEVERE, "Failed to load built-in monitors",e);
|
||||
}
|
||||
}
|
||||
public static final DescriptorList<NodeMonitor> LIST = new DescriptorList<NodeMonitor>(NodeMonitor.class);
|
||||
}
|
||||
@@ -24,6 +24,7 @@
|
||||
package hudson.node_monitors;
|
||||
|
||||
import hudson.Util;
|
||||
import hudson.Extension;
|
||||
import hudson.model.Computer;
|
||||
import hudson.remoting.Callable;
|
||||
import hudson.remoting.Future;
|
||||
@@ -46,10 +47,7 @@ import org.kohsuke.stapler.export.ExportedBean;
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class ResponseTimeMonitor extends NodeMonitor {
|
||||
public AbstractNodeMonitorDescriptor getDescriptor() {
|
||||
return DESCRIPTOR;
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static final AbstractNodeMonitorDescriptor<Data> DESCRIPTOR = new AbstractNodeMonitorDescriptor<Data>() {
|
||||
protected Data monitor(Computer c) throws IOException, InterruptedException {
|
||||
Data old = get(c);
|
||||
@@ -162,10 +160,6 @@ public class ResponseTimeMonitor extends NodeMonitor {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
static {
|
||||
LIST.add(DESCRIPTOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Time out interval in milliseconds.
|
||||
*/
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
package hudson.node_monitors;
|
||||
|
||||
import hudson.Util;
|
||||
import hudson.Extension;
|
||||
import hudson.model.Computer;
|
||||
import hudson.model.Hudson;
|
||||
import hudson.remoting.Callable;
|
||||
@@ -43,10 +44,6 @@ import java.io.IOException;
|
||||
* @sine 1.233
|
||||
*/
|
||||
public class SwapSpaceMonitor extends NodeMonitor {
|
||||
public AbstractNodeMonitorDescriptor getDescriptor() {
|
||||
return DESCRIPTOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTML representation of the space.
|
||||
*/
|
||||
@@ -80,6 +77,7 @@ public class SwapSpaceMonitor extends NodeMonitor {
|
||||
return Hudson.getInstance().hasPermission(Hudson.ADMINISTER) ? super.getColumnCaption() : null;
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static final AbstractNodeMonitorDescriptor<MemoryUsage> DESCRIPTOR = new AbstractNodeMonitorDescriptor<MemoryUsage>() {
|
||||
protected MemoryUsage monitor(Computer c) throws IOException, InterruptedException {
|
||||
return c.getChannel().call(new MonitorTask());
|
||||
@@ -164,8 +162,4 @@ public class SwapSpaceMonitor extends NodeMonitor {
|
||||
return availableSwapSpace;
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
LIST.add(DESCRIPTOR);
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public abstract class Cloud extends AbstractModelObject implements ExtensionPoin
|
||||
/**
|
||||
* All registered {@link Cloud} implementations.
|
||||
*/
|
||||
public static final DescriptorList<Cloud> ALL = new DescriptorList<Cloud>();
|
||||
public static final DescriptorList<Cloud> ALL = new DescriptorList<Cloud>(Cloud.class);
|
||||
|
||||
/**
|
||||
* Permission constant to control mutation operations on {@link Cloud}.
|
||||
|
||||
Reference in new issue
Block a user