jazz大大~~
我的錯誤訊息如下:代碼:
Working Directory -> hdfs://WINDOOP:9000/user/user
14/02/25 16:35:55 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.
14/02/25 16:35:55 INFO mapred.JobClient: Cleaning up the staging area hdfs://WINDOOP:9000/windoop/mapred/staging/user/.staging/job_201402251402_0007
14/02/25 16:35:55 ERROR security.UserGroupInformation: PriviledgedActionException as:user cause:org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist: hdfs://WINDOOP:9000/user/user/input
Exception in thread "main" org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist: hdfs://WINDOOP:9000/user/user/input
at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.listStatus(FileInputFormat.java:235)
at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.getSplits(FileInputFormat.java:252)
at org.apache.hadoop.mapred.JobClient.writeNewSplits(JobClient.java:962)
at org.apache.hadoop.mapred.JobClient.writeSplits(JobClient.java:979)
at org.apache.hadoop.mapred.JobClient.access$600(JobClient.java:174)
at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:897)
at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:850)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Unknown Source)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1121)
at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:850)
at org.apache.hadoop.mapreduce.Job.submit(Job.java:500)
at org.windoop.presidentElection.main(presidentElection.java:353)
我的reduce設定不做事情
事先已經把setcombiner拿掉
也已經設定job.setNumReduceTasks(0);
但應該不是這個問題
應該是輸入格式問題。
以下是我的map程式碼:代碼:
public static class TokenizerMapper
extends Mapper<Object, Text, Text, Text>{
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
//0 1 2 3 4 5
int[][] distance = { /* 0 */{ 0, 0, 0, 0, 0, 0 },
/* 1 */{ 0, 0, 7, 4,10, 3 },
/* 2 */{ 0, 7, 0, 9, 6, 2 },
/* 3 */{ 0, 4, 9, 0,15, 8 },
/* 4 */{ 0,10, 6,15, 0, 1 },
/* 5 */{ 0, 3, 2, 8, 1, 0 } };
public void map(Object key, Text value, Context context
) throws IOException, InterruptedException {
String[] str = value.toString().split(" ");
int[][] initialPopulation = new int[str.length][5];
for (int i = 0; i < str.length; i++) {
String[] s2 = str[i].split("");
for (int j = 0; j < initialPopulation[i].length; j++) {
initialPopulation[i][j]=Integer.valueOf(s2[j+1]);
}
}
int[][] nextGeneration = new int[initialPopulation.length][5];
int[][] next = new int[initialPopulation.length][5];
//由初始族群產生下一代
next = doGA(initialPopulation);
//進行50次迭代
for (int i = 0; i < 1000; i++) {
nextGeneration = next.clone();
next = doGA(nextGeneration);
}
for (int i = 0; i < next.length; i++) {
for (int j = 0; j < next[i].length; j++) {
System.out.printf("%d ",next[i][j]);
}
System.out.printf("%d " ,getFitness(next[i]));
System.out.println();
}
System.out.println();
//取出最佳解
int[] fitnessArray = new int[initialPopulation.length];
for (int i = 0; i < next.length; i++) {
fitnessArray[i]=getFitness(next[i]);
}
fitnessArray = quickSort(fitnessArray, 0, fitnessArray.length-1);
for (int i = 0; i < next.length; i++) {
int f = getFitness(next[i]);
int x= 0;
if (f == fitnessArray[0]) {
for (int j = 0; j < i; j++) {
if(Arrays.equals(next[i], next[j]))
x++;
}
if(x == 0){
String outKey = Arrays.toString(next[i]);
String outValue = String.valueOf(f);
context.write(new Text(outKey),new Text(outValue));
}
}
}
}// end constructor