本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
示例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());
}
示例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;
}
示例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());
}
示例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();
}
示例9: getCpuCount
import org.wildfly.common.cpu.ProcessorInfo; //导入依赖的package包/类
private static int getCpuCount(){
return ProcessorInfo.availableProcessors();
}