forked from Netflix/Hystrix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Netflix#1032 from tine2k/ManyHystrixTimerThreads1030
Implementation for feature request Netflix#1013
- Loading branch information
Showing
5 changed files
with
185 additions
and
13 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
hystrix-core/src/main/java/com/netflix/hystrix/HystrixTimerThreadPoolProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.netflix.hystrix; | ||
|
||
import com.netflix.hystrix.strategy.properties.HystrixPropertiesChainedArchaiusProperty; | ||
import com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy; | ||
import com.netflix.hystrix.strategy.properties.HystrixProperty; | ||
|
||
import static com.netflix.hystrix.strategy.properties.HystrixProperty.Factory.asProperty; | ||
|
||
/** | ||
* Properties for Hystrix timer thread pool. | ||
* <p> | ||
* Default implementation of methods uses Archaius (https://github.com/Netflix/archaius) | ||
*/ | ||
public abstract class HystrixTimerThreadPoolProperties { | ||
|
||
private final HystrixProperty<Integer> corePoolSize; | ||
|
||
protected HystrixTimerThreadPoolProperties() { | ||
this(new Setter().withCoreSize(Runtime.getRuntime().availableProcessors())); | ||
} | ||
|
||
protected HystrixTimerThreadPoolProperties(Setter setter) { | ||
this.corePoolSize = getProperty("hystrix", "coreSize", setter.getCoreSize()); | ||
} | ||
|
||
private static HystrixProperty<Integer> getProperty(String propertyPrefix, String instanceProperty, Integer defaultValue) { | ||
return asProperty(new HystrixPropertiesChainedArchaiusProperty.IntegerProperty( | ||
new HystrixPropertiesChainedArchaiusProperty.DynamicIntegerProperty(propertyPrefix + ".timer.threadpool.default." + instanceProperty, defaultValue))); | ||
} | ||
|
||
public HystrixProperty<Integer> getCorePoolSize() { | ||
return corePoolSize; | ||
} | ||
|
||
/** | ||
* Factory method to retrieve the default Setter. | ||
*/ | ||
public static Setter Setter() { | ||
return new Setter(); | ||
} | ||
|
||
/** | ||
* Fluent interface that allows chained setting of properties. | ||
* <p> | ||
* See {@link HystrixPropertiesStrategy} for more information on order of precedence. | ||
* <p> | ||
* Example: | ||
* <p> | ||
* <pre> {@code | ||
* HystrixTimerThreadPoolProperties.Setter() | ||
* .withCoreSize(10); | ||
* } </pre> | ||
* | ||
* @NotThreadSafe | ||
*/ | ||
public static class Setter { | ||
private Integer coreSize = null; | ||
|
||
private Setter() { | ||
} | ||
|
||
public Integer getCoreSize() { | ||
return coreSize; | ||
} | ||
|
||
public Setter withCoreSize(int value) { | ||
this.coreSize = value; | ||
return this; | ||
} | ||
|
||
/** | ||
* Base properties for unit testing. | ||
*/ | ||
/* package */ | ||
static Setter getUnitTestPropertiesBuilder() { | ||
return new Setter().withCoreSize(10); // size of thread pool | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...java/com/netflix/hystrix/strategy/properties/HystrixPropertiesTimerThreadPoolDefault.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright 2012 Netflix, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.netflix.hystrix.strategy.properties; | ||
|
||
import com.netflix.hystrix.HystrixThreadPoolKey; | ||
import com.netflix.hystrix.HystrixThreadPoolProperties; | ||
import com.netflix.hystrix.HystrixTimerThreadPoolProperties; | ||
|
||
/** | ||
* Default implementation of {@link HystrixTimerThreadPoolProperties} using Archaius (https://github.com/Netflix/archaius) | ||
* | ||
* @ExcludeFromJavadoc | ||
*/ | ||
public class HystrixPropertiesTimerThreadPoolDefault extends HystrixTimerThreadPoolProperties { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters