首页 > 其他分享 >dremio yarn 集成之 AppBundleGenerator 简单说明

dremio yarn 集成之 AppBundleGenerator 简单说明

时间:2023-02-04 21:36:00浏览次数:150  
标签:dremio Stream jar AppBundleGenerator yarn add

AppBundleGenerator 的目的是方便yarn 应用的运行,dremio 自己开发了一个方便软件打包的服务,可以简化

参考处理

默认生成的jar 包名称dremio-bundle.jar

public Path generateBundle() throws IOException {
    // Create an application bundle jar based on current application classpath
    Path yarnBundledJarPath = Files.createTempFile(DREMIO_BUNDLE_PREFIX, ".jar");
    // dremio包装的JarGenerator ,生成jar 包
    try (JarGenerator jarGenerator = JarGenerator.of(new JarOutputStream(Files.newOutputStream(yarnBundledJarPath)))) {
      // First add prefix classpath entries
      // Second, add content of classpath to bundle jar
      // Then add extra classpath entries
      List<URI> jarEntries;
      try (Stream<Path> prefixStream = toPathStream(classPathPrefix);
        Stream<Path> classLoaderStream = toPathStream(classLoader);
        Stream<Path> classPathStream = toPathStream(classPath)) {
        jarEntries = addPathsToBundle(jarGenerator,
          Stream.concat(prefixStream, Stream.concat(classLoaderStream, classPathStream)));
      }
 
      // After that add native libraries
      List<URI> nativeLibrariesEntries = addPathsToBundle(jarGenerator, nativeLibraryPath.stream().map(Paths::get));
 
      // After that add plugins
      URI pluginsPathEntry = addPathToJar(jarGenerator, pluginsPath);
     // jar Manifest 添加
      // Finally, add classpath and native library path entries in jar manifest
      // Following spec for class-path, string is a list of URI separated by space...
      Manifest manifest = new Manifest();
      final Attributes mainAttributes = manifest.getMainAttributes();
      mainAttributes.put(Attributes.Name.MANIFEST_VERSION, "1.0");
      mainAttributes.put(Attributes.Name.CLASS_PATH,
          jarEntries.stream()
          .map(URI::toString)
          .collect(Collectors.joining(DELIMITER)));
      mainAttributes.putValue(X_DREMIO_LIBRARY_PATH_MANIFEST_ATTRIBUTE,
          nativeLibrariesEntries.stream().map(URI::toString).collect(Collectors.joining(DELIMITER)));
      mainAttributes.putValue(X_DREMIO_PLUGINS_PATH_MANIFEST_ATTRIBUTE, pluginsPathEntry.toString());
 
      jarGenerator.addManifest(manifest);
    }
 
    return yarnBundledJarPath;
  }

使用

DacDaemonYarnApplication 类的构造函数中

