當前位置: 首頁>>代碼示例>>Java>>正文


Java Computer類代碼示例

本文整理匯總了Java中hudson.model.Computer的典型用法代碼示例。如果您正苦於以下問題:Java Computer類的具體用法?Java Computer怎麽用?Java Computer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Computer類屬於hudson.model包,在下文中一共展示了Computer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: localRootPathToNodeMountPoint

import hudson.model.Computer; //導入依賴的package包/類
@LocalData
@Test
public void localRootPathToNodeMountPoint() throws Exception {

    // The node configuration version 1.0.0 contains a localRootPath field.
    // This tests that future versions load this field as nodeMountPoint,
    // in other words it tests NodeDisk.readResolve()

    Computer computer = jr.getInstance().getComputer("node1");
    Node node = computer.getNode();
    DescribableList<NodeProperty<?>,NodePropertyDescriptor> props = node.getNodeProperties();
    ExternalWorkspaceProperty exwsProp = props.get(ExternalWorkspaceProperty.class);

    List<NodeDiskPool> diskPools = exwsProp.getNodeDiskPools();
    assertThat(diskPools.size(), is(1));

    NodeDiskPool diskPool = diskPools.get(0);
    assertThat(diskPool.getDiskPoolRefId(), is ("dp1"));

    List<NodeDisk> disks = diskPool.getNodeDisks();
    assertThat(disks.size(), is(1));

    NodeDisk disk = disks.get(0);
    assertThat(disk.getDiskRefId(), is("d1"));
    assertThat(disk.getNodeMountPoint(), is("/tmp/dp1/d1"));
}
 
開發者ID:jenkinsci,項目名稱:external-workspace-manager-plugin,代碼行數:27,代碼來源:ConfigMigrationTest.java

示例2: modifiedWhileSerialized

import hudson.model.Computer; //導入依賴的package包/類
@Test @Issue("JENKINS-41037")
public void modifiedWhileSerialized() throws Exception {
    final CloudStatistics cs = CloudStatistics.get();
    final CloudStatistics.ProvisioningListener l = CloudStatistics.ProvisioningListener.get();
    final ProvisioningActivity activity = l.onStarted(new ProvisioningActivity.Id("Cloud", "template", "PAOriginal"));
    final StatsModifyingAttachment blocker = new StatsModifyingAttachment(OK, "Blocker");
    Computer.threadPoolForRemoting.submit(new Callable<Object>() {
        @Override public Object call() throws Exception {
            cs.attach(activity, PROVISIONING, blocker);
            cs.persist();
            return null;
        }
    }).get();

    String serialized = cs.getConfigFile().asString();
    assertThat(serialized, not(containsString("ConcurrentModificationException")));
    assertThat(serialized, not(containsString("active class=\"linked-hash-set\"")));
    assertThat(serialized, containsString("Blocker"));
    assertThat(serialized, containsString("PAOriginal"));
    assertThat(serialized, containsString("PAModifying"));
    assertThat(serialized, containsString("active class=\"java.util.concurrent.CopyOnWriteArrayList\""));
}
 
開發者ID:jenkinsci,項目名稱:cloud-stats-plugin,代碼行數:23,代碼來源:CloudStatisticsTest.java

示例3: getGroups

import hudson.model.Computer; //導入依賴的package包/類
public List<PermissionGroup> getGroups(String typeString) {
	AclType type = AclType.parseAclType(typeString);
	List<PermissionGroup> groups;
	switch (type) {
	case GLOBAL: {
		groups = new ArrayList<PermissionGroup>(
				PermissionGroup.getAll());
		groups.remove(PermissionGroup.get(Permission.class));
		break;
	}
	case PROJECT: {
		groups = new ArrayList<PermissionGroup>(
				PermissionGroup.getAll());
		groups.remove(PermissionGroup.get(Permission.class));
		groups.remove(PermissionGroup.get(Jenkins.class));
		groups.remove(PermissionGroup.get(Computer.class));
		groups.remove(PermissionGroup.get(View.class));
		break;
	}
	default:
		groups = null;
	}
	return groups;
}
 
開發者ID:jenkinsci,項目名稱:ssh2easy-plugin,代碼行數:25,代碼來源:CloudCIAuthorizationStrategy.java

示例4: setUp

import hudson.model.Computer; //導入依賴的package包/類
@Override
public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException {
	OpenEdgeInstallation installation = getOpenEdgeInstallation();
	if (installation != null) {
		installation = installation.forNode(Computer.currentComputer().getNode(), listener);
	}

	// Add DLC variable and modify PATH
	final OpenEdgeInstallation install = installation;
	return new Environment() {
		@Override
		public void buildEnvVars(Map<String, String> env) {
			if (install != null) {
				EnvVars envVars = new EnvVars();
				install.buildEnvVars(envVars);
				env.putAll(envVars);
			}
		}
	};
}
 
