You can use this getFileBlockLocations method of Filesystem class which will return an array containing hostname, offsets & size of portions of the given file.
BlockLocation[] blkLoc = fs.getFileBlockLocations(file, 0, length);
You call this method inside JobClient. The results are written in a SequenceFile. The ResourceManager later reads the file while initializing the job.
When you are extending (inheriting) FileInputFormat you will return a list of InputSplit. While initializing the job it is important to specify the location of Input Splits.
public FileSplit(Path file, long start, long length, String[] hosts)
You are not implementing data locality, but you are telling the where the input splits can be found.