本文整理了Java中com.uber.athenax.backend.server.yarn.YarnClusterConfiguration
类的一些代码示例,展示了YarnClusterConfiguration
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YarnClusterConfiguration
类的具体详情如下:
包路径:com.uber.athenax.backend.server.yarn.YarnClusterConfiguration
类名称:YarnClusterConfiguration
[英]YarnClusterConfiguration consists of information of the YARN cluster.
[中]YanclusterConfiguration由纱线簇的信息组成。
代码示例来源: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: uber/AthenaX
private Map<String, String> setUpAmEnvironment(
ApplicationId appId,
String amClassPath,
String shipFiles,
String dynamicProperties) throws IOException {
final Map<String, String> env = new HashMap<>();
// set Flink app class path
env.put(YarnConfigKeys.ENV_FLINK_CLASSPATH, amClassPath);
// set Flink on YARN internal configuration values
env.put(YarnConfigKeys.ENV_TM_COUNT, String.valueOf(job.taskManagerCount()));
env.put(YarnConfigKeys.ENV_TM_MEMORY, String.valueOf(job.taskManagerMemoryMb()));
env.put(YarnConfigKeys.FLINK_JAR_PATH, clusterConf.flinkUberJar().toString());
env.put(YarnConfigKeys.ENV_APP_ID, appId.toString());
env.put(YarnConfigKeys.ENV_CLIENT_HOME_DIR, clusterConf.homeDir());
env.put(YarnConfigKeys.ENV_CLIENT_SHIP_FILES, shipFiles);
env.put(YarnConfigKeys.ENV_SLOTS, "-1");
env.put(YarnConfigKeys.ENV_DETACHED, "true");
// https://github.com/apache/hadoop/blob/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/YarnApplicationSecurity.md#identity-on-an-insecure-cluster-hadoop_user_name
env.put(YarnConfigKeys.ENV_HADOOP_USER_NAME,
UserGroupInformation.getCurrentUser().getUserName());
if (dynamicProperties != null) {
env.put(YarnConfigKeys.ENV_DYNAMIC_PROPERTIES, dynamicProperties);
}
// set classpath from YARN configuration
Utils.setupYarnClassPath(clusterConf.conf(), env);
return env;
}
代码示例来源:origin: uber/AthenaX
private void collectLocalResources(
Map<String, LocalResource> resources,
Set<Path> shippedPaths
) throws IOException {
for (Path p : clusterConf.resourcesToLocalize()) {
resources.put(p.getName(), toLocalResource(p, LocalResourceVisibility.APPLICATION));
}
for (Path p : Iterables.concat(clusterConf.systemJars(), job.userProvidedJars())) {
String name = p.getName();
if (resources.containsKey(name)) {
throw new IllegalArgumentException("Duplicated name in the shipped files " + p);
}
resources.put(name, toLocalResource(p, LocalResourceVisibility.APPLICATION));
shippedPaths.add(p);
}
}
代码示例来源:origin: uber/AthenaX
AthenaXYarnClusterDescriptor(
YarnClusterConfiguration clusterConf,
YarnClient yarnClient,
Configuration flinkConf,
JobConf job) {
super(new Configuration(flinkConf),
clusterConf.conf(),
"",
yarnClient,
true);
this.clusterConf = clusterConf;
this.yarnClient = yarnClient;
this.flinkConf = flinkConf;
this.job = job;
}
代码示例来源:origin: uber/AthenaX
private LocalResource toLocalResource(Path path, LocalResourceVisibility visibility) throws IOException {
FileSystem fs = path.getFileSystem(clusterConf.conf());
FileStatus stat = fs.getFileStatus(path);
return LocalResource.newInstance(
ConverterUtils.getYarnUrlFromPath(path),
LocalResourceType.FILE,
visibility,
stat.getLen(), stat.getModificationTime()
);
}
代码示例来源:origin: uber/AthenaX
public String generateYarnClusterConfContent(String clusterName) {
StringBuffer sb = new StringBuffer();
String parent = workDir.getAbsolutePath();
sb.append("clusters:\n")
.append(String.format(" %s:\n", clusterName))
.append(String.format(" yarn.site.location: %s\n", new File(parent, "yarn-site.xml").toURI()))
.append(String.format(" athenax.home.dir: %s\n", workDir.toURI()))
.append(String.format(" flink.uber.jar.location: %s\n", new File(parent, "flink.jar").toURI()))
.append(" localize.resources:\n");
yarnClusterConf.resourcesToLocalize().forEach(x -> sb.append(String.format(" - %s\n", x.toUri())));
sb.append(" additional.jars:\n");
yarnClusterConf.systemJars().forEach(x -> sb.append(String.format(" - %s\n", x.toUri())));
return sb.toString();
}
代码示例来源:origin: uber/AthenaX
ClusterInfo(String name, YarnClusterConfiguration conf) {
this.name = name;
this.client = YarnClient.createYarnClient();
client.init(conf.conf());
client.start();
this.conf = conf;
}
代码示例来源:origin: uber/AthenaX
private YarnClusterConfiguration prepareYarnCluster() throws IOException, URISyntaxException {
yarnCluster.init(yarnConf);
yarnCluster.start();
yarnConf.set(RM_ADDRESS, yarnCluster.getResourceManager().getConfig().get(RM_ADDRESS));
File yarnSite = new File(workDir, "yarn-site.xml");
try (PrintWriter pw = new PrintWriter(new FileWriter(yarnSite))) {
yarnConf.writeXml(pw);
}
Path flinkUberJar = new Path(new File(workDir, "flink.jar").toURI());
Path flinkConfYaml = new Path(new File(workDir, "flink-conf.yaml").toURI());
@SuppressWarnings("ConstantConditions")
Path log4jPath = new Path(Thread.currentThread().getContextClassLoader().getResource("log4j.properties").toURI());
Set<Path> resourcesToLocalize = new HashSet<>(Arrays.asList(flinkUberJar, flinkConfYaml, log4jPath));
String home = workDir.toURI().toString();
return new YarnClusterConfiguration(
yarnConf,
home,
flinkUberJar,
resourcesToLocalize,
systemJars(yarnSite));
}
代码示例来源:origin: uber/AthenaX
@Test
public void testDeployerWithIsolatedConfiguration() throws Exception {
YarnClusterConfiguration clusterConf = mock(YarnClusterConfiguration.class);
doReturn(new YarnConfiguration()).when(clusterConf).conf();
ScheduledExecutorService executor = mock(ScheduledExecutorService.class);
Configuration flinkConf = new Configuration();
YarnClient client = mock(YarnClient.class);
JobDeployer deploy = new JobDeployer(clusterConf, client, executor, flinkConf);
AthenaXYarnClusterDescriptor desc = mock(AthenaXYarnClusterDescriptor.class);
YarnClusterClient clusterClient = mock(YarnClusterClient.class);
doReturn(clusterClient).when(desc).deploy();
ActorGateway actorGateway = mock(ActorGateway.class);
doReturn(actorGateway).when(clusterClient).getJobManagerGateway();
doReturn(Future$.MODULE$.successful(null)).when(actorGateway).ask(any(), any());
JobGraph jobGraph = mock(JobGraph.class);
doReturn(JobID.generate()).when(jobGraph).getJobID();
deploy.start(desc, jobGraph);
verify(clusterClient).runDetached(jobGraph, null);
}
}
内容来源于网络,如有侵权,请联系作者删除!