public DacDaemonYarnApplication(DremioConfig dremioConfig, YarnConfiguration yarnConfig, @NotNull Environment env) {
    this.yarnConfig = yarnConfig;
   // 注意需要一个DREMIO_HOME 环境变量
    final String dremioHome = Preconditions.checkNotNull(env.getEnv(DREMIO_HOME),
        "Environment variable DREMIO_HOME is not set");
 
    this.keytabFileLocation = dremioConfig.getString(DremioConfig.KERBEROS_KEYTAB_PATH);
 
    // Gather the list of jars to be added to the container classpath
    Stream<String> classpathJars = Stream.concat(
        yarnConfig.getTrimmedStringCollection(YarnDefaultsConfigurator.CLASSPATH_JARS).stream().map(d -> dremioHome.concat(d)),
        dremioConfig.getStringList(DremioConfig.YARN_CLASSPATH).stream());
   
    classpathJars.forEach(classpathJar -> {
      Path jarFullPath = Paths.get(classpathJar);
      Path parentDir = jarFullPath.getParent();
      final String fileName = jarFullPath.getFileName().toString();
 
      try(Stream<Path> paths = Files.list(parentDir)) {
        paths
        .filter(p -> p.getFileName().toString().matches(fileName))
        .forEach(p -> {
          jarNames.add(p.getFileName().toString());
          this.classpathJarNames.add(p.toFile());
        });
      } catch(IOException e) {
        logger.warn("Cannot list files in directory {}", parentDir, e);
      }
    });
 
    // Create an application bundle jar based on current application classpath
    AppBundleGenerator appBundleGenerator = AppBundleGenerator.of(dremioConfig);
    try {
      if (!isTestingModeOn) {
        yarnBundledJarPath = appBundleGenerator.generateBundle();
      } else {
        yarnBundledJarPath = Paths.get("/temp");
      }
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }

说明

dremio 的AppBundleGenerator 主要是生成jar 文件(都使用了java jar 操作api),方便yarn 运行(实际上就是fat jar),后边YarnController 会使用到,具体会介绍

参考资料

provision/yarn/yarntwill/src/main/java/com/dremio/provision/yarn/AppBundleGenerator.java
provision/yarn/yarntwill/src/main/java/com/dremio/provision/yarn/DacDaemonYarnApplication.java
https://docs.dremio.com/software/advanced-administration/start-stop/#starting-up-with-yarn-deployments
https://docs.dremio.com/software/deployment/yarn-hadoop/

标签:dremio,Stream,jar,AppBundleGenerator,yarn,add
From: https://www.cnblogs.com/rongfengliang/p/17092429.html

相关文章

  • dremio 的 YarnDaemon 简单说明
    YarnDaemon与DremioDaemon基本类似,都是启动dremio服务,只是YarnDaemon更多是关于执行器节点的运行模式与DremioDaemon差异比较大,DremioDaemon就是一个longrunning......
  • dremio 23 版本反射问题最新说明
    此问题,官方已经确认是在进行反射替换的时候有问题,同时预计会在24版本解决,但是目前暂时还没有发布(官方对于社区版的支持不是很好。。。。)参考资料https://community.drem......
  • dremio provision 模式功能简单说明
    目前此功能主要是支持yarn等资源调度的,在dremio系统中名称为弹性引擎ProvisioningService服务接口定义参考类图  不同类型的实现具体操作是由ProvisioningServ......
  • dremio provisioning 几种模式简单介绍
    主要是包含了基于云以及yarn模式的部署awseks  azurearm  azureaks  yarn模式  标准集群模式  说明以上集中模式包含了软件以及在云......
  • dremio api 简单说明
    以前在简单介绍dremiowebserver的时候提过dremio的api,实际上包含了两大部分,一个是为了bff的(方便前端使用的),一个是独立的restapi方便业务调用的(实际上就是官方文档中看......
  • Yarn平滑下线节点(Graceful Decommission)
    一、背景二、概述三、下线流程与原理1.读取待下线节点列表2.判断节点下线模式3.设置超时时间4.RMNode处理下线事件5.监控节点的状态、下线节点四、相关的Yarn......
  • dremio ioc 机制简单说明
    dremio不对服务的依赖管理以及处理没有直接使用googleguice,而是dremio自己包装了一个类似guice的ioc能力提供的能力说明因为对于ioc来说需要包含不同的几种服务注入......
  • 通过DACModule 模块学习dremio 服务模块依赖关系之 bootstrap
    以前有简单介绍过dremio的DACModule模块,核心就是进行服务的启动以及依赖管理维护,接口实现了包含了bootstrap以及build区别在于bootstrap管理的是一些需要提前准备好的......
  • dremio ClusterCoordinator 服务简单说明
    dremioClusterCoordinator主要是处理集群任务协商的,比如那些服务可以在什么节点上运行,以及对于查询具体这么执行,对于元数据应该如果存储以及元数据如何进行刷新,同时还包含......
  • Hive SQL Join关联查询Apache Hadoop概述Hadoop YARN架构、组件及其交互流程Apache Hi
    Hadoop离线是大数据生态圈的核心与基石,是整个大数据开发的入门。本次分享内容让初学者能高效、快捷掌握Hadoop必备知识,大大缩短Hadoop离线阶段学习时间,下面一起开始今天的学......