開發者ID:Riverside-Software,項目名稱:openedge-jenkins-plugin,代碼行數:21,代碼來源:OpenEdgeBuildWrapper.java

示例5: provision

import hudson.model.Computer; //導入依賴的package包/類
@Override
public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload) {
    try {

        List<NodeProvisioner.PlannedNode> r = new ArrayList<NodeProvisioner.PlannedNode>();
        final ECSTaskTemplate template = getTemplate(label);

        for (int i = 1; i <= excessWorkload; i++) {

            r.add(new NodeProvisioner.PlannedNode(template.getDisplayName(), Computer.threadPoolForRemoting
                    .submit(new ProvisioningCallback(template, label)), 1));
        }
        return r;
    } catch (Exception e) {
        LOGGER.log(Level.WARNING, "Failed to provision ECS slave", e);
        return Collections.emptyList();
    }
}
 
開發者ID:cloudbees,項目名稱:amazon-ecs-plugin,代碼行數:19,代碼來源:ECSCloud.java

示例6: attachFacet

import hudson.model.Computer; //導入依賴的package包/類
public static void attachFacet(Run<?, ?> run, TaskListener listener) {
    final Executor executor = run.getExecutor();
    if (executor == null) {
        return;
    }

    final Computer owner = executor.getOwner();
    DockerComputer dockerComputer;
    if (owner instanceof DockerComputer) {
        dockerComputer = (DockerComputer) owner;
        try {
            DockerFingerprints.addRunFacet(
                    createRecordFor(dockerComputer),
                    run
            );
        } catch (IOException | ParseException e) {
            listener.error("Can't add Docker fingerprint to run.");
            LOG.error("Can't add fingerprint to run {}", run, e);
        }
    }


}
 
開發者ID:KostyaSha,項目名稱:yet-another-docker-plugin,代碼行數:24,代碼來源:ContainerRecordUtils.java

示例7: done

import hudson.model.Computer; //導入依賴的package包/類
protected void done(final AbstractCloudComputer<?> c) {
    c.setAcceptingTasks(false); // just in case
    synchronized (this) {
        if (terminating) {
            return;
        }
        terminating = true;
    }

    final Future<?> submit = Computer.threadPoolForRemoting.submit(() -> {
            try {
                AbstractCloudSlave node = c.getNode();
                if (node != null) {
                    node.terminate();
                }
            } catch (InterruptedException | IOException e) {
                LOG.warn("Failed to terminate " + c.getName(), e);
                synchronized (DockerOnceRetentionStrategy.this) {
                    terminating = false;
                }
            }
        }
    );
}
 
開發者ID:KostyaSha,項目名稱:yet-another-docker-plugin,代碼行數:25,代碼來源:DockerOnceRetentionStrategy.java

示例8: setup

import hudson.model.Computer; //導入依賴的package包/類
@Before
public void setup() throws IOException {
    // Define a Test Directory
    File localPath = File.createTempFile("TestGitRepository", "");

    // prepare a new folder
    if(localPath.exists()) localPath.delete();

    // create the repository
    repository = FileRepositoryBuilder.create(new File(localPath, ".git"));
    repository.create();

    // Setup Mocks
    when(build.getWorkspace()).thenReturn(new FilePath(new File(getClass().getResource("/").getPath())));
    when(listener.getLogger()).thenReturn(System.out);

    when(app.getName()).thenReturn("testapp");
    when(app.getGitUrl()).thenReturn(repository.getDirectory().getAbsolutePath());
    
    mockStatic(Computer.class);
    PowerMockito.when(Computer.currentComputer()).thenReturn(mock(MasterComputer.class));
    
}
 
開發者ID:jenkinsci,項目名稱:openshift-deployer-plugin,代碼行數:24,代碼來源:DeploymentPackageTest.java

示例9: updateMetrics

import hudson.model.Computer; //導入依賴的package包/類
private synchronized void updateMetrics() {
    final Jenkins jenkins = Jenkins.getInstance();
    if (jenkins != null) {
        Set<Computer> forRetention = new HashSet<Computer>();
        for (Node node : jenkins.getNodes()) {
            Computer computer = node.toComputer();
            if (computer == null) {
                continue;
            }
            forRetention.add(computer);
            getOrCreateTimer(computer);
        }
        MetricRegistry metricRegistry = Metrics.metricRegistry();
        for (Map.Entry<Computer, Timer> entry : computerBuildDurations.entrySet()) {
            if (forRetention.contains(entry.getKey())) {
                continue;
            }
            // purge dead nodes
            metricRegistry.remove(name("jenkins", "node", entry.getKey().getName(), "builds"));
        }
        computerBuildDurations.keySet().retainAll(forRetention);
    }

}
 
