本文整理汇总了Java中hudson.slaves.SlaveComputer类的典型用法代码示例。如果您正苦于以下问题:Java SlaveComputer类的具体用法?Java SlaveComputer怎么用?Java SlaveComputer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SlaveComputer类属于hudson.slaves包,在下文中一共展示了SlaveComputer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCopyToSlave
import hudson.slaves.SlaveComputer; //导入依赖的package包/类
@Test
public void testCopyToSlave() throws Exception {
DumbSlave node = rule.createSlave();
SlaveComputer c = node.getComputer();
c.connect(false).get(); // wait until it's connected
if(c.isOffline())
fail("Slave failed to go online: " + c.getLog());
FreeStyleProject other = createArtifactProject(),
p = createProject(other.getName(), null, "", "", false, false, false, true);
rule.assertBuildStatusSuccess(other.scheduleBuild2(0, new UserCause()).get());
p.setAssignedLabel(node.getSelfLabel());
FreeStyleBuild b = p.scheduleBuild2(0, new UserCause()).get();
rule.assertBuildStatusSuccess(b);
assertSame(node, b.getBuiltOn());
assertFile(true, "foo.txt", b);
assertFile(true, "subdir/subfoo.txt", b);
assertFile(true, "deepfoo/a/b/c.log", b);
}
示例2: launch
import hudson.slaves.SlaveComputer; //导入依赖的package包/类
@Override
public void launch(final SlaveComputer computer, TaskListener listener) throws IOException, InterruptedException {
Date startDate = new Date();
PrintStream logger = listener.getLogger();
logger.println("Start time: " + getUtcDate(startDate));
if (computer instanceof HyperComputer) {
launch((HyperComputer) computer, listener);
} else {
throw new IllegalArgumentException("This launcher only can handle HyperComputer");
}
Date endDate = new Date();
logger.println("Done setting up at: " + getUtcDate(endDate));
logger.println("Done in " + TimeUnit2.MILLISECONDS.toSeconds(endDate.getTime() - startDate.getTime()) + " seconds");
}
示例3: getZAPProgramNameWithSeparator
import hudson.slaves.SlaveComputer; //导入依赖的package包/类
/**
* Return the ZAProxy program name with separator prefix (\zap.bat or /zap.sh) depending of the build node and the OS.
*
* @param build
* @return the ZAProxy program name with separator prefix (\zap.bat or /zap.sh)
* @throws IOException
* @throws InterruptedException
*/
private String getZAPProgramNameWithSeparator(AbstractBuild<?, ?> build) throws IOException, InterruptedException {
Node node = build.getBuiltOn();
String zapProgramName = "";
// Append zap program following Master/Slave and Windows/Unix
if( "".equals(node.getNodeName())) { // Master
if( File.pathSeparatorChar == ':' ) { // UNIX
zapProgramName = "/" + ZAP_PROG_NAME_SH;
} else { // Windows (pathSeparatorChar == ';')
zapProgramName = "\\" + ZAP_PROG_NAME_BAT;
}
}
else { // Slave
if( "Unix".equals(((SlaveComputer)node.toComputer()).getOSDescription()) ) {
zapProgramName = "/" + ZAP_PROG_NAME_SH;
} else {
zapProgramName = "\\" + ZAP_PROG_NAME_BAT;
}
}
return zapProgramName;
}
示例4: launch
import hudson.slaves.SlaveComputer; //导入依赖的package包/类
/**
* This method is called when the node is about to be used.
* So what it will do (in theory) is to start the vm (if
* needed), then find a way to link to the vm, and run slave.jar on the vm
*
* @param slaveComputer the node to be launched
* @param taskListener listener
*/
@Override
public void launch(SlaveComputer slaveComputer, TaskListener taskListener)
throws IOException, InterruptedException {
OVirtVMSlave slave = (OVirtVMSlave) slaveComputer.getNode();
printLog(taskListener, "Connecting to ovirt server...");
VM vm = OVirtHypervisor.find(hypervisorDescription)
.getVM(virtualMachineName);
try {
// only if snapshot is specified should we try to shut it down
// and revert to snapshot
if (isSnapshotSpecified()) {
putVMDown(vm, taskListener);
revertSnapshot(vm, slave.getSnapshotName(), taskListener);
waitTillSnapshotUnlocked(taskListener);
}
putVMUp(vm, taskListener);
delegateLauncher.launch(slaveComputer, taskListener);
} catch (Exception e) {
handleLaunchFailure(e, taskListener);
}
}
示例5: check
import hudson.slaves.SlaveComputer; //导入依赖的package包/类
@Override public long check(final SlaveComputer c) {
// Ensure that the EC2FleetCloud cannot be mutated from under us while
// we're doing this check
synchronized(parent) {
// Ensure nobody provisions onto this node until we've done
// checking
boolean shouldAcceptTasks = c.isAcceptingTasks();
c.setAcceptingTasks(false);
try {
if (isIdleForTooLong(c)) {
// Find instance ID
Node compNode = c.getNode();
if (compNode == null) {
return 0;
}
final String nodeId = compNode.getNodeName();
if (parent.terminateInstance(nodeId)) {
// Instance successfully terminated, so no longer accept tasks
shouldAcceptTasks = false;
}
} else {
if (c.isOffline() && !c.isConnecting() && c.isLaunchSupported())
c.tryReconnect();
}
} finally {
c.setAcceptingTasks(shouldAcceptTasks);
}
}
return 1;
}
示例6: prepareAndLaunchSlaveContainer
import hudson.slaves.SlaveComputer; //导入依赖的package包/类
public void prepareAndLaunchSlaveContainer(final SlaveComputer computer, TaskListener listener) throws IOException, InterruptedException {
// if slave container already exists, we reuse it
if (context.getSlaveContainer() != null) {
if (driver.hasContainer(launcher, context.getSlaveContainer().getId())) {
return;
}
}
String buildImage = spec.getBuildHostImage().getImage(driver, listener);
String containerSize = spec.getBuildHostImage().getSize();
final ContainerInstance slaveContainer = driver.createAndLaunchSlaveContainer(computer, launcher, buildImage, containerSize);
context.setSlaveContainer(slaveContainer);
}
示例7: createAndLaunchSlaveContainer
import hudson.slaves.SlaveComputer; //导入依赖的package包/类
@Override
public ContainerInstance createAndLaunchSlaveContainer(final SlaveComputer computer, Launcher launcher, String image, String size) throws IOException, InterruptedException {
String sizeFlag = "--size=" + size;
String rootUrl = Jenkins.getInstance().getRootUrl();
String jenkinsUrl = rootUrl + "/jnlpJars/slave.jar";
String downloadSlaveJarCmd = String.format("wget %s -O slave.jar && echo wget OK || (curl %s -O && echo curl OK || echo skip download slave.jar)", jenkinsUrl, jenkinsUrl);
String jnlpConnectCmd = String.format("java -jar slave.jar -jnlpUrl %s/%s/slave-agent.jnlp -secret %s", rootUrl, computer.getUrl(), computer.getJnlpMac());
String startCmd = "/bin/sh -c '" + downloadSlaveJarCmd + " ; " + jnlpConnectCmd + "'";
ArgumentListBuilder args = new ArgumentListBuilder()
.add("run", "-d")
.add(sizeFlag)
//.add("--workdir", HyperSlave.SLAVE_ROOT)
.add(image)
.add("/bin/sh", "-c")
.add(startCmd);
ByteArrayOutputStream out = new ByteArrayOutputStream();
int status = launchHyperCLI(launcher, args)
.stdout(out).stderr(launcher.getListener().getLogger()).join();
String containerId = out.toString("UTF-8").trim();
if (status != 0) {
throw new IOException("Failed to create remoting container");
}
return new ContainerInstance(image, containerId);
}
示例8: launch
import hudson.slaves.SlaveComputer; //导入依赖的package包/类
@Override
public void launch(SlaveComputer computer, TaskListener listener) {
listener.getLogger().println("Launching " + computer.getDisplayName());
try {
if (!(computer instanceof DockerComputerSingle)) {
throw new IllegalStateException(computer.getName() + " not instance of DockerComputerSingle");
}
provisionWithWait((DockerComputerSingle) computer, listener);
} catch (Throwable e) {
LOG.error("Can't launch ", e);
listener.error("Can't launch " + e.getMessage());
Throwables.propagate(e);
}
}
示例9: launch
import hudson.slaves.SlaveComputer; //导入依赖的package包/类
@Override
public void launch(SlaveComputer _computer, TaskListener listener) {
EC2Computer computer = (EC2Computer)_computer;
PrintStream logger = listener.getLogger();
logger.println("The instance " + computer.getNode().getNodeName() + " is a Spot slave.");
logger.println("Waiting for the instance to register itself with JNLP as " + computer.getNode().getNodeName());
}
示例10: getWorkingDirectory
import hudson.slaves.SlaveComputer; //导入依赖的package包/类
private String getWorkingDirectory(SlaveComputer slaveComputer) {
String workingDirectory = slaveComputer.getNode().getRemoteFS();
while (workingDirectory.endsWith("/")) {
workingDirectory = workingDirectory.substring(0, workingDirectory.length() - 1);
}
return workingDirectory;
}
示例11: afterDisconnect
import hudson.slaves.SlaveComputer; //导入依赖的package包/类
/**
* Try to shutdown the computer after the slave.jar has stopped running.
*
* @param computer node that has been disconnected
* @param listener listener
*/
@Override
public synchronized void afterDisconnect(SlaveComputer computer,
TaskListener listener) {
VM vm = OVirtHypervisor.find(hypervisorDescription)
.getVM(virtualMachineName);
try {
printLog(listener, "Shutting down...");
shutdownVM(vm);
} catch(Exception e) {
printLog(listener, "Error while shutting down VM");
printLog(listener, e.getMessage());
}
delegateLauncher.afterDisconnect(computer, listener);
}
示例12: launch
import hudson.slaves.SlaveComputer; //导入依赖的package包/类
@Override
public void launch(SlaveComputer slaveComputer, TaskListener taskListener)
throws InterruptedException, IOException {
if(delegate.isLaunchSupported()){
try {
delegate.launch(slaveComputer, taskListener);
} catch (IOException e) {
RavelloLogger.log(taskListener.getLogger(), e.getMessage());
throw e;
}
}
}
示例13: isRequired
import hudson.slaves.SlaveComputer; //导入依赖的package包/类
public static boolean isRequired() {
try {
SlaveComputer.class.getClassLoader().loadClass(SlaveComputer.class.getName() + "$SlaveLogFetcher");
return false;
} catch (ClassNotFoundException e) {
return true;
}
}
示例14: addContents
import hudson.slaves.SlaveComputer; //导入依赖的package包/类
private void addContents(@NonNull Container container, final @NonNull Node node) {
Computer c = node.toComputer();
if (c == null) {
return;
}
if (c instanceof SlaveComputer && !Boolean.TRUE.equals(((SlaveComputer) c).isUnix())) {
return;
}
if (!node.createLauncher(TaskListener.NULL).isUnix()) {
return;
}
String name;
if (node instanceof Jenkins) {
name = "master";
} else {
name = "slave/" + node.getNodeName();
}
container.add(
new Content("nodes/" + name + "/file-descriptors.txt") {
@Override
public void writeTo(OutputStream os) throws IOException {
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(os, "utf-8")));
out.println(node.getDisplayName());
out.println("======");
out.println();
try {
out.println(getUlimit(node));
} catch (IOException e) {
SupportLogFormatter.printStackTrace(e, out);
} finally {
out.flush();
}
}
}
);
}
示例15: launch
import hudson.slaves.SlaveComputer; //导入依赖的package包/类
@Override
public void launch(SlaveComputer computer, TaskListener listener) throws IOException, InterruptedException {
//noop;
}