SPARK-1767: Prefer HDFS-cached replicas when scheduling data-local tasks

This change reorders the replicas returned by
HadoopRDD#getPreferredLocations so that replicas cached by HDFS are at
the start of the list.  This requires Hadoop 2.5 or higher; previous
versions of Hadoop do not expose the information needed to determine
whether a replica is cached.
I don't understand what you mean by "the hadoop apis... [should be] inlined, and not accessed via reflection".  We need reflection to access the APIs; we can't call them directly since that would cause compatibility problems when using Spark with older Hadoop versions.  The HadoopRDD.NEW_HADOOP_CLASSES object is only initialized once, so you won't pay the cost of looking up the Hadoop classes multiple times.

The typecast is necessary since we don't know the type of what we're getting.  Even if we did know, there is no way to do an unsafe typecast in Scala (unlike C, Scala will always throw an exception if the typecast fails).  So we are as efficient as we can be, as far as I can see.  Let me know if I'm missing something.