archaius是什么,能做什么?
archaius是Netflix公司开源项目之一,基于java的配置管理类库,主要用于多配置存储的动态获取。主要功能是对apache common configuration类库的扩展。在云平台开发中可以将其用作分布式配置管理依赖构件。同时,它有如下一些特性:
- 动态类型化属性
- 高效和线程安全的配置操作
- 配置改变时的回调机制
- jmx
- 组合配置(核心内容)
At the heart of Archaius is the concept of a Composite Configuration which can hold one or more Configurations. Each Configuration can be sourced from a Configuration Source such as: JDBC, REST, .properties file etc. Configuration Sources can optionally be polled at runtime for changes (In the above diagram, the Persisted DB Configuration Source; an RDBMS containing properties in a table, is polled every so often for changes).
The final value of a property is determined based on the top most Configuration that contains that property. i.e. If a property is present in multiple configurations, the actual value seen by the application will be the value that is present in the topmost slot in the hierarchy of Configurations. The hierarchy can be configured.
动态属性(Dynamic properties)
String prop = System.getProperty("myProperty");
int x = DEFAULT_VALUE;
try {
x = Integer.parseInt(prop);
} catch (NumberFormatException e) {
// handle format issues
}
myMethod(x);
// ...
更简洁的方式
DynamicIntProperty prop =
DynamicPropertyFactory.getInstance().getIntProperty("myProperty", DEFAULT_VALUE);
// prop.get() may change value at runtime
myMethod(prop.get());
同时,我们可以加入事件回调
prop.addCallback(new Runnable() {
public void run() {
// ...
}
});
动态属性如何实现动态,轮询框架
使用属性来源和定时器进行轮询
PolledConfigurationSource source = createMyOwnSource();
AbstractPollingScheduler scheduler = createMyOwnScheduler();
ConfigurationManager.install(new DynamicConfiguration(source, scheduler));
目前框架核心默认实现了两种来源,JDBCConfigurationSource、URLConfigurationSource
发布上下文(Deployment context)
比如应用程序需要读取一个数据库配置文件database-*.properties,但是*可能是prod和test,我们要从中选一个,这时需要咨询发布上下文,我们可以调用发布上下文的一个方法DeploymentContext.getDeploymentEnvironment(),然后我们就可以取得实际的数据库配置文件database-${environment}.properties
Deployment context properties can be used in many ways. Archaius uses deployment context to load cascaded configuration files. Here is the use case:
Application defines a set of default properties
At runtime, those properties should be overridden by deployment context specific values.
For example, an application has a configuration file database.properties, which contains default set of database properties. It has two other properties filedatabase-prod.properties, which contains overridden values for “prod” environment
database-test.properties, which contains overridden values for “test” environment
To load any one of the above file, the ConfigurationManager will consult with DeploymentContext object set with it to determine what environment it is in (through DeploymentContext.getDeploymentEnvironment() method), and load additional database-${environment} file to override the default values.
高效和线程安全的配置
框架提供了高效和线程安全的config(apache common configuration),比如:ConcurrentMapConfiguration、ConcurrentCompositeConfiguration,支持高并发和组合配置
参考文献
https://github.com/Netflix/archaius
https://github.com/Netflix/archaius/wiki
http://www.tuicool.com/articles/uQRn6f
http://commons.apache.org/proper/commons-configuration/
http://commons.apache.org/proper/commons-configuration/userguide_v1.10/user_guide.html
http://blog.csdn.net/zhangfb95/article/details/48297907
相关推荐
spring-cloud-starter-netflix-archaius-1.4.5.RELEASE.jar
spring-cloud-netflix-archaius-2.1.0.RELEASE
spring-cloud-starter-netflix-archaius-2.1.0.RELEASE
Netflix开源面向稀疏数据优化的轻量神经网络库Vectorflow
开源项目-Netflix-Skunkworks-go-jira.zip,GitHub - Netflix-Skunkworks/go-jira: simple jira command line client in Go
开源项目-netflix-chaosmonkey.zip,Golang in production: Netflix's Chaos Monkey
TV Shows and Movies listed on Netflix This dataset consists of tv shows and movies available on Netflix as of 2019. The dataset is collected from Flixable which is a third-party Netflix search engine....
<groupId>com.netflix.archaius</groupId> <artifactId>archaius-core <version>0.7.7</version>
Netflix 4.16.1
开源项目-Netflix-rend.zip,Rend - memcached proxy in Go
著名的Netflix 智能推荐 百万美金大奖赛使用是数据集. 因为竞赛关闭, Netflix官网上已无法下载. Netflix provided a training data set of 100,480,507 ratings that 480,189 users gave to 17,770 movies. Each ...
Netflix Ribbon是Netflix发布的云中间层服务开源项目,主要功能是提供客户端的软件负载均衡算法,将Netflix的中间层服务连接在一起。 具体来说,Ribbon是一个客户端负载均衡器,可以在配置文件中列出所有的服务提供...
login-netflix:登录主题灵感来自Netflix的布局| tela de login inspirada没有布局和Netflix
Netflix 6.26.1