gpt4 book ai didi

org.apache.hadoop.yarn.conf.YarnConfiguration.addResource()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 01:44:40 28 4
gpt4 key购买 nike

本文整理了Java中org.apache.hadoop.yarn.conf.YarnConfiguration.addResource()方法的一些代码示例,展示了YarnConfiguration.addResource()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YarnConfiguration.addResource()方法的具体详情如下:
包路径:org.apache.hadoop.yarn.conf.YarnConfiguration
类名称:YarnConfiguration
方法名:addResource

YarnConfiguration.addResource介绍

暂无

代码示例

代码示例来源:origin: apache/flink

public AbstractYarnClusterDescriptor(
    Configuration flinkConfiguration,
    YarnConfiguration yarnConfiguration,
    String configurationDirectory,
    YarnClient yarnClient,
    boolean sharedYarnClient) {
  this.yarnConfiguration = Preconditions.checkNotNull(yarnConfiguration);
  // for unit tests only
  if (System.getenv("IN_TESTS") != null) {
    try {
      yarnConfiguration.addResource(new File(System.getenv("YARN_CONF_DIR"), "yarn-site.xml").toURI().toURL());
    } catch (Throwable t) {
      throw new RuntimeException("Error", t);
    }
  }
  this.yarnClient = Preconditions.checkNotNull(yarnClient);
  this.sharedYarnClient = sharedYarnClient;
  this.flinkConfiguration = Preconditions.checkNotNull(flinkConfiguration);
  userJarInclusion = getUserJarInclusionMode(flinkConfiguration);
  this.configurationDirectory = Preconditions.checkNotNull(configurationDirectory);
}

代码示例来源:origin: alibaba/jstorm

public Executor(String instancName, String shellCommand, STARTType startType, String runningContainer,
        String localDir, String deployPath,
        String hadoopHome, String javaHome, String pythonHome, String dstPath, String portList, String shellArgs,
        String ExecShellStringPath, String applicationId, String supervisorLogviewPort, String nimbusThriftPort) {
  executorMeta = new ExecutorMeta(instancName, shellCommand, startType, runningContainer,
      localDir, deployPath, hadoopHome, javaHome, pythonHome, dstPath, portList, shellArgs,
      ExecShellStringPath, applicationId, supervisorLogviewPort, nimbusThriftPort);
  conf = new YarnConfiguration();
  Path yarnSite = new Path(hadoopHome + JOYConstants.YARN_SITE_PATH);
  conf.addResource(yarnSite);
  //get first log dir
  logDir = conf.get(JOYConstants.YARN_NM_LOG, JOYConstants.YARN_NM_LOG_DIR).split(JOYConstants.COMMA)[0] + JOYConstants.BACKLASH + applicationId + JOYConstants.BACKLASH + runningContainer;
  //Setup RegistryOperations
  registryOperations = RegistryOperationsFactory.createInstance(JOYConstants.YARN_REGISTRY, conf);
  try {
    setupInitialRegistryPaths();
  } catch (IOException e) {
    e.printStackTrace();
  }
  registryOperations.start();
}

代码示例来源:origin: uber/AthenaX

public YarnClusterConfiguration toYarnClusterConfiguration() {
  Preconditions.checkNotNull(yarnSite, "yarn.site.location is not configured");
  Preconditions.checkNotNull(homeDir, "athenax.home.dir is not configured");
  Preconditions.checkNotNull(flinkUberJar, "flink.uber.jar.location is not configured");
  YarnConfiguration yarnConf = new YarnConfiguration();
  yarnConf.addResource(new Path(URI.create(yarnSite)));
  return new YarnClusterConfiguration(
    yarnConf, homeDir, new Path(flinkUberJar),
    resourcesToLocalize.stream().map(x -> new Path(URI.create(x))).collect(Collectors.toSet()),
    additionalJars.stream().map(x -> new Path(URI.create(x))).collect(Collectors.toSet()));
 }
}

代码示例来源:origin: DTStack/flinkx

public static YarnConfiguration getYarnConf(String yarnConfDir) {
  YarnConfiguration yarnConf = new YarnConfiguration();
  try {
    File dir = new File(yarnConfDir);
    if(dir.exists() && dir.isDirectory()) {
      File[] xmlFileList = new File(yarnConfDir).listFiles((dir1, name) -> {
        if(name.endsWith(".xml")){
          return true;
        }
        return false;
      });
      if(xmlFileList != null) {
        for(File xmlFile : xmlFileList) {
          yarnConf.addResource(xmlFile.toURI().toURL());
        }
      }
    }
  } catch(Exception e) {
    throw new RuntimeException(e);
  }
  haYarnConf(yarnConf);
  return yarnConf;
}

