Expected authority at index 7: hdfs://

来源:互联网 发布:微信上免费送礼品淘宝 编辑:程序博客网 时间:2024/06/14 23:30

hadoop版本:1.0.4

今天在跑TestForest的时候,居然出现了这个问题:

Exception in thread "main" java.lang.IllegalArgumentException: Expected authority at index 7: hdfs://at java.net.URI.create(URI.java:859)at org.apache.hadoop.fs.FileSystem.getDefaultUri(FileSystem.java:131)at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:123)at org.apache.mahout.classifier.df.mapreduce.Classifier.run(Classifier.java:107)at org.apache.mahout.classifier.df.mapreduce.TestForest.mapreduce(TestForest.java:187)at org.apache.mahout.classifier.df.mapreduce.TestForest.testForest(TestForest.java:173)at org.apache.mahout.classifier.df.mapreduce.TestForest.run(TestForest.java:145)at mahout.fansy.partial.test.TestTestForest.main(TestTestForest.java:26)Caused by: java.net.URISyntaxException: Expected authority at index 7: hdfs://at java.net.URI$Parser.fail(URI.java:2829)at java.net.URI$Parser.failExpecting(URI.java:2835)at java.net.URI$Parser.parseHierarchical(URI.java:3083)at java.net.URI$Parser.parse(URI.java:3034)at java.net.URI.<init>(URI.java:595)at java.net.URI.create(URI.java:857)... 7 more
我调用TestForest的代码如下:

package mahout.fansy.partial.test;import org.apache.hadoop.conf.Configuration;import org.apache.mahout.classifier.df.mapreduce.TestForest;public class TestTestForest {/** * 测试TestForest * @param args * @throws Exception  */public static void main(String[] args) throws Exception {String[] arg=new String[]{"-i","hdfs://ubuntu:9000/user/breiman/input/glass.data","-ds","hdfs://ubuntu:9000/user/breiman/glass.info","-m","hdfs://ubuntu:9000/user/breiman/glass.tree/forest.seq","-a","-mr","-o","hdfs://ubuntu:9000/user/breiman/out-testforest0"};Configuration conf=new Configuration();conf.set("mapred.job.tracker", "ubuntu:9001");conf.set("fs.default.name", "hdfs://");TestForest tf=new TestForest();tf.setConf(conf);Configuration confq=tf.getConf();System.out.println(confq);tf.run(arg);}}
刚开始的时候是直接使用TestForest.main(arg)来调用的,但是发现conf的值设置不了(即全部都是按照默认,这个肯定不行,在win7 的myeclipse上面调用hadoop肯定要设置conf的)但是哪里可以设置,所以就想到了TestForest是继承Configuration的,然后Configuration有一个setConf的方法,所以就实例化了一个TestForest对象,然后调用setConf方法设置conf,但是conf设置的不对,所以出现了上面的错误。要如何设置呢?其实把conf.set("fs.default.name", "hdfs://");改为conf.set("fs.default.name", "ubuntu:9000");就可以了,其中ubuntu是主节点机器名。然后就可以跑了。

分享,成长,快乐

转载请注明blog地址:http://blog.csdn.net/fansy1990


原创粉丝点击