job_local670513569_0001 java.lang.Exception: java.lang.StringIndexOutOfBoundsException: String index out of

多学习多思考 发布于 2016/03/14 13:46
阅读 1K+
收藏 0
016-03-14 13:43:03,430 INFO  [LocalJobRunner Map Task Executor #0] mapred.MapTask (MapTask.java:flush(1437)) - Starting flush of map output
2016-03-14 13:43:03,430 INFO  [LocalJobRunner Map Task Executor #0] mapred.MapTask (MapTask.java:flush(1455)) - Spilling map output
2016-03-14 13:43:03,430 INFO  [LocalJobRunner Map Task Executor #0] mapred.MapTask (MapTask.java:flush(1456)) - bufstart = 0; bufend = 20988; bufvoid = 104857600
2016-03-14 13:43:03,431 INFO  [LocalJobRunner Map Task Executor #0] mapred.MapTask (MapTask.java:flush(1458)) - kvstart = 26214396(104857584); kvend = 26211400(104845600); length = 2997/6553600
2016-03-14 13:43:03,447 INFO  [LocalJobRunner Map Task Executor #0] mapred.MapTask (MapTask.java:sortAndSpill(1641)) - Finished spill 0
2016-03-14 13:43:03,449 INFO  [Thread-12] mapred.LocalJobRunner (LocalJobRunner.java:runTasks(456)) - map task executor complete.
2016-03-14 13:43:03,466 WARN  [Thread-12] mapred.LocalJobRunner (LocalJobRunner.java:run(560)) - job_local670513569_0001
java.lang.Exception: java.lang.StringIndexOutOfBoundsException: String index out of range: -335
at org.apache.hadoop.mapred.LocalJobRunner$Job.runTasks(LocalJobRunner.java:462)
at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:522)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -335
at java.lang.String.substring(String.java:1967)
at cn.test.hadoop.mr.wc.house.WCMapper.map(WCMapper.java:45)
at cn.test.hadoop.mr.wc.house.WCMapper.map(WCMapper.java:1)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:340)
at org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:243)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2016-03-14 13:43:03,771 INFO  [communication thread] mapred.LocalJobRunner (LocalJobRunner.java:statusUpdate(591)) - map > sort
2016-03-14 13:43:03,885 INFO  [main] mapreduce.Job (Job.java:monitorAndPrintJob(1375)) - Job job_local670513569_0001 failed with state FAILED due to: NA
2016-03-14 13:43:03,958 INFO  [main] mapreduce.Job (Job.java:monitorAndPrintJob(1380)) - Counters: 26
File System Counters
FILE: Number of bytes read=83941
FILE: Number of bytes wri
加载中
0
多学习多思考
多学习多思考

找到了很多问题,直接用try ,catch 包住,直接跳过bug


0
ProgrammerJiang
ProgrammerJiang
可能是环形缓冲区那块溢出有问题了,你把你的WCMapper贴出来看看
ProgrammerJiang
ProgrammerJiang
这代码、切割有问题吧、你debug 一步一步看。
多学习多思考
多学习多思考
亲哥,我用6台节点,来跑个1.5G的日志文件,跑原生的workcount程序可以跑,为何我写的不行呀??
多学习多思考
多学习多思考
发了出来了,麻烦你看看
0
多学习多思考
多学习多思考

引用来自“ProgrammerJiang”的评论

可能是环形缓冲区那块溢出有问题了,你把你的WCMapper贴出来看看
package cn.test.hadoop.mr.wc.house;
import java.io.IOException;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import cn.test.utils.ReplaceUtil;
public class WCMapper extends Mapper<LongWritable, Text, Text, LongWritable> {
	@Override
	protected void map(LongWritable key, Text value, Context context)  {
		//\u63a5\u6536\u4e00\u884c\u6570\u636e
	
		String li2ne = value.toString();
		//\u5206\u5272
//		String[] words = li2ne.split("houseId");
	/*	//\u8fed\u4ee3
		for(String w : words){
			
			
			//\u53d1\u9001
			System.out.println(w);
			context.write(new Text(w), new LongWritable(1));
		}*/
		
		if(null != li2ne && li2ne.contains("houseId")&&li2ne.contains("userid")){
			
			String houseUser="";
			
			String houseId= li2ne.substring(li2ne.indexOf("houseId")+8, li2ne.lastIndexOf("houseId"));
		    		
		    houseId=ReplaceUtil.rePlex(houseId);
		
		    // just for speical  number
		    if(houseId.contains("houseId")){
		    	houseId=houseId.substring(0, houseId.indexOf("houseId"));
			    System.out.println("-2h2-" + houseId );
		    }
			
		    if(houseId.contains("freeType")){
		    	houseId=houseId.substring(0, houseId.indexOf("freeType"));
			    System.out.println("-fr-" + houseId );
		    }
		    
		    String userid="";
		  
		    if(userid.contains("smallAreaCode")== false){
		       userid=li2ne.substring(li2ne.indexOf("userid")+8, li2ne.indexOf("smallAreaCode"));
				System.out.println("--small----"   + userid);
		    }else{
				System.out.println("--Code----"   + userid);
		    	userid=li2ne.substring(li2ne.indexOf("userid")+8, li2ne.length());
		    }
		
			userid=ReplaceUtil.rePlex(userid);
			
//			houseUser= "u:"+userid+",h:"+houseId;
			houseUser= userid+","+houseId;
			System.out.println("---houseUser---"   + houseUser);
			if(50 <houseUser.length()){
				System.out.println( li2ne);
			}
			
			try {
				context.write(new Text(houseUser), new LongWritable(1));
			} catch (IOException e) {
				e.printStackTrace();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
}



0
卧枝会中田
卧枝会中田

异常 和 异常链 这不不都写的清清楚楚么?

Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -335
at java.lang.String.substring(String.java:1967)
at cn.test.hadoop.mr.wc.house.WCMapper.map(WCMapper.java:45)
at cn.test.hadoop.mr.wc.house.WCMapper.map(WCMapper.java:1)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:340)
at org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:243)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2016-03-14 13:43:03,771 INFO  [communication thread] mapred.LocalJobRunner (LocalJobRunner.java:statusUpdate(591)) - map > sort
2016-03-14 13:43:03,885 INFO  [main] mapreduce.Job (Job.java:monitorAndPrintJob(1375)) - Job job_local670513569_0001 failed with state FAILED due to: NA
2016-03-14 13:43:03,958 INFO  [main] mapreduce.Job (Job.java:monitorAndPrintJob(1380)) - Counters: 26
File System Counters
FILE: Number of bytes read=83941
FILE: Number of bytes wri

多学习多思考
多学习多思考
我也看到了
多学习多思考
多学习多思考
谢谢,提醒,问题已经解决了,写的不太注意, 多谢关心,数据顺利出来了!
返回顶部
顶部