quinta-feira, 13 de outubro de 2016

Library for configuration management from Netflix

Archaius is the Netflix client side configuration library. It is the library used by all of the Netflix OSS components for configuration. 

It is an extension of the Apache Commons Configuration project. It allows updates to configuration by either polling a source for changes or for a source to push changes to the client. Archaius uses Dynamic Property classes as handles to properties.

Some Archaius features: 
  • Dynamic, Typed Properties
  • High throughput and Thread Safe Configuration operations
  • A polling framework that allows obtaining property changes of a Configuration Source
  • A Callback mechanism that gets invoked on effective
  • A JMX MBean that can be accessed via JConsole to inspect and invoke operations on properties
  • Out of the box, Composite Configurations for applications
  • Implementations of dynamic configuration sources for URLs, JDBC and Amazon DynamoDB
  • Scala dynamic property wrappers

In my sample I will show how use Dynamic Properties and how is could be used Archaius with configuration with many environments.



About ArchaiusSandBox class:
  • Set default configuration with property archaius.properties 
  • installConfig is a method that apply config, with polling to each 1 second 
  • In set environment we will get value from "environment" variable, we expected in this case DEV or TEST
  • In the main method, we call the configuration to get "myprop"
    • it is possible put default configuration to property, I defined "NOT FOUND" but is possible put any value.
    • waiting 10 seconds to put new configuration and call again 







Resources folder. There are 3 properties:
  • archaius.properties is the default configuration with  reference to configuration available per environment
  • archaius-dev.properties configuration specific to DEV
  • archaius-test configuration specific to TEST













In runtime is possible change property, to work in this sample, should be added on archaius.properties (within 10 seconds) the property myprop=TEST-VALUE.

After 10 seconds put in main method it should printed the new value.

In this post I used some archaius functionalities, there are many others available. But with these few codes is possible create configuration to many environments with possibility to change in runtime.




References:


Nenhum comentário:

Postar um comentário

Observação: somente um membro deste blog pode postar um comentário.