this time someone has to react I am struggling with running my code using a distributed cache. I already have the files on hdfs, but when I run this code:
import java.awt.image.BufferedImage; import java.awt.image.DataBufferByte; import java.awt.image.Raster; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; import org.apache.hadoop.filecache.*; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.*; import org.apache.hadoop.mapred.*; import java.lang.String; import java.lang.Runtime; import java.net.URI; import java.util.StringTokenizer; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FSDataInputStream; public class blur2 { public static class BlurMapper extends MapReduceBase implements Mapper<Text, BytesWritable, LongWritable, BytesWritable> { OutputCollector<LongWritable, BytesWritable> goutput; int IMAGE_HEIGHT = 240; int IMAGE_WIDTH = 320; public BytesWritable Gmiu; public BytesWritable Gsigma; public BytesWritable w; byte[] bytes = new byte[IMAGE_HEIGHT*IMAGE_WIDTH*3]; public BytesWritable emit = new BytesWritable(bytes); int count = 0; int initVar = 125; public LongWritable l = new LongWritable(1); byte[] byte1 = new byte[IMAGE_HEIGHT*IMAGE_WIDTH]; byte[] byte2 = new byte[IMAGE_HEIGHT*IMAGE_WIDTH]; byte[] byte3 = new byte[IMAGE_HEIGHT*IMAGE_WIDTH]; public void map(Text key, BytesWritable file,OutputCollector<LongWritable, BytesWritable> output, Reporter reporter) throws IOException { goutput = output; BufferedImage img = ImageIO.read(new ByteArrayInputStream(file.getBytes())); Raster ras=img.getData(); DataBufferByte db= (DataBufferByte)ras.getDataBuffer(); byte[] data = db.getData(); if(count==0){ for(int i=0;i<IMAGE_HEIGHT*IMAGE_WIDTH;i++) { byte1[i]=20; byte2[i]=125; } Gmiu = new BytesWritable(data); Gsigma = new BytesWritable(byte1); w = new BytesWritable(byte2); count++; } else{ byte1 = Gmiu.getBytes(); byte2 = Gsigma.getBytes(); byte3 = w.getBytes(); for(int i=0;i<IMAGE_HEIGHT*IMAGE_WIDTH;i++) { byte pixel = data[i]; Double tempmiu=new Double(0.0); Double tempsig=new Double(0.0); double temp1=0.0; double alpha = 0.05; tempmiu = (1-alpha)*byte1[i] + alpha*pixel; temp1=temp1+(pixel-byte1[i])*(pixel-byte1[i]); tempsig=(1-alpha)*byte2[i]+ alpha*temp1; byte1[i] = tempmiu.byteValue(); byte2[i]= tempsig.byteValue(); Double w1=new Double((1-alpha)*byte3[i]+alpha*100); byte3[i] = w1.byteValue(); } Gmiu.set(byte1,0,IMAGE_HEIGHT*IMAGE_WIDTH); Gsigma.set(byte2,0,IMAGE_HEIGHT*IMAGE_WIDTH); w.set(byte3,0,IMAGE_HEIGHT*IMAGE_WIDTH); } byte1 = Gsigma.getBytes(); for(int i=0;i<IMAGE_HEIGHT*IMAGE_WIDTH;i++) { bytes[i]=byte1[i]; } byte1 = Gsigma.getBytes(); for(int i=0;i<IMAGE_HEIGHT*IMAGE_WIDTH;i++) { bytes[IMAGE_HEIGHT*IMAGE_WIDTH+i]=byte1[i]; } byte1 = w.getBytes(); for(int i=0;i<IMAGE_HEIGHT*IMAGE_WIDTH;i++) { bytes[2*IMAGE_HEIGHT*IMAGE_WIDTH+i]=byte1[i]; } emit.set(bytes,0,3*IMAGE_HEIGHT*IMAGE_WIDTH); } @Override public void close(){ try{ goutput.collect(l, emit); } catch(Exception e){ e.printStackTrace(); System.exit(-1); } } }
took a lot of space with this, can someone tell me why I get this error:
java.io.FileNotFoundException: File does not exist: ~/ayush/output/part-00000 at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:394) at org.apache.hadoop.filecache.DistributedCache.getTimestamp(DistributedCache.java:475) at org.apache.hadoop.mapred.JobClient.configureCommandLineOptions(JobClient.java:676) at org.apache.hadoop.mapred.JobClient.submitJob(JobClient.java:774) at org.apache.hadoop.mapred.JobClient.runJob(JobClient.java:1127) at blur2.main(blur2.java:175) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.hadoop.util.RunJar.main(RunJar.java:165) at org.apache.hadoop.mapred.JobShell.run(JobShell.java:54) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79) at org.apache.hadoop.mapred.JobShell.main(JobShell.java:68)
java caching hadoop distributed
ayush singhal
source share