Hadoop conf 常用类说明

Configuration:Conf核心类,加载配置
Configurable:简单的接口,定义了setConf、getConf方法
ConfigRedactor:提供了对敏感信息过滤的功能,敏感信息的pattern可以通过key:hadoop.security.sensitive-config-keys进行配置
ConfigurationWithLogging:依赖ConfigRedactor,在获取配置时,对配置进行输出以及屏蔽敏感信息
Configured:Configurable的基础实现类
ConfServlet:提供Servlet用于获取conf中的值
Reconfigurable:可变配置基础接口,提供以下三个接口
  void reconfigureProperty(String property, String newVal)
    throws ReconfigurationException;
  boolean isPropertyReconfigurable(String property);
  Collection<String> getReconfigurableProperties();
ReconfigurableBase:Reconfigurable基础实现,提供了startReconfigurationTask、shutdownReconfigurationTask、getReconfigurationTaskStatus等方法,生成ReconfigurationThread用于异步修改配置
ReconfigurationException:对一个不可变属性执行reconfigureProperty方法时,会抛出ReconfigurationException异常
ReconfigurationThread:ReconfigurableBase的内部类,继承Thread,以ReconfigurableBase为参数,对配置进行修改
  public void startReconfigurationTask() throws IOException {
    synchronized (reconfigLock) {
      if (!shouldRun) {
        String errorMessage = "The server is stopped.";
        LOG.warn(errorMessage);
        throw new IOException(errorMessage);
      }
      if (reconfigThread != null) {
        String errorMessage = "Another reconfiguration task is running.";
        LOG.warn(errorMessage);
        throw new IOException(errorMessage);
      }
      reconfigThread = new ReconfigurationThread(this);
      reconfigThread.setDaemon(true);
      reconfigThread.setName("Reconfiguration Task");
      reconfigThread.start();
      startTime = Time.now();
    }
  }
  public void shutdownReconfigurationTask() {
    Thread tempThread;
    synchronized (reconfigLock) {
      shouldRun = false;
      if (reconfigThread == null) {
        return;
      }
      tempThread = reconfigThread;
      reconfigThread = null;
    }

    try {
      tempThread.join();
    } catch (InterruptedException e) {
    }
  }
ReconfigurationTaskStatus:配置修改状态类
  public ReconfigurationTaskStatus getReconfigurationTaskStatus() {
    synchronized (reconfigLock) {
      if (reconfigThread != null) {
        return new ReconfigurationTaskStatus(startTime, 0, null);
      }
      return new ReconfigurationTaskStatus(startTime, endTime, status);
    }
  }
ReconfigurationUtil:主要提供了parseChangedProperties方法,用于解析新的配置与旧的配置
ReconfigurationServlet:提供Servlet用于动态改变配置
StorageSize、StorageUnit:存储数值的大小以及单位,可以通过Configuration:ConfgetStorageSize方法获取

转载于:https://www.cnblogs.com/tyler-jin/p/10424294.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值