当前位置: 首页>>代码示例>>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;未经允许,请勿转载。