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 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

你可能感兴趣的:(Hadoop conf 常用类说明)