Skip to content

Commit

Permalink
added test case for setting metrics.rollingStats; updated README; rem…
Browse files Browse the repository at this point in the history
…oved unused code
  • Loading branch information
Zhang Yuhan committed Oct 22, 2014
1 parent 3d9ef19 commit 9acbd36
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions hystrix-contrib/hystrix-javanica/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ ThreadPoolProperties can be set using @HystrixCommand's 'threadPoolProperties' l
@HystrixProperty(name = "coreSize", value = "30"),
@HystrixProperty(name = "maxQueueSize", value = "101"),
@HystrixProperty(name = "keepAliveTimeMinutes", value = "2"),
@HystrixProperty(name = "metricsRollingStatisticalWindowBuckets", value = "12"),
@HystrixProperty(name = "queueSizeRejectionThreshold", value = "15"),
@HystrixProperty(name = "metricsRollingStatisticalWindowInMilliseconds", value = "1440")
@HystrixProperty(name = "metrics.rollingStats.numBuckets", value = "12"),
@HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "1440")
})
public User getUserById(String id) {
return userResource.getUserById(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public static void initializeThreadPoolProperties(HystrixCommand hystrixCommand)

HystrixProperty[] properties = hystrixCommand.threadPoolProperties();
for(HystrixProperty property : properties) {
Integer value = Integer.parseInt(property.value());
String name = String.format("hystrix.threadpool.%s.%s", threadPoolKey, property.name());
ConfigurationManager.getConfigInstance().setProperty(name, property.value());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
import com.netflix.hystrix.HystrixThreadPoolProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.netflix.hystrix.contrib.javanica.command.AbstractHystrixCommand;
import com.netflix.hystrix.contrib.javanica.test.spring.conf.AopCglibConfig;
import com.netflix.hystrix.contrib.javanica.test.spring.domain.User;
import com.netflix.hystrix.strategy.concurrency.HystrixRequestContext;
import com.netflix.hystrix.strategy.properties.HystrixPropertiesThreadPoolDefault;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -61,8 +60,8 @@ public void testGetUser() throws NoSuchFieldException, IllegalAccessException {
assertEquals(101, (int) properties.maxQueueSize().get());
assertEquals(2, (int) properties.keepAliveTimeMinutes().get());
assertEquals(15, (int) properties.queueSizeRejectionThreshold().get());
//assertEquals(1440, (int) properties.metricsRollingStatisticalWindowInMilliseconds().get()); // TODO: won't be set. make this work.
//assertEquals(12, (int) properties.metricsRollingStatisticalWindowBuckets().get());
assertEquals(1440, (int) properties.metricsRollingStatisticalWindowInMilliseconds().get());
assertEquals(12, (int) properties.metricsRollingStatisticalWindowBuckets().get());
} finally {
context.shutdown();
}
Expand Down Expand Up @@ -97,9 +96,9 @@ public static class UserService {
@HystrixProperty(name = "coreSize", value = "30"),
@HystrixProperty(name = "maxQueueSize", value = "101"),
@HystrixProperty(name = "keepAliveTimeMinutes", value = "2"),
@HystrixProperty(name = "metricsRollingStatisticalWindowBuckets", value = "12"),
@HystrixProperty(name = "metrics.rollingStats.numBuckets", value = "12"),
@HystrixProperty(name = "queueSizeRejectionThreshold", value = "15"),
@HystrixProperty(name = "metricsRollingStatisticalWindowInMilliseconds", value = "1440")
@HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "1440")
})
public User getUser(String id, String name) {
return new User(id, name + id); // it should be network call
Expand Down

0 comments on commit 9acbd36

Please sign in to comment.