第三章:小朱笔记hadoop之conf分析:Reconfigurable相关

第三章:小朱笔记hadoop之conf分析 -Reconfigurable相关

       集群运行过程中有时会需要对配置进行修改,而通常需要重启才能生效,如该HDFS Namenode的一个配置,需要重启NN才能生效。而对于规模较大的系统,重启的成本较高。所以引入了一个reconfigurable机制。

       为了便于完成配置项变更,还提供了一个ReconfigurationServlet工具便于从web端变更配置。使用时只需要将该servelt加入到相应节点的httpserver中,并在context中加入conf.servlet.reconfigurable.$P的参数,值为对应的Reconfigurable实现(一般为节点自身实现),其中$P表示的是ReconfigurationServlet在httpServer中对应的path。

       (1)Reconfigurable,该接口定义了可变配置的基本操作

写道
/**
* Change a configuration property on this object to the value specified.
*
* Change a configuration property on this object to the value specified
* and return the previous value that the configuration property was set to
* (or null if it was not previously set). If newVal is null, set the property
* to its default value;
*
* If the property cannot be changed, throw a
* {@link ReconfigurationException}.
*/
public String reconfigureProperty(String property, String newVal)
throws ReconfigurationException;

/**
* Return whether a given property is changeable at run time.
*
* If isPropertyReconfigurable returns true for a property,
* then changeConf should not throw an exception when changing
* this property.
*/
public boolean isPropertyReconfigurable(String property);

 

(2)ReconfigurableBase,该基类有两个抽象方法,所有想要实现动态配置的节点,都需要实现这两个方法:

写道
/**
* {@inheritDoc}
*
* 定义该节点上所有可以进行动态配置的属性集合
*
* Subclasses must override this.
*/
@Override
public abstract Collection<String> getReconfigurableProperties();


/**
* Change a configuration property.
* 某个可以动态配置的属性变化时需要进行的处理
* Subclasses must override this. This method applies the change to
* all internal data structures derived from the configuration property
* that is being changed. If this object owns other Reconfigurable objects
* reconfigureProperty should be called recursively to make sure that
* to make sure that the configuration of these objects is updated.
*/
protected abstract void reconfigurePropertyImpl(String property, String newVal)
throws ReconfigurationException;

 

(3)ReconfigurationServlet 用于配置动态管理

 

   注意:该模块在2.2版本中并未用到。 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值