提交 27cb0e90 编写于 作者: K kohsuke

added a test JobProperty implementation that makes the job heavier

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@34619 71c3de6d-444a-0410-be80-ed276b4c234a
上级 a9f3b6f5
......@@ -1014,7 +1014,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
for (SubTaskContributor euc : SubTaskContributor.all())
r.addAll(euc.forProject(this));
for (JobProperty<? super P> p : properties)
r.addAll(p.getMemberExecutionUnits());
r.addAll(p.getSubTasks());
return r;
}
......
......@@ -170,7 +170,7 @@ public abstract class JobProperty<J extends Job<?,?>> implements Describable<Job
*
* @since 1.FATTASK
*/
public Collection<? extends SubTask> getMemberExecutionUnits() {
public Collection<? extends SubTask> getSubTasks() {
return Collections.emptyList();
}
}
/*
* The MIT License
*
* Copyright (c) 2010, InfraDNA, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package hudson.model.queue;
import hudson.Extension;
import hudson.model.AbstractProject;
import hudson.model.JobProperty;
import hudson.model.JobPropertyDescriptor;
import hudson.model.Queue.Executable;
import hudson.model.Queue.Task;
import org.kohsuke.stapler.DataBoundConstructor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
*
*
* @author Kohsuke Kawaguchi
*/
public class WideJobProperty extends JobProperty<AbstractProject<?,?>> {
public final int weight;
@DataBoundConstructor
public WideJobProperty(int weight) {
this.weight = weight;
}
@Override
public List<SubTask> getSubTasks() {
List<SubTask> r = new ArrayList<SubTask>();
for (int i=1; i< weight; i++)
r.add(new AbstractSubTask() {
private final AbstractSubTask outerThis = this;
public Executable createExecutable() throws IOException {
return new Executable() {
public SubTask getParent() {
return outerThis;
}
public void run() {
// nothing. we just waste time
}
};
}
@Override
public Object getSameNodeConstraint() {
// must occupy the same node as the project itself
return getProject();
}
@Override
public long getEstimatedDuration() {
return getProject().getEstimatedDuration();
}
public Task getOwnerTask() {
return getProject();
}
public String getDisplayName() {
return "place holder for "+getProject().getDisplayName();
}
private AbstractProject<?, ?> getProject() {
return WideJobProperty.this.owner;
}
});
return r;
}
@Extension
public static class DescriptorImpl extends JobPropertyDescriptor {
@Override
public String getDisplayName() {
return "This project occupies multiple executors";
}
}
}
<!--
The MIT License
Copyright (c) 2010, InfraDNA, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<!-- JDK config -->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<f:entry title="${%Weight}" field="weight">
<f:textbox />
</f:entry>
</j:jelly>
TODO:
If a subtask is interrupted, all the executors should be aborted.
executor rendering
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册