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


Java ProcessorInfo類代碼示例

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


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

示例1: createDefaultFraction

import org.wildfly.common.cpu.ProcessorInfo; //導入依賴的package包/類
/**
 * Creates a default batch fraction.
 * <p>
 * Uses an {@code in-memory} job repository with the {@linkplain #DEFAULT_JOB_REPOSITORY_NAME default name}.
 * </p>
 *
 * <p>
 * Uses a default thread-pool with a calculated maximum number of threads based on the available number of processors. A
 * keep alive time of 30 seconds is used for the thread-pool.
 * </p>
 *
 * @return a new default batch fraction
 */
public static BatchFraction createDefaultFraction() {
    final BatchFraction fraction = new BatchFraction();
    final InMemoryJobRepository<?> jobRepository = new InMemoryJobRepository<>(DEFAULT_JOB_REPOSITORY_NAME);
    fraction.inMemoryJobRepository(jobRepository)
            .defaultJobRepository(jobRepository.getKey());

    // Default thread-pool
    final ThreadPool<?> threadPool = new ThreadPool<>(DEFAULT_THREAD_POOL_NAME);
    threadPool.maxThreads(ProcessorInfo.availableProcessors())
            .keepaliveTime("time", "30")
            .keepaliveTime("unit", "seconds");
    fraction.threadPool(threadPool)
            .defaultThreadPool(threadPool.getKey());

    return fraction;

}
 
開發者ID:wildfly-swarm-archive,項目名稱:ARCHIVE-wildfly-swarm,代碼行數:31,代碼來源:BatchFraction.java

示例2: getBootstrapMaxThreads

import org.wildfly.common.cpu.ProcessorInfo; //導入依賴的package包/類
/**
 * Determine the number of threads to use for the bootstrap service container. This reads
 * the {@link #BOOTSTRAP_MAX_THREADS} system property and if not set, defaults to 2*cpus.
 * @see Runtime#availableProcessors()
 * @return the maximum number of threads to use for the bootstrap service container.
 */
public static int getBootstrapMaxThreads() {
    // Base the bootstrap thread on proc count if not specified
    int cpuCount = ProcessorInfo.availableProcessors();
    int defaultThreads = cpuCount * 2;
    String maxThreads = WildFlySecurityManager.getPropertyPrivileged(BOOTSTRAP_MAX_THREADS, null);
    if (maxThreads != null && maxThreads.length() > 0) {
        try {
            int max = Integer.decode(maxThreads);
            defaultThreads = Math.max(max, 1);
        } catch(NumberFormatException ex) {
            ServerLogger.ROOT_LOGGER.failedToParseCommandLineInteger(BOOTSTRAP_MAX_THREADS, maxThreads);
        }
    }
    return defaultThreads;
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:22,代碼來源:ServerEnvironment.java

示例3: testRuntime

import org.wildfly.common.cpu.ProcessorInfo; //導入依賴的package包/類
@Test
public void testRuntime() throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization())
            .setSubsystemXml(getSubsystemXml());
    KernelServices mainServices = builder.build();
    if (!mainServices.isSuccessfulBoot()) {
        Assert.fail(String.valueOf(mainServices.getBootError()));
    }
    ServiceController<XnioWorker> workerServiceController = (ServiceController<XnioWorker>) mainServices.getContainer().getService(IOServices.WORKER.append("default"));
    workerServiceController.setMode(ServiceController.Mode.ACTIVE);
    workerServiceController.awaitValue();
    XnioWorker worker = workerServiceController.getService().getValue();
    Assert.assertEquals(ProcessorInfo.availableProcessors() * 2, worker.getIoThreadCount());
    Assert.assertEquals(ProcessorInfo.availableProcessors() * 16, worker.getOption(Options.WORKER_TASK_MAX_THREADS).intValue());
    PathAddress addr = PathAddress.parseCLIStyleAddress("/subsystem=io/worker=default");
    ModelNode op = Util.createOperation("read-resource", addr);
    op.get("include-runtime").set(true);
    mainServices.executeOperation(op);
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:20,代碼來源:IOSubsystemTestCase.java

示例4: testRuntime

