热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

com.netflix.hystrix.HystrixThreadPoolProperties.coreSize()方法的使用及代码示例

本文整理了Java中com.netflix.hystrix.HystrixThreadPoolProperties.coreSize()方法的一些代码示例,展示了

本文整理了Java中com.netflix.hystrix.HystrixThreadPoolProperties.coreSize()方法的一些代码示例,展示了HystrixThreadPoolProperties.coreSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HystrixThreadPoolProperties.coreSize()方法的具体详情如下:
包路径:com.netflix.hystrix.HystrixThreadPoolProperties
类名称:HystrixThreadPoolProperties
方法名:coreSize

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 //if user sets maximum dynamicMaximumSize = dynamicCoreSize;
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 workQueue = getBlockingQueue(maxQueueSize);
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 * @return actually configured maximum size of threadpool
*/
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());
}

推荐阅读
  • Android 构建基础流程详解
    Android 构建基础流程详解 ... [详细]
  • Hadoop的文件操作位于包org.apache.hadoop.fs里面,能够进行新建、删除、修改等操作。比较重要的几个类:(1)Configurati ... [详细]
  • 本文节选自《NLTK基础教程——用NLTK和Python库构建机器学习应用》一书的第1章第1.2节,作者Nitin Hardeniya。本文将带领读者快速了解Python的基础知识,为后续的机器学习应用打下坚实的基础。 ... [详细]
  • JVM钩子函数的应用场景详解
    本文详细介绍了JVM钩子函数的多种应用场景,包括正常关闭、异常关闭和强制关闭。通过具体示例和代码演示,帮助读者更好地理解和应用这一机制。适合对Java编程和JVM有一定基础的开发者阅读。 ... [详细]
  • 本文详细介绍了Java反射机制的基本概念、获取Class对象的方法、反射的主要功能及其在实际开发中的应用。通过具体示例,帮助读者更好地理解和使用Java反射。 ... [详细]
  • DAO(Data Access Object)模式是一种用于抽象和封装所有对数据库或其他持久化机制访问的方法,它通过提供一个统一的接口来隐藏底层数据访问的复杂性。 ... [详细]
  • 本文详细介绍了在 CentOS 7 系统中配置 fstab 文件以实现开机自动挂载 NFS 共享目录的方法,并解决了常见的配置失败问题。 ... [详细]
  • com.sun.javadoc.PackageDoc.exceptions()方法的使用及代码示例 ... [详细]
  • 本文介绍如何使用 Python 的 DOM 和 SAX 方法解析 XML 文件,并通过示例展示了如何动态创建数据库表和处理大量数据的实时插入。 ... [详细]
  • 原文网址:https:www.cnblogs.comysoceanp7476379.html目录1、AOP什么?2、需求3、解决办法1:使用静态代理4 ... [详细]
  • com.hazelcast.config.MapConfig.isStatisticsEnabled()方法的使用及代码示例 ... [详细]
  • 本文介绍了如何利用Shell脚本高效地部署MHA(MySQL High Availability)高可用集群。通过详细的脚本编写和配置示例,展示了自动化部署过程中的关键步骤和注意事项。该方法不仅简化了集群的部署流程,还提高了系统的稳定性和可用性。 ... [详细]
  • NOIP2000的单词接龙问题与常见的成语接龙游戏有异曲同工之妙。题目要求在给定的一组单词中,从指定的起始字母开始,构建最长的“单词链”。每个单词在链中最多可出现两次。本文将详细解析该题目的解法,并分享学习过程中的心得体会。 ... [详细]
  • 在Android开发中,实现多点触控功能需要使用`OnTouchListener`监听器来捕获触摸事件,并在`onTouch`方法中进行详细的事件处理。为了优化多点触控的交互体验,开发者可以通过识别不同的触摸手势(如缩放、旋转等)并进行相应的逻辑处理。此外,还可以结合`MotionEvent`类提供的方法,如`getPointerCount()`和`getPointerId()`,来精确控制每个触点的行为,从而提升用户操作的流畅性和响应性。 ... [详细]
  • Java环境中Selenium Chrome驱动在大规模Web应用扩展时的性能限制分析 ... [详细]
author-avatar
dotagod12
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有