sqoop_server启动过程

ServerInitializer

ServerInitializer负责初始化server. 其实现ServletContextListener,也就是在web启动的时候会进行初始化的动作。

/**
 * Initializes the Sqoop server. This listener is also responsible for
 * cleaning up any resources occupied by the server during the system shutdown.
 */
public class ServerInitializer implements ServletContextListener {

  private static final Logger LOG = Logger.getLogger(ServerInitializer.class);

  public void contextDestroyed(ServletContextEvent arg0) {
    SqoopServer.destroy();
  }

  public void contextInitialized(ServletContextEvent arg0) {
    try {
      SqoopServer.initialize();
    } catch (Throwable ex) {
      // We are assuming that by default we are running as the only app inside
      // the tomcat and hence we want to try kill entire tomcat on our load failure.
      if("true".equals(System.getProperty(ConfigurationConstants.KILL_TOMCAT_ON_FAILURE, "true"))) {
        LOG.error("Sqoop server failed to start", ex);
        System.exit(1);
      }

      throw new RuntimeException("Sqoop server failed to start.", ex);
    }
  }
}

sqoop_server的源代码

/**
 * Entry point for initializing and destroying Sqoop server
 */
public class SqoopServer {

  private static final Logger LOG = Logger.getLogger(SqoopServer.class);

  public static void destroy() {
  ....
  }

  public static void initialize() {
    try {
      LOG.info("Booting up Sqoop server");
      SqoopConfiguration.getInstance().initialize();
      AuthenticationManager.getInstance().initialize();
      AuthorizationManager.getInstance().initialize();
      AuditLoggerManager.getInstance().initialize();
      RepositoryManager.getInstance().initialize();
      ConnectorManager.getInstance().initialize();
      Driver.getInstance().initialize();
      JobManager.getInstance().initialize();
      LOG.info("Sqoop server has successfully boot up");
    } catch (Exception ex) {
      LOG.error("Server startup failure", ex);
      throw new RuntimeException("Failure in server initialization", ex);
    }
  }
}

sqoop_server类分为两个部分, initialize方法负责初始化相应的资源。destroy方法负责释放资源。destroy的代码和initialize的是相对应的。为了节省空间,故略去相对应的destroy的代码。

从上面的代码中,可以看出 sqoop_server的初始化过程包括对以下对象的初始化:

  • SqoopConfiguration对象, 其保存sqoop的相关配置信息
  • AuthenticationManager对象, 其负责
  • AuthorizationManager对象, 其负责
  • AuditLoggerManager对象, 其负责
  • RepositoryManager对象, 其负责
  • ConnectorManager对象, 其负责
  • Driver对象, 其负责
  • JobManager对象, 其负责

后面的文章将分别对各个对象进行详细分析。 这里暂不叙述。

你可能感兴趣的:(sqoop_server启动过程)