zoukankan      html  css  js  c++  java
  • Expected authority at index 7: hdfs://

    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

  • 相关阅读:
    HDU1879 kruscal 继续畅通工程
    poj1094 拓扑 Sorting It All Out
    (转)搞ACM的你伤不起
    (转)女生应该找一个玩ACM的男生
    poj3259 bellman——ford Wormholes解绝负权问题
    poj2253 最短路 floyd Frogger
    Leetcode 42. Trapping Rain Water
    Leetcode 41. First Missing Positive
    Leetcode 4. Median of Two Sorted Arrays(二分)
    Codeforces:Good Bye 2018(题解)
  • 原文地址:https://www.cnblogs.com/suncoolcat/p/3339373.html
Copyright © 2011-2022 走看看