代码示例来源:origin: DTStack/flinkStreamSQL

public static YarnConfiguration getYarnConf(String yarnConfDir) {
  YarnConfiguration yarnConf = new YarnConfiguration();
  try {
    File dir = new File(yarnConfDir);
    if(dir.exists() && dir.isDirectory()) {
      File[] xmlFileList = new File(yarnConfDir).listFiles((dir1, name) -> {
        if(name.endsWith(".xml")){
          return true;
        }
        return false;
      });
      if(xmlFileList != null) {
        for(File xmlFile : xmlFileList) {
          yarnConf.addResource(xmlFile.toURI().toURL());
        }
      }
    }
  } catch(Exception e) {
    throw new RuntimeException(e);
  }
  haYarnConf(yarnConf);
  return yarnConf;
}

代码示例来源:origin: DTStack/flinkx

public static YarnConfiguration getYarnConfiguration(Configuration config, String yarnConfDir) throws Exception {
  YarnConfiguration yarnConf = new YarnConfiguration();
  config.setString(ConfigConstants.PATH_HADOOP_CONFIG, yarnConfDir);
  FileSystem.initialize(config);
  File dir = new File(yarnConfDir);
  if (dir.exists() && dir.isDirectory()) {
    File[] xmlFileList = new File(yarnConfDir).listFiles(new FilenameFilter() {
      @Override
      public boolean accept(File dir, String name) {
        if (name.endsWith(".xml")) {
          return true;
        }
        return false;
      }
    });
    if (xmlFileList != null) {
      for (File xmlFile : xmlFileList) {
        yarnConf.addResource(xmlFile.toURI().toURL());
      }
    }
  }
  return yarnConf;
}

代码示例来源:origin: linkedin/TonY

private void createYarnClient() {
 if (this.yarnConfAddress != null) {
  this.yarnConf.addResource(new Path(this.yarnConfAddress));
 }
 if (this.hdfsConfAddress != null) {
  this.hdfsConf.addResource(new Path(this.hdfsConfAddress));
 }
 int numRMConnectRetries = tonyConf.getInt(TonyConfigurationKeys.RM_CLIENT_CONNECT_RETRY_MULTIPLIER,
   TonyConfigurationKeys.DEFAULT_RM_CLIENT_CONNECT_RETRY_MULTIPLIER);
 long rmMaxWaitMS = yarnConf.getLong(YarnConfiguration.RESOURCEMANAGER_CONNECT_RETRY_INTERVAL_MS,
   YarnConfiguration.DEFAULT_RESOURCEMANAGER_CONNECT_RETRY_INTERVAL_MS) * numRMConnectRetries;
 yarnConf.setLong(YarnConfiguration.RESOURCEMANAGER_CONNECT_MAX_WAIT_MS, rmMaxWaitMS);
 if (System.getenv(Constants.HADOOP_CONF_DIR) != null) {
  hdfsConf.addResource(new Path(System.getenv(Constants.HADOOP_CONF_DIR) + File.separatorChar + Constants.CORE_SITE_CONF));
  yarnConf.addResource(new Path(System.getenv(Constants.HADOOP_CONF_DIR) + File.separatorChar + Constants.CORE_SITE_CONF));
  hdfsConf.addResource(new Path(System.getenv(Constants.HADOOP_CONF_DIR) + File.separatorChar + Constants.HDFS_SITE_CONF));
 }
 yarnClient = YarnClient.createYarnClient();
 yarnClient.init(yarnConf);
}

代码示例来源:origin: org.apache.fluo/fluo-cluster

private synchronized TwillRunnerService getTwillRunner(FluoConfiguration config) {
 if (!twillRunners.containsKey(config.getApplicationName())) {
  YarnConfiguration yarnConfig = new YarnConfiguration();
  yarnConfig.addResource(new Path(hadoopPrefix + "/etc/hadoop/core-site.xml"));
  yarnConfig.addResource(new Path(hadoopPrefix + "/etc/hadoop/yarn-site.xml"));
  TwillRunnerService twillRunner =
    new YarnTwillRunnerService(yarnConfig, config.getAppZookeepers() + ZookeeperPath.TWILL);
  twillRunner.start();
  twillRunners.put(config.getApplicationName(), twillRunner);
  // sleep to give twill time to retrieve state from zookeeper
  try {
   Thread.sleep(1000);
  } catch (InterruptedException e) {
   throw new IllegalStateException(e);
  }
 }
 return twillRunners.get(config.getApplicationName());
}