import org.wildfly.common.cpu.ProcessorInfo; //導入依賴的package包/類
@Test
public void testRuntime() throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization())
            .setSubsystemXml(getSubsystemXml());
    KernelServices mainServices = builder.build();
    if (!mainServices.isSuccessfulBoot()) {
        Assert.fail(mainServices.getBootError().toString());
    }
    ServiceController<XnioWorker> workerServiceController = (ServiceController<XnioWorker>) mainServices.getContainer().getService(IOServices.WORKER.append("default"));
    workerServiceController.setMode(ServiceController.Mode.ACTIVE);
    workerServiceController.awaitValue();
    XnioWorker worker = workerServiceController.getService().getValue();
    Assert.assertEquals(ProcessorInfo.availableProcessors() * 2, worker.getIoThreadCount());
    Assert.assertEquals(ProcessorInfo.availableProcessors() * 16, worker.getOption(Options.WORKER_TASK_MAX_THREADS).intValue());
    PathAddress addr = PathAddress.parseCLIStyleAddress("/subsystem=io/worker=default");
    ModelNode op = Util.createOperation("read-resource", addr);
    op.get("include-runtime").set(true);
    mainServices.executeOperation(op);
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:20,代碼來源:IOSubsystem11TestCase.java

示例5: applyDefaults

import org.wildfly.common.cpu.ProcessorInfo; //導入依賴的package包/類
public BatchFraction applyDefaults() {
    final InMemoryJobRepository<?> jobRepository = new InMemoryJobRepository<>(DEFAULT_JOB_REPOSITORY_NAME);

    // Default thread-pool
    final ThreadPool<?> threadPool = new ThreadPool<>(DEFAULT_THREAD_POOL_NAME);
    threadPool.maxThreads(ProcessorInfo.availableProcessors())
            .keepaliveTime("time", "30")
            .keepaliveTime("unit", "seconds");

    return inMemoryJobRepository(jobRepository)
            .defaultJobRepository(jobRepository.getKey())
            .threadPool(threadPool)
            .defaultThreadPool(threadPool.getKey());
}
 
開發者ID:wildfly-swarm,項目名稱:wildfly-swarm,代碼行數:15,代碼來源:BatchFraction.java

示例6: createCPUNode

import org.wildfly.common.cpu.ProcessorInfo; //導入依賴的package包/類
/**
 * Create a ModelNode representing the CPU the instance is running on.
 *
 * @return a ModelNode representing the CPU the instance is running on.
 * @throws OperationFailedException
 */
private ModelNode createCPUNode() throws OperationFailedException {
    ModelNode cpu = new ModelNode().setEmptyObject();
    cpu.get(ARCH).set(getProperty("os.arch"));
    cpu.get(AVAILABLE_PROCESSORS).set(ProcessorInfo.availableProcessors());
    return cpu;
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:13,代碼來源:AbstractInstallationReporter.java

示例7: testRuntime

import org.wildfly.common.cpu.ProcessorInfo; //導入依賴的package包/類
@Test
public void testRuntime() throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization())
            .setSubsystemXml(getSubsystemXml());
    KernelServices mainServices = builder.build();
    if (!mainServices.isSuccessfulBoot()) {
        Assert.fail(mainServices.getBootError().toString());
    }
    ServiceController<XnioWorker> workerServiceController = (ServiceController<XnioWorker>) mainServices.getContainer().getService(IOServices.WORKER.append("default"));
    workerServiceController.setMode(ServiceController.Mode.ACTIVE);
    workerServiceController.awaitValue();
    XnioWorker worker = workerServiceController.getService().getValue();
    Assert.assertEquals(ProcessorInfo.availableProcessors() * 2, worker.getIoThreadCount());
    Assert.assertEquals(ProcessorInfo.availableProcessors() * 16, worker.getOption(Options.WORKER_TASK_MAX_THREADS).intValue());
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:16,代碼來源:IOSubsystem10TestCase.java

示例8: getScaledCount

import org.wildfly.common.cpu.ProcessorInfo; //導入依賴的package包/類
private static int getScaledCount(BigDecimal count, BigDecimal perCpu) {
    return count.add(perCpu.multiply(BigDecimal.valueOf((long) ProcessorInfo.availableProcessors()), MathContext.DECIMAL64), MathContext.DECIMAL64).round(MathContext.DECIMAL64).intValueExact();
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:4,代碼來源:ThreadsParser.java

示例9: getCpuCount

import org.wildfly.common.cpu.ProcessorInfo; //導入依賴的package包/類
private static int getCpuCount(){
    return ProcessorInfo.availableProcessors();
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:4,代碼來源:WorkerAdd.java


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