- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我的 java 应用程序应该在运行时为 hadoop xml 定义文件夹(为简单起见,让它从程序命令行参数中获取)。我想,我可以使用类似下面的代码:
import org.apache.hadoop.conf.Configuration()
....
Configuration = new Configuration
config.addResource(new Path(String.format("%s/core-site.xml", hadoopLocation)));
config.addResource(new Path(String.format("%s/hdfs-site.xml", hadoopLocation)));
config.addResource(new Path(String.format("%s/tez-site.xml", hadoopLocation)));
config.addResource(new Path(String.format("%s/yarn-site.xml", hadoopLocation)));
config.addResource(new Path(String.format("%s/mapred-site.xml", hadoopLocation)));
config.set("fs.hdfs.impl", org.apache.hadoop.hdfs.DistributedFileSystem.class.getName() );
config.set("fs.file.impl", org.apache.hadoop.fs.LocalFileSystem.class.getName() );
try {
FileSystem dfs = FileSystem.get(config);
} catch (IOException e) {
LOGGER.error("Failed to process hadoop file system");
}
但是,我应该在我的程序中每次调用 new Configuration()
时重复它,或者使用一些持久的预配置 baseConfiguration
对象并像 new Configuration(基础配置)
。所有这些方式看起来都很笨拙。有没有更优雅的解决方案。也许我可以执行一次类似静态方法调用的东西。以下代码仅供引用:
Configuration.setBaseXmlsDir();
最佳答案
Hadoop 应用程序在类路径中查找这些文件。如果您运行 hadoop classpath
,您应该能够在列表中看到配置目录。
因此,要修改位置,您只需要在应用程序运行之前修改类路径即可。最简单的方法是在启动应用程序之前定义环境变量 HADOOP_CONF_DIR
,如下所示:
export HADOOP_CONF_DIR=/your/path/to/xmls
hadoop jar ...
关于java - 如何以编程方式为 hadoop *-site.xml 设置目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47228472/
谁能告诉我 Core-site.xml、hdfs-site.xml、mapred-site.xml 和 yarn-site.xml 必须具备的属性,没有这些属性 hadoop 就无法启动? 最佳答案
由于特定的 problem我设法解决了这个问题,我今天大部分时间都在弄清楚 site.py(s) 是如何工作的。有一点我不明白。 据我了解,当加载 python 时,首先运行 lib/python2.
这个问题在这里已经有了答案: Using async/await with a forEach loop (33 个答案) 关闭 4 年前。 我认为我的 driver.get(site) 调用设置错
与hadoop api configuration on the client machine有关。 如果我们尝试将客户端计算机上的mapred-site.xml保持尽可能少=仅指定mapred.jo
我一直对site-packages的命名原理有些好奇。 site 在这种情况下是什么意思?我怀疑它的意思是“网站”,而且我从未听说过与安装位置或机器上下文相关的“站点”。 有什么想法吗? 最佳答案 我
我有一个本地 NiFi 实例,我想通过安全的站点到站点通信将数据发送到 AWS 服务器上的远程 NiFi 实例。 我使用 NiFi TLS 工具包为我的客户端和服务器 keystore 和信任库生成了
已关闭。这个问题是 not about programming or software development 。目前不接受答案。 这个问题似乎不是关于 a specific programming
我尝试按照说明在我的页面上设置 reCAPTCHA here 。我注册了 API key 对,并获得了公钥和私钥。对我来说,不清楚应该如何使用私钥,并且我无法找到有关它的更多信息。调用 reCAPTC
尝试我的第一个“HELLO WORLD”类型的 Web 应用程序,该应用程序基于显示 godaddy 设置的示例程序。 使用 Visual Studio 2017 和 C#。我的程序在 localho
我使用 HttpClient 从 Hadoop 服务器下载文件。 但其他人说这不利于安全,因为它不需要输入用户 ID。所以我必须将其更改为webhdfs或hdfs。 我必须连接 Hadoop,但它不是
去年,我根据 GitHub Pages' instructions 将我的博客设置为 GitHub 页面“用户站点”在遵循他们的命名约定 username.github.io 的 repo 中。但是,
我尝试了几天在 2 个站点之间创建 VPN 隧道,但没有成功。 场景 我有以下场景: 站点 A 的 IP 地址为 192.168.1.0/24,网关 GWA 的地址为 192.168.1.254 和
我们有一个 VSO 存储库,同一解决方案中包含多个站点。我们希望能够通过持续交付将彼此独立的站点部署到 Azure。现在,第一个站点按字母顺序部署到我们所有的站点,这当然是不可取的。 这可以实现吗?
我们有一个 VSO 存储库,同一解决方案中包含多个站点。我们希望能够通过持续交付将彼此独立的站点部署到 Azure。现在,第一个站点按字母顺序部署到我们所有的站点,这当然是不可取的。 这可以实现吗?
如何为查看者输入“站点”? Eclipse API 中的“站点”是什么? 我在SampleView中找到了以下代码: viewer.setInput(getViewSite()); 其中 viewer
在 The Django Book在关于管理站点的第 6 章中,他们告诉我将以下 URL 模式添加到 urls.py: urlpatterns = patterns('', # ...
我正在尝试安装站点包,并且在运行 makemigrations 时收到错误: django.contrib.admin.sites.AlreadyRegistered: The model Site
我正在尝试使用 Google Tag Manager对于使用 Google Sites 创建的站点,但到目前为止我还没有运气。这个问题似乎已经出现在几个论坛上,但我无法为此找到任何明确的答案。 帮助将
在我的电脑中: /etc/R 中有三个文件Renviron 和 Rprofile.site、Renviron.site 、我在任何地方都找不到Rprofile。这是一个适当的状态吗? Rprofile
我正在尝试安装站点包,并且在运行 makemigrations 时收到错误: django.contrib.admin.sites.AlreadyRegistered: The model Site
我是一名优秀的程序员,十分优秀!