代码示例来源:origin: apache/fluo

private synchronized TwillRunnerService getTwillRunner(FluoConfiguration config) {
 if (!twillRunners.containsKey(config.getApplicationName())) {
  YarnConfiguration yarnConfig = new YarnConfiguration();
  yarnConfig.addResource(new Path(hadoopPrefix + "/etc/hadoop/core-site.xml"));
  yarnConfig.addResource(new Path(hadoopPrefix + "/etc/hadoop/yarn-site.xml"));
  TwillRunnerService twillRunner =
    new YarnTwillRunnerService(yarnConfig, config.getAppZookeepers() + ZookeeperPath.TWILL);
  twillRunner.start();
  twillRunners.put(config.getApplicationName(), twillRunner);
  // sleep to give twill time to retrieve state from zookeeper
  try {
   Thread.sleep(1000);
  } catch (InterruptedException e) {
   throw new IllegalStateException(e);
  }
 }
 return twillRunners.get(config.getApplicationName());
}

代码示例来源:origin: io.fluo/fluo-cluster

private synchronized TwillRunnerService getTwillRunner(FluoConfiguration config) {
 if (!twillRunners.containsKey(config.getApplicationName())) {
  YarnConfiguration yarnConfig = new YarnConfiguration();
  yarnConfig.addResource(new Path(hadoopPrefix + "/etc/hadoop/core-site.xml"));
  yarnConfig.addResource(new Path(hadoopPrefix + "/etc/hadoop/yarn-site.xml"));
  TwillRunnerService twillRunner =
    new YarnTwillRunnerService(yarnConfig, config.getAppZookeepers() + ZookeeperPath.TWILL);
  twillRunner.start();
  twillRunners.put(config.getApplicationName(), twillRunner);
  // sleep to give twill time to retrieve state from zookeeper
  try {
   Thread.sleep(1000);
  } catch (InterruptedException e) {
   throw new IllegalStateException(e);
  }
 }
 return twillRunners.get(config.getApplicationName());
}

代码示例来源:origin: org.apache.flink/flink-yarn_2.11

public AbstractYarnClusterDescriptor(
    Configuration flinkConfiguration,
    YarnConfiguration yarnConfiguration,
    String configurationDirectory,
    YarnClient yarnClient,
    boolean sharedYarnClient) {
  this.yarnConfiguration = Preconditions.checkNotNull(yarnConfiguration);
  // for unit tests only
  if (System.getenv("IN_TESTS") != null) {
    try {
      yarnConfiguration.addResource(new File(System.getenv("YARN_CONF_DIR"), "yarn-site.xml").toURI().toURL());
    } catch (Throwable t) {
      throw new RuntimeException("Error", t);
    }
  }
  this.yarnClient = Preconditions.checkNotNull(yarnClient);
  this.sharedYarnClient = sharedYarnClient;
  this.flinkConfiguration = Preconditions.checkNotNull(flinkConfiguration);
  userJarInclusion = getUserJarInclusionMode(flinkConfiguration);
  this.configurationDirectory = Preconditions.checkNotNull(configurationDirectory);
}

代码示例来源:origin: org.apache.flink/flink-yarn

public AbstractYarnClusterDescriptor(
    Configuration flinkConfiguration,
    YarnConfiguration yarnConfiguration,
    String configurationDirectory,
    YarnClient yarnClient,
    boolean sharedYarnClient) {
  this.yarnConfiguration = Preconditions.checkNotNull(yarnConfiguration);
  // for unit tests only
  if (System.getenv("IN_TESTS") != null) {
    try {
      yarnConfiguration.addResource(new File(System.getenv("YARN_CONF_DIR"), "yarn-site.xml").toURI().toURL());
    } catch (Throwable t) {
      throw new RuntimeException("Error", t);
    }
  }
  this.yarnClient = Preconditions.checkNotNull(yarnClient);
  this.sharedYarnClient = sharedYarnClient;
  this.flinkConfiguration = Preconditions.checkNotNull(flinkConfiguration);
  userJarInclusion = getUserJarInclusionMode(flinkConfiguration);
  this.configurationDirectory = Preconditions.checkNotNull(configurationDirectory);
}

代码示例来源:origin: org.springframework.data/spring-yarn-core

if (resources != null) {
  for (Resource resource : resources) {
    internalConfig.addResource(resource.getURL());

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com