開發者ID:jenkinsci,項目名稱:metrics-plugin,代碼行數:25,代碼來源:JenkinsMetricProviderImpl.java

示例10: onStarted

import hudson.model.Computer; //導入依賴的package包/類
@Override
public synchronized void onStarted(Run run, TaskListener listener) {
    JenkinsMetricProviderImpl instance = instance();
    if (instance != null) {
        List<Timer.Context> contextList = new ArrayList<Timer.Context>();
        contextList.add(instance.jenkinsJobBuildingTime.time());
        Executor executor = run.getExecutor();
        if (executor != null) {
            Computer computer = executor.getOwner();
            Timer timer = instance.getOrCreateTimer(computer);
            contextList.add(timer.time());
        }
        contexts.put(run, contextList);
    }
    ScheduledRate.instance().addAction(run);
}
 
開發者ID:jenkinsci,項目名稱:metrics-plugin,代碼行數:17,代碼來源:JenkinsMetricProviderImpl.java

示例11: getExecutor

import hudson.model.Computer; //導入依賴的package包/類
@Override
@Exported
public Executor getExecutor() {
    final Jenkins jenkins = Jenkins.getInstance();
    if (jenkins == null) {
        return null;
    }
    for (final Computer computer : jenkins.getComputers()) {
        for (final Executor executor : computer.getExecutors()) {
            if (isCurrent(executor)) {
                return executor;
            }
        }
    }
    return null;
}
 
開發者ID:groupon,項目名稱:DotCi,代碼行數:17,代碼來源:DbBackedBuild.java

示例12: getRawSepFor

import hudson.model.Computer; //導入依賴的package包/類
private String getRawSepFor(Computer c) {
	if (c == null) { return null; }
	String sep = null;
	//Fetch via System properties
	try {
		Map<Object,Object> map = c.getSystemProperties();
		if (map != null && map.containsKey("file.separator")) {
			Object o = map.get("file.separator");
			if (o instanceof String) {
				sep = (String)o;
				if (sep.equals("\\") || sep.equals("/")) {
					return sep;
				}
			}
		}
	} catch (IOException | InterruptedException e) {
		return null;
	}
	return sep;
}
 
開發者ID:i-m-c,項目名稱:jenkins-inheritance-plugin,代碼行數:21,代碼來源:NodeFileSeparator.java

示例13: setLogLevel

import hudson.model.Computer; //導入依賴的package包/類
public static void setLogLevel(Level level) {
    SupportPlugin instance = getInstance();
    instance.handler.setLevel(level);
    for (Node n : Jenkins.getInstance().getNodes()) {
        Computer c = n.toComputer();
        if (c == null) {
            continue;
        }
        VirtualChannel channel = c.getChannel();
        if (channel != null) {
            try {
                channel.callAsync(new LogUpdater(level));
            } catch (IOException e) {
                // ignore
            }
        }
    }
}
 
開發者ID:jenkinsci,項目名稱:support-core-plugin,代碼行數:19,代碼來源:SupportPlugin.java

示例14: run

import hudson.model.Computer; //導入依賴的package包/類
@Override
public void run()
{
    Node node = Computer.currentComputer().getNode();
    LOGGER.info(String.format("%s was run on %s", DummySubTask.this.getDisplayName(), node.getNodeName()));
    
    try
    {
        Thread.sleep(DummySubTask.this.duration);
    }
    catch(InterruptedException e)
    {
        LOGGER.log(Level.SEVERE, "", e);
        return;
    }
    
    DummySubTask.this.lastBuiltOn = node;
}
 
開發者ID:ikedam,項目名稱:scoring-load-balancer,代碼行數:19,代碼來源:DummySubTask.java

示例15: onOnline

import hudson.model.Computer; //導入依賴的package包/類
@Override
public void onOnline(Computer c, TaskListener listener) throws IOException,
        InterruptedException {
    // gets called when master goes into online state
    // gets called when existing slave re-connects
    // gets called when new slave goes into online state
    logger.info("---- " + ComputerListenerImpl.class.getName() + ":"
            + " onOnline computer " + c);

    // update functions only when gearman-plugin is enabled
    if (!GearmanPluginConfig.get().enablePlugin()) {
        return;
    }

    GearmanProxy gp = GearmanProxy.getInstance();
    /*
     * Spawn management executor worker if one doesn't exist yet.
     * This worker does not need any executors. It only needs
     * to work with gearman.
     */
    gp.createManagementWorker();

    // on creation of new slave
    gp.createExecutorWorkersOnNode(c);
}
 
開發者ID:openstack-infra,項目名稱:gearman-plugin,代碼行數:26,代碼來源:ComputerListenerImpl.java


注:本文中的hudson.model.Computer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。