无法从hadoop hdfs检索文件(Can't retrieve files from hadoop hdfs)
我正在学习如何从/向hdfs读/写文件。
这是我用来阅读的代码:
import java.io.InputStream; import java.net.URI; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IOUtils; public class FileSystemCat { public static void main (String [] args) throws Exception { String uri = "/user/hadoop/file.txt"; Configuration conf = new Configuration(); conf.addResource(new Path("/usr/local/hadoop/etc/hadoop/core-site.xml")); conf.addResource(new Path("/usr/local/hadoop/etc/hadoop/hdfs-site.xml")); FileSystem fs = FileSystem.get(URI.create(uri),conf); InputStream in = null; try{ in = fs.open(new Path(uri)); IOUtils.copyBytes(in, System.out, 4096,false); }finally{ IOUtils.closeStream(in); } }
}
该文件在那里
但是,当我在eclipse中运行代码时,我得到以下内容
Exception in thread "main" java.io.FileNotFoundException: File /user/hadoop/file.txt does not exist at org.apache.hadoop.fs.RawLocalFileSystem.deprecatedGetFileStatus(RawLocalFileSystem.java:511) at org.apache.hadoop.fs.RawLocalFileSystem.getFileLinkStatusInternal(RawLocalFileSystem.java:724) at org.apache.hadoop.fs.RawLocalFileSystem.getFileStatus(RawLocalFileSystem.java:501) at org.apache.hadoop.fs.FilterFileSystem.getFileStatus(FilterFileSystem.java:397) at org.apache.hadoop.fs.ChecksumFileSystem$ChecksumFSInputChecker.<init>(ChecksumFileSystem.java:137) at org.apache.hadoop.fs.ChecksumFileSystem.open(ChecksumFileSystem.java:339) at org.apache.hadoop.fs.FileSystem.open(FileSystem.java:764) at hadoop.FileSystemCat.main(FileSystemCat.java:22)
我用作路径文件:///user/hadoop/file.txt和hdfs:///user/hadoop/file.txt
对于后者,错误略有不同:
Exception in thread "main" java.io.IOException: No FileSystem for scheme: hdfs
核心的site.xml
<configuration> <property> <name>fs.default.name</name> <value>hdfs://localhost/</value> </property> </configuration>
HDFS-site.xml中
<configuration> <property> <name>dfs.replication</name> <value>2</value> </property> <property> <name>dfs.namenode.name.dir</name> <value>file:///usr/local/hadoop_store/hdfs/namenode/</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>file:///usr/local/hadoop_store/hdfs/datanode/,file:///mnt/hadoop/hadoop_store/hdfs/datanode/</value> </property> <property> <name>dfs.webhdfs.enabled</name> <value>true</value> </property> </configuration>
有顾虑吗?
谢谢
I am learning how to read/write files from/to hdfs.
This is the code I use for reading:
import java.io.InputStream; import java.net.URI; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IOUtils; public class FileSystemCat { public static void main (String [] args) throws Exception { String uri = "/user/hadoop/file.txt"; Configuration conf = new Configuration(); conf.addResource(new Path("/usr/local/hadoop/etc/hadoop/core-site.xml")); conf.addResource(new Path("/usr/local/hadoop/etc/hadoop/hdfs-site.xml")); FileSystem fs = FileSystem.get(URI.create(uri),conf); InputStream in = null; try{ in = fs.open(new Path(uri)); IOUtils.copyBytes(in, System.out, 4096,false); }finally{ IOUtils.closeStream(in); } }
}
The file is there
However, I get the following when I run my code in eclipse
Exception in thread "main" java.io.FileNotFoundException: File /user/hadoop/file.txt does not exist at org.apache.hadoop.fs.RawLocalFileSystem.deprecatedGetFileStatus(RawLocalFileSystem.java:511) at org.apache.hadoop.fs.RawLocalFileSystem.getFileLinkStatusInternal(RawLocalFileSystem.java:724) at org.apache.hadoop.fs.RawLocalFileSystem.getFileStatus(RawLocalFileSystem.java:501) at org.apache.hadoop.fs.FilterFileSystem.getFileStatus(FilterFileSystem.java:397) at org.apache.hadoop.fs.ChecksumFileSystem$ChecksumFSInputChecker.<init>(ChecksumFileSystem.java:137) at org.apache.hadoop.fs.ChecksumFileSystem.open(ChecksumFileSystem.java:339) at org.apache.hadoop.fs.FileSystem.open(FileSystem.java:764) at hadoop.FileSystemCat.main(FileSystemCat.java:22)
I used as path both file:///user/hadoop/file.txt and hdfs:///user/hadoop/file.txt
For the latter the error is slightly different:
Exception in thread "main" java.io.IOException: No FileSystem for scheme: hdfs
core-site.xml
<configuration> <property> <name>fs.default.name</name> <value>hdfs://localhost/</value> </property> </configuration>
hdfs-site.xml
<configuration> <property> <name>dfs.replication</name> <value>2</value> </property> <property> <name>dfs.namenode.name.dir</name> <value>file:///usr/local/hadoop_store/hdfs/namenode/</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>file:///usr/local/hadoop_store/hdfs/datanode/,file:///mnt/hadoop/hadoop_store/hdfs/datanode/</value> </property> <property> <name>dfs.webhdfs.enabled</name> <value>true</value> </property> </configuration>
Any concern?
Thanks
原文:https://stackoverflow.com/questions/24488269
更新时间:2023-01-04 07:01
最满意答案
你应该使用
android:textColor="#FFFFFF"
代替
tools:textColor="@android:color/white"
或者尝试以编程方式设置
button.setTextColor(ContextCompat.getColor(YourActivity.this,R.color.colorBlack));
you should use
android:textColor="#FFFFFF"
instead of
tools:textColor="@android:color/white"
or try to set programatically like this
button.setTextColor(ContextCompat.getColor(YourActivity.this,R.color.colorBlack));
相关问答
更多-
如何更改iOS7中UISearchBar的Cancel按钮的textColor?(How to change textColor of Cancel button of UISearchBar in iOS7?)[2023-03-28]
我找到了自己的问题的答案。 这里是代码,如果你想改变所有取消按钮,请在AppDelegate添加。 [[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: ... -
可以在每个平台的自定义渲染器的帮助下更改颜色。 您可以访问自定义渲染器中的本机API。 但需要确保需要,因为不推荐(对于iOS肯定)。 UIAlertView类旨在按原样使用,不支持子类化。 此类的视图层次结构是私有的,不得修改。 iOS的相关主题在这里 。 Possible to change color with the help of custom renderers for each platform. You have access to native api inside custom rend ...
-
最简单的解决方法是在IB中创建虚拟标签,为文本提供您喜欢的颜色并设置为隐藏。 然后,您可以在代码中引用此颜色,将标签设置为所需的颜色。 yourLabel.textColor = hiddenLabel.textColor 以编程方式更改文本颜色的唯一方法是使用标准颜色, UIColor.white , UIColor.green ... The easiest workaround is create dummy labels in IB, give them the text the color yo ...
-
您也可以为颜色定义选择器。 仅区分被按状态和所有其他状态的简短示例是:您的JavaScript中存在一些错误: 你在jsFiddle中设置了mootools而不是jQuery 你的选择器错了,它是[attr=value] ,请在此查看列表 您的JavaScript是静态的,这意味着您只检查一次是否检查了无线电,如果有更改,则没有任何反应 您将颜色设置为收音机而不是标签 这是代码: $(function() { // When the value of the radio change $('.radioPanel [type="radio"]').on('ch ...
无法在swift中更改循环内的textColor和字体大小(Cannot change textColor and font size inside the loop in swift)[2022-02-04]
首先删除Button.titleLabel?.text = "\(button)" 。 这个就足够Button.setTitle("\(button)", forState: UIControlState.Normal) 。 然后你应该使用按钮中的setTitleColor方法来改变它。 Button.setTitleColor(UIColor. blackColor(), forState: UIControlState.Normal) 最后你在你的字体名称中犯了一个错误: Button.titleLab ...Android - Button的textColor,选择器不起作用(Android - Button's textColor with a selector not working)[2021-12-17]
试试这个:你应该使用 android:textColor="#FFFFFF" 代替 tools:textColor="@android:color/white" 或者尝试以编程方式设置 button.setTextColor(ContextCompat.getColor(YourActivity.this,R.color.colorBlack)); you should use android:textColor="#FFFFFF" instead of tools:textColor="@android:colo ...如何在Android中更改XML中按钮的textColor?(How to change textColor of a button from XML in Android?)[2023-10-21]
是的,它可以完成。 你只需要按照可绘制按钮的方式执行。 然后将其分配给android:textColor="@drawable/yourselector" Yes it can be done. You just do the same way you do for the button drawable. Then assign it to android:textColor="@drawable/yourselector"好吧,我不确定它是否是最好的解决方案,但我通过复制LanguageAnnotatation来管理这个问题,包括widget-system(我之所以选择它,是因为它是最接近我想要实现的,因为它使用CSS和span -tag)。 我复制了以下类,调整属性(语言有lang和dir属性,我的颜色注释只有颜色属性): ve.ce.TextColorAnnotation.js ve.dm.TextColorAnnotation.js ve.ui.TextColorContextItem.js ve.ui.TextCol ...相关文章
更多- flume写入Hadoop hdfs报错 Too many open files
- Hadoop Java程序-files功能测试
- Hadoop HDFS 文件与分块理解
- 用FUSE挂载Hadoop的HDFS文件系统
- 扩展Hadoop HDFS,实现WebDav协议,将hdfs mount为Linux本地文件系统
- 【Hadoop】Build and Run HDFS
- Hadoop HDFS 配置
- Hadoop 本地文件复制到hdfs目录
- Hadoop HDFS 配置 挂载HDFS文件系统
- Hadoop HDFS的一些操作
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。