本文整理了Java中com.netflix.hystrix.HystrixThreadPoolProperties.coreSize()
方法的一些代码示例,展示了HystrixThreadPoolProperties.coreSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HystrixThreadPoolProperties.coreSize()
方法的具体详情如下:
包路径:com.netflix.hystrix.HystrixThreadPoolProperties
类名称:HystrixThreadPoolProperties
方法名:coreSize
[英]Core thread-pool size that gets passed to ThreadPoolExecutor#setCorePoolSize(int)
[中]传递给ThreadPoolExecutor的核心线程池大小35; setCorePoolSize(int)
代码示例来源:origin: PipelineAI/pipeline
@Override
public Number getValue() {
return properties.coreSize().get();
}
});
代码示例来源:origin: PipelineAI/pipeline
private void touchConfig() {
final int dynamicCoreSize = properties.coreSize().get();
final int cOnfiguredMaximumSize= properties.maximumSize().get();
int dynamicMaximumSize = properties.actualMaximumSize();
final boolean allowSizesToDiverge = properties.getAllowMaximumSizeToDivergeFromCoreSize().get();
boolean maxTooLow = false;
if (allowSizesToDiverge && configuredMaximumSize
maxTooLow = true;
}
// In JDK 6, setCorePoolSize and setMaximumPoolSize will execute a lock operation. Avoid them if the pool size is not changed.
if (threadPool.getCorePoolSize() != dynamicCoreSize || (allowSizesToDiverge && threadPool.getMaximumPoolSize() != dynamicMaximumSize)) {
if (maxTooLow) {
logger.error("Hystrix ThreadPool configuration for : " + metrics.getThreadPoolKey().name() + " is trying to set coreSize = " +
dynamicCoreSize + " and maximumSize = " + configuredMaximumSize + ". Maximum size will be set to " +
dynamicMaximumSize + ", the coreSize value, since it must be equal to or greater than the coreSize value");
}
threadPool.setCorePoolSize(dynamicCoreSize);
threadPool.setMaximumPoolSize(dynamicMaximumSize);
}
threadPool.setKeepAliveTime(properties.keepAliveTimeMinutes().get(), TimeUnit.MINUTES);
}
代码示例来源:origin: PipelineAI/pipeline
public ThreadPoolExecutor getThreadPool(final HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolProperties threadPoolProperties) {
final ThreadFactory threadFactory = getThreadFactory(threadPoolKey);
final boolean allowMaximumSizeToDivergeFromCoreSize = threadPoolProperties.getAllowMaximumSizeToDivergeFromCoreSize().get();
final int dynamicCoreSize = threadPoolProperties.coreSize().get();
final int keepAliveTime = threadPoolProperties.keepAliveTimeMinutes().get();
final int maxQueueSize = threadPoolProperties.maxQueueSize().get();
final BlockingQueue
if (allowMaximumSizeToDivergeFromCoreSize) {
final int dynamicMaximumSize = threadPoolProperties.maximumSize().get();
if (dynamicCoreSize > dynamicMaximumSize) {
logger.error("Hystrix ThreadPool configuration at startup for : " + threadPoolKey.name() + " is trying to set coreSize = " +
dynamicCoreSize + " and maximumSize = " + dynamicMaximumSize + ". Maximum size will be set to " +
dynamicCoreSize + ", the coreSize value, since it must be equal to or greater than the coreSize value");
return new ThreadPoolExecutor(dynamicCoreSize, dynamicCoreSize, keepAliveTime, TimeUnit.MINUTES, workQueue, threadFactory);
} else {
return new ThreadPoolExecutor(dynamicCoreSize, dynamicMaximumSize, keepAliveTime, TimeUnit.MINUTES, workQueue, threadFactory);
}
} else {
return new ThreadPoolExecutor(dynamicCoreSize, dynamicCoreSize, keepAliveTime, TimeUnit.MINUTES, workQueue, threadFactory);
}
}
代码示例来源:origin: PipelineAI/pipeline
/**
* Given all of the thread pool configuration, what is the actual maximumSize applied to the thread pool
* via {@link ThreadPoolExecutor#setMaximumPoolSize(int)}
*
* Cases:
* 1) allowMaximumSizeToDivergeFromCoreSize == false: maximumSize is set to coreSize
* 2) allowMaximumSizeToDivergeFromCoreSize == true, maximumSize >= coreSize: thread pool has different core/max sizes, so return the configured max
* 3) allowMaximumSizeToDivergeFromCoreSize == true, maximumSize
*/
public Integer actualMaximumSize() {
final int coreSize = coreSize().get();
final int maximumSize = maximumSize().get();
if (getAllowMaximumSizeToDivergeFromCoreSize().get()) {
if (coreSize > maximumSize) {
return coreSize;
} else {
return maximumSize;
}
} else {
return coreSize;
}
}
代码示例来源:origin: PipelineAI/pipeline
@Test
public void testSetNeitherCoreNorMaximumSizeWithDivergenceDisallowed() {
HystrixThreadPoolProperties properties = new HystrixThreadPoolProperties(TestThreadPoolKey.TEST,
HystrixThreadPoolProperties.Setter()
.withAllowMaximumSizeToDivergeFromCoreSize(false)) {
};
assertEquals(HystrixThreadPoolProperties.default_coreSize, properties.coreSize().get().intValue());
assertEquals(HystrixThreadPoolProperties.default_maximumSize, properties.maximumSize().get().intValue());
assertEquals(HystrixThreadPoolProperties.default_coreSize, (int) properties.actualMaximumSize());
}
代码示例来源:origin: PipelineAI/pipeline
@Test
public void testSetNeitherCoreNorMaximumSizeWithDivergenceAllowed() {
HystrixThreadPoolProperties properties = new HystrixThreadPoolProperties(TestThreadPoolKey.TEST,
HystrixThreadPoolProperties.Setter()
.withAllowMaximumSizeToDivergeFromCoreSize(true)) {
};
assertEquals(HystrixThreadPoolProperties.default_coreSize, properties.coreSize().get().intValue());
assertEquals(HystrixThreadPoolProperties.default_maximumSize, properties.maximumSize().get().intValue());
assertEquals(HystrixThreadPoolProperties.default_maximumSize, (int) properties.actualMaximumSize());
}
代码示例来源:origin: PipelineAI/pipeline
@Test
public void testSetCoreSizeOnlyWithDivergenceAllowed() {
HystrixThreadPoolProperties properties = new HystrixThreadPoolProperties(TestThreadPoolKey.TEST,
HystrixThreadPoolProperties.Setter()
.withCoreSize(14)
.withAllowMaximumSizeToDivergeFromCoreSize(true)) {
};
assertEquals(14, properties.coreSize().get().intValue());
assertEquals(HystrixThreadPoolProperties.default_maximumSize, properties.maximumSize().get().intValue());
assertEquals(14, (int) properties.actualMaximumSize());
}
代码示例来源:origin: PipelineAI/pipeline
@Test
public void testSetMaximumSizeOnlyLowerThanDefaultCoreSizeWithDivergenceAllowed() {
HystrixThreadPoolProperties properties = new HystrixThreadPoolProperties(TestThreadPoolKey.TEST,
HystrixThreadPoolProperties.Setter()
.withMaximumSize(3)
.withAllowMaximumSizeToDivergeFromCoreSize(true)) {
};
assertEquals(HystrixThreadPoolProperties.default_coreSize, properties.coreSize().get().intValue());
assertEquals(3, properties.maximumSize().get().intValue());
assertEquals(HystrixThreadPoolProperties.default_coreSize, (int) properties.actualMaximumSize());
}
代码示例来源:origin: PipelineAI/pipeline
@Test
public void testSetCoreSizeOnlyWithDivergenceDisallowed() {
HystrixThreadPoolProperties properties = new HystrixThreadPoolProperties(TestThreadPoolKey.TEST,
HystrixThreadPoolProperties.Setter()
.withCoreSize(14)
.withAllowMaximumSizeToDivergeFromCoreSize(false)) {
};
assertEquals(14, properties.coreSize().get().intValue());
assertEquals(HystrixThreadPoolProperties.default_maximumSize, properties.maximumSize().get().intValue());
assertEquals(14, (int) properties.actualMaximumSize());
}
代码示例来源:origin: PipelineAI/pipeline
@Test
public void testSetMaximumSizeOnlyLowerThanDefaultCoreSizeWithDivergenceDisallowed() {
HystrixThreadPoolProperties properties = new HystrixThreadPoolProperties(TestThreadPoolKey.TEST,
HystrixThreadPoolProperties.Setter()
.withMaximumSize(3)
.withAllowMaximumSizeToDivergeFromCoreSize(false)) {
};
assertEquals(HystrixThreadPoolProperties.default_coreSize, properties.coreSize().get().intValue());
assertEquals(3, properties.maximumSize().get().intValue());
assertEquals(HystrixThreadPoolProperties.default_coreSize, (int) properties.actualMaximumSize());
}
代码示例来源:origin: PipelineAI/pipeline
@Test
public void testSetMaximumSizeOnlyGreaterThanDefaultCoreSizeWithDivergenceDisallowed() {
HystrixThreadPoolProperties properties = new HystrixThreadPoolProperties(TestThreadPoolKey.TEST,
HystrixThreadPoolProperties.Setter()
.withMaximumSize(21)
.withAllowMaximumSizeToDivergeFromCoreSize(false)) {
};
assertEquals(HystrixThreadPoolProperties.default_coreSize, properties.coreSize().get().intValue());
assertEquals(21, properties.maximumSize().get().intValue());
assertEquals(HystrixThreadPoolProperties.default_coreSize, (int) properties.actualMaximumSize());
}
代码示例来源:origin: PipelineAI/pipeline
@Test
public void testSetMaximumSizeOnlyGreaterThanDefaultCoreSizeWithDivergenceAllowed() {
HystrixThreadPoolProperties properties = new HystrixThreadPoolProperties(TestThreadPoolKey.TEST,
HystrixThreadPoolProperties.Setter()
.withMaximumSize(21)
.withAllowMaximumSizeToDivergeFromCoreSize(true)) {
};
assertEquals(HystrixThreadPoolProperties.default_coreSize, properties.coreSize().get().intValue());
assertEquals(21, properties.maximumSize().get().intValue());
assertEquals(21, (int) properties.actualMaximumSize());
}
代码示例来源:origin: PipelineAI/pipeline
@Test
public void testSetCoreSizeLessThanMaximumSizeWithDivergenceDisallowed() {
HystrixThreadPoolProperties properties = new HystrixThreadPoolProperties(TestThreadPoolKey.TEST,
HystrixThreadPoolProperties.Setter()
.withCoreSize(2)
.withMaximumSize(8)
.withAllowMaximumSizeToDivergeFromCoreSize(false)) {
};
assertEquals(2, properties.coreSize().get().intValue());
assertEquals(8, properties.maximumSize().get().intValue());
assertEquals(2, (int) properties.actualMaximumSize());
}
代码示例来源:origin: PipelineAI/pipeline
@Test
public void testSetCoreSizeLessThanMaximumSizeWithDivergenceAllowed() {
HystrixThreadPoolProperties properties = new HystrixThreadPoolProperties(TestThreadPoolKey.TEST,
HystrixThreadPoolProperties.Setter()
.withCoreSize(2)
.withMaximumSize(8)
.withAllowMaximumSizeToDivergeFromCoreSize(true)) {
};
assertEquals(2, properties.coreSize().get().intValue());
assertEquals(8, properties.maximumSize().get().intValue());
assertEquals(8, (int) properties.actualMaximumSize());
}
代码示例来源:origin: PipelineAI/pipeline
@Test
public void testSetCoreSizeGreaterThanMaximumSizeWithDivergenceDisallowed() {
HystrixThreadPoolProperties properties = new HystrixThreadPoolProperties(TestThreadPoolKey.TEST,
HystrixThreadPoolProperties.Setter()
.withCoreSize(12)
.withMaximumSize(8)
.withAllowMaximumSizeToDivergeFromCoreSize(false)) {
};
assertEquals(12, properties.coreSize().get().intValue());
assertEquals(8, properties.maximumSize().get().intValue());
assertEquals(12, (int) properties.actualMaximumSize());
}
代码示例来源:origin: PipelineAI/pipeline
@Test
public void testSetCoreSizeEqualToMaximumSizeDivergenceDisallowed() {
HystrixThreadPoolProperties properties = new HystrixThreadPoolProperties(TestThreadPoolKey.TEST,
HystrixThreadPoolProperties.Setter()
.withCoreSize(7)
.withMaximumSize(7)
.withAllowMaximumSizeToDivergeFromCoreSize(false)) {
};
assertEquals(7, properties.coreSize().get().intValue());
assertEquals(7, properties.maximumSize().get().intValue());
assertEquals(7, (int) properties.actualMaximumSize());
}
代码示例来源:origin: PipelineAI/pipeline
@Test
public void testSetCoreSizeEqualToMaximumSizeDivergenceAllowed() {
HystrixThreadPoolProperties properties = new HystrixThreadPoolProperties(TestThreadPoolKey.TEST,
HystrixThreadPoolProperties.Setter()
.withCoreSize(7)
.withMaximumSize(7)
.withAllowMaximumSizeToDivergeFromCoreSize(true)) {
};
assertEquals(7, properties.coreSize().get().intValue());
assertEquals(7, properties.maximumSize().get().intValue());
assertEquals(7, (int) properties.actualMaximumSize());
}
代码示例来源:origin: PipelineAI/pipeline
@Test
public void testSetCoreSizeGreaterThanMaximumSizeWithDivergenceAllowed() {
HystrixThreadPoolProperties properties = new HystrixThreadPoolProperties(TestThreadPoolKey.TEST,
HystrixThreadPoolProperties.Setter()
.withCoreSize(12)
.withMaximumSize(8)
.withAllowMaximumSizeToDivergeFromCoreSize(true)) {
};
assertEquals(12, properties.coreSize().get().intValue());
assertEquals(8, properties.maximumSize().get().intValue());
assertEquals(12, (int) properties.actualMaximumSize());
}
}
代码示例来源:origin: PipelineAI/pipeline
private HystrixThreadPoolConfiguration(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolProperties threadPoolProperties) {
this(threadPoolKey, threadPoolProperties.coreSize().get(),
threadPoolProperties.maximumSize().get(), threadPoolProperties.actualMaximumSize(),
threadPoolProperties.maxQueueSize().get(), threadPoolProperties.queueSizeRejectionThreshold().get(),
threadPoolProperties.keepAliveTimeMinutes().get(), threadPoolProperties.getAllowMaximumSizeToDivergeFromCoreSize().get(),
threadPoolProperties.metricsRollingStatisticalWindowBuckets().get(),
threadPoolProperties.metricsRollingStatisticalWindowInMilliseconds().get());
}
代码示例来源:origin: PipelineAI/pipeline
@Test
public void testGetUser() throws NoSuchFieldException, IllegalAccessException {
User u1 = userService.getUser("1", "name: ");
assertEquals("name: 1", u1.getName());
assertEquals(1, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
HystrixInvokableInfo> command = HystrixRequestLog.getCurrentRequest()
.getAllExecutedCommands().iterator().next();
assertEquals("GetUserCommand", command.getCommandKey().name());
assertEquals("UserGroupKey", command.getCommandGroup().name());
assertEquals("Test", command.getThreadPoolKey().name());
assertTrue(command.getExecutionEvents().contains(HystrixEventType.SUCCESS));
// assert properties
assertEquals(110, command.getProperties().executionTimeoutInMilliseconds().get().intValue());
assertEquals(false, command.getProperties().executionIsolationThreadInterruptOnTimeout().get());
HystrixThreadPoolProperties properties = getThreadPoolProperties(command);
assertEquals(30, (int) properties.coreSize().get());
assertEquals(35, (int) properties.maximumSize().get());
assertEquals(true, properties.getAllowMaximumSizeToDivergeFromCoreSize().get());
assertEquals(101, (int) properties.maxQueueSize().get());
assertEquals(2, (int) properties.keepAliveTimeMinutes().get());
assertEquals(15, (int) properties.queueSizeRejectionThreshold().get());
assertEquals(1440, (int) properties.metricsRollingStatisticalWindowInMilliseconds().get());
assertEquals(12, (int) properties.metricsRollingStatisticalWindowBuckets().get());
}