use of com.netflix.hystrix.HystrixThreadPoolProperties in project Hystrix by Netflix.
the class BasicHystrixTest method getThreadPoolProperties.
protected final HystrixThreadPoolProperties getThreadPoolProperties(HystrixInvokableInfo<?> command) {
try {
Field field = command.getClass().getSuperclass().getSuperclass().getSuperclass().getDeclaredField("threadPool");
field.setAccessible(true);
HystrixThreadPool threadPool = (HystrixThreadPool) field.get(command);
Field field2 = HystrixThreadPool.HystrixThreadPoolDefault.class.getDeclaredField("properties");
field2.setAccessible(true);
return (HystrixThreadPoolProperties) field2.get(threadPool);
} catch (NoSuchFieldException e) {
throw Throwables.propagate(e);
} catch (IllegalAccessException e) {
throw Throwables.propagate(e);
}
}
use of com.netflix.hystrix.HystrixThreadPoolProperties in project Hystrix by Netflix.
the class BasicFallbackDefaultPropertiesTest method testFallbackOverridesThreadPollProperties.
@Test
public void testFallbackOverridesThreadPollProperties() {
service.commandWithFallbackOverridesDefaultProperties();
com.netflix.hystrix.HystrixInvokableInfo fallbackCommand = getHystrixCommandByKey("fallbackOverridesDefaultProperties");
HystrixThreadPoolProperties properties = getThreadPoolProperties(fallbackCommand);
assertEquals(321, properties.maxQueueSize().get().intValue());
}
use of com.netflix.hystrix.HystrixThreadPoolProperties in project Hystrix by Netflix.
the class HystrixPropertiesFactory method getThreadPoolProperties.
/**
* Get an instance of {@link HystrixThreadPoolProperties} with the given factory {@link HystrixPropertiesStrategy} implementation for each {@link HystrixThreadPool} instance.
*
* @param key
* Pass-thru to {@link HystrixPropertiesStrategy#getThreadPoolProperties} implementation.
* @param builder
* Pass-thru to {@link HystrixPropertiesStrategy#getThreadPoolProperties} implementation.
* @return {@link HystrixThreadPoolProperties} instance
*/
public static HystrixThreadPoolProperties getThreadPoolProperties(HystrixThreadPoolKey key, HystrixThreadPoolProperties.Setter builder) {
HystrixPropertiesStrategy hystrixPropertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy();
String cacheKey = hystrixPropertiesStrategy.getThreadPoolPropertiesCacheKey(key, builder);
if (cacheKey != null) {
HystrixThreadPoolProperties properties = threadPoolProperties.get(cacheKey);
if (properties != null) {
return properties;
} else {
if (builder == null) {
builder = HystrixThreadPoolProperties.Setter();
}
// create new instance
properties = hystrixPropertiesStrategy.getThreadPoolProperties(key, builder);
// cache and return
HystrixThreadPoolProperties existing = threadPoolProperties.putIfAbsent(cacheKey, properties);
if (existing == null) {
return properties;
} else {
return existing;
}
}
} else {
// no cacheKey so we generate it with caching
return hystrixPropertiesStrategy.getThreadPoolProperties(key, builder);
}
}
use of com.netflix.hystrix.HystrixThreadPoolProperties in project Hystrix by Netflix.
the class BasicCommandDefaultPropertiesTest method testCommandInheritsThreadPollProperties.
@Test
public void testCommandInheritsThreadPollProperties() {
service.commandInheritsDefaultProperties();
HystrixInvokableInfo<?> command = HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().iterator().next();
HystrixThreadPoolProperties properties = getThreadPoolProperties(command);
assertEquals(123, properties.maxQueueSize().get().intValue());
}
use of com.netflix.hystrix.HystrixThreadPoolProperties in project Hystrix by Netflix.
the class BasicCommandDefaultPropertiesTest method testCommandOverridesDefaultThreadPollProperties.
@Test
public void testCommandOverridesDefaultThreadPollProperties() {
service.commandOverridesDefaultThreadPoolProperties();
HystrixInvokableInfo<?> command = HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().iterator().next();
HystrixThreadPoolProperties properties = getThreadPoolProperties(command);
assertEquals(321, properties.maxQueueSize().get().intValue());
}
Aggregations