From 717f13bcb100480ecc4f8f5cf95a7296af9dabb8 Mon Sep 17 00:00:00 2001 From: Matt Jacobs Date: Tue, 16 May 2017 10:58:40 -0700 Subject: [PATCH] Added Javanica support for setting allowMaximumSizeToDivergeFromCoreSize in annotation --- .../contrib/javanica/conf/HystrixPropertiesManager.java | 7 +++++++ .../configuration/command/BasicCommandPropertiesTest.java | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/conf/HystrixPropertiesManager.java b/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/conf/HystrixPropertiesManager.java index 040277696..eb9296ae6 100644 --- a/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/conf/HystrixPropertiesManager.java +++ b/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/conf/HystrixPropertiesManager.java @@ -80,6 +80,7 @@ private HystrixPropertiesManager() { public static final String MAX_QUEUE_SIZE = "maxQueueSize"; public static final String CORE_SIZE = "coreSize"; public static final String MAXIMUM_SIZE = "maximumSize"; + public static final String ALLOW_MAXIMUM_SIZE_TO_DIVERGE_FROM_CORE_SIZE = "allowMaximumSizeToDivergeFromCoreSize"; public static final String KEEP_ALIVE_TIME_MINUTES = "keepAliveTimeMinutes"; public static final String QUEUE_SIZE_REJECTION_THRESHOLD = "queueSizeRejectionThreshold"; public static final String METRICS_ROLLING_STATS_NUM_BUCKETS = "metrics.rollingStats.numBuckets"; @@ -296,6 +297,12 @@ public void set(HystrixThreadPoolProperties.Setter setter, String value) { } } ) + .put(ALLOW_MAXIMUM_SIZE_TO_DIVERGE_FROM_CORE_SIZE, new PropSetter() { + @Override + public void set(HystrixThreadPoolProperties.Setter setter, String value) throws IllegalArgumentException { + setter.withAllowMaximumSizeToDivergeFromCoreSize(toBoolean(value)); + } + }) .put(KEEP_ALIVE_TIME_MINUTES, new PropSetter() { @Override public void set(HystrixThreadPoolProperties.Setter setter, String value) { diff --git a/hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/common/configuration/command/BasicCommandPropertiesTest.java b/hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/common/configuration/command/BasicCommandPropertiesTest.java index a1df10720..f3f4aff22 100644 --- a/hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/common/configuration/command/BasicCommandPropertiesTest.java +++ b/hystrix-contrib/hystrix-javanica/src/test/java/com/netflix/hystrix/contrib/javanica/test/common/configuration/command/BasicCommandPropertiesTest.java @@ -84,7 +84,8 @@ public void testGetUser() throws NoSuchFieldException, IllegalAccessException { HystrixThreadPoolProperties properties = getThreadPoolProperties(command); assertEquals(30, (int) properties.coreSize().get()); - assertEquals(25, (int) properties.maximumSize().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()); @@ -160,7 +161,8 @@ public static class UserService { }, threadPoolProperties = { @HystrixProperty(name = "coreSize", value = "30"), - @HystrixProperty(name = "maximumSize", value = "25"), + @HystrixProperty(name = "maximumSize", value = "35"), + @HystrixProperty(name = "allowMaximumSizeToDivergeFromCoreSize", value = "true"), @HystrixProperty(name = "maxQueueSize", value = "101"), @HystrixProperty(name = "keepAliveTimeMinutes", value = "2"), @HystrixProperty(name = "metrics.rollingStats.numBuckets", value = "12"),