forked from Netflix/ribbon
-
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.
configuration: Decouple static archaius
**Motivation** Ribbon makes heavy use of Archaius in a static manner for configuration. This pattern couple Ribbon with legacy archaius and its dependencies and makes it hard to run tests in parallel. By decoupling from both archaius and statics users can now provide alternative configuration mechanisms as well as improve testability. **Changes** - Introduce a new DynamicPropertyRepository abstraction to decouple from Archaius specific APIs - For legacy support make the ArchaiusDynamicPropertyRepository discoverable via the service loader. - Allow a non-static DynamicPropertyRepository to be associated with a IClientConfig. This is a bit of a hack but minimizes code changes. - Decouple all build.gradle dependencies from archaius, except for the ribbon-archaius subproject - Pick up @zone from DynamicPropertyRepository and NOT from archaius's DeploymentContext - Remove configuration for PollingServerListUpdater as it is not used and would always require static configuration
- Loading branch information
Showing
53 changed files
with
1,121 additions
and
1,066 deletions.
There are no files selected for viewing
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
755 changes: 424 additions & 331 deletions
755
ribbon-archaius/src/main/java/com/netflix/client/config/DefaultClientConfigImpl.java
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,9 +1,10 @@ | ||
dependencies { | ||
compile 'org.slf4j:slf4j-api:1.6.4' | ||
compile "org.slf4j:slf4j-api:${slf4j_version}" | ||
compile 'com.google.code.findbugs:annotations:2.0.0' | ||
compile "com.google.guava:guava:${guava_version}" | ||
compile 'commons-lang:commons-lang:2.6' | ||
|
||
testCompile 'junit:junit:4.11' | ||
testCompile "org.slf4j:slf4j-log4j12:${slf4j_version}" | ||
testCompile project(":ribbon-archaius") | ||
} |
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
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
34 changes: 34 additions & 0 deletions
34
ribbon-core/src/main/java/com/netflix/client/config/Property.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,34 @@ | ||
package com.netflix.client.config; | ||
|
||
import java.util.function.Consumer; | ||
|
||
/** | ||
* Ribbon specific encapsulation of a dynamic configuration property | ||
* @param <T> | ||
*/ | ||
public interface Property<T> { | ||
/** | ||
* Register a consumer to be called when the configuration changes | ||
* @param consumer | ||
*/ | ||
void onChange(Consumer<T> consumer); | ||
|
||
/** | ||
* @return Get the current value or default value | ||
*/ | ||
T get(); | ||
|
||
static <T> Property<T> of(T value) { | ||
return new Property<T>() { | ||
@Override | ||
public void onChange(Consumer<T> consumer) { | ||
|
||
} | ||
|
||
@Override | ||
public T get() { | ||
return value; | ||
} | ||
}; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
ribbon-core/src/main/java/com/netflix/client/config/UnboxedIntProperty.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,19 @@ | ||
package com.netflix.client.config; | ||
|
||
public class UnboxedIntProperty { | ||
private volatile int value; | ||
|
||
public UnboxedIntProperty(Property<Integer> delegate) { | ||
this.value = delegate.get(); | ||
|
||
delegate.onChange(newValue -> this.value = newValue); | ||
} | ||
|
||
public UnboxedIntProperty(int constantValue) { | ||
this.value = constantValue; | ||
} | ||
|
||
public int get() { | ||
return value; | ||
} | ||
} |
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: 0 additions & 29 deletions
29
ribbon-eureka/src/main/java/com/netflix/niws/loadbalancer/DefaultNIWSServerListFilter.java
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
log4j.rootCategory=INFO,stdout | ||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender | ||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.stdout.layout.ConversionPattern=%d %-5p %C:%L [%t] [%M] %m%n |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
dependencies { | ||
compile project(':ribbon-core') | ||
compile project(':ribbon-archaius') | ||
compile project(':ribbon-loadbalancer') | ||
compile 'commons-collections:commons-collections:3.2.2' | ||
compile 'org.apache.httpcomponents:httpclient:4.2.1' | ||
compile 'com.google.code.findbugs:annotations:2.0.0' | ||
compile "com.sun.jersey:jersey-client:${jersey_version}" | ||
compile "com.sun.jersey.contribs:jersey-apache-client4:${jersey_version}" | ||
compile 'org.slf4j:slf4j-api:1.6.4' | ||
compile "org.slf4j:slf4j-api:${slf4j_version}" | ||
compile "com.netflix.servo:servo-core:${servo_version}" | ||
compile "com.google.guava:guava:${guava_version}" | ||
compile "com.netflix.archaius:archaius-core:${archaius_version}" | ||
compile 'com.netflix.netflix-commons:netflix-commons-util:0.1.1' | ||
testCompile 'junit:junit:4.11' | ||
testCompile 'org.slf4j:slf4j-log4j12:1.7.2' | ||
testCompile "org.slf4j:slf4j-log4j12:${slf4j_version}" | ||
testCompile 'commons-io:commons-io:2.0.1' | ||
testCompile "com.sun.jersey:jersey-server:${jersey_version}" | ||
testCompile 'com.google.mockwebserver:mockwebserver:20130505' | ||
testCompile project(':ribbon-archaius') | ||
testCompile project(":ribbon-loadbalancer").sourceSets.test.output | ||
} |
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
Oops, something went wrong.