public MongoStreamRecordReader(InputSplit split, JobConf conf) throws IOException {

		// determine if any locations are local 
		ArrayList<String> sortedLocations = new ArrayList<String>();
		ArrayList<String> localLocations = new ArrayList<String>();
		ArrayList<String> remoteLocations = new ArrayList<String>();
		
		InetAddress local = InetAddress.getLocalHost();
		
		
		// see if any of these is local
		for(String loc : split.getLocations()) {
			String[] parts = loc.split(":");
			
			InetAddress host = InetAddress.getByName(parts[0]);
			
			if(local.equals(host)) {
				System.err.println(loc + " is local");
				localLocations.add(loc);
			}
			else {
				remoteLocations.add(loc);
			}
		}
		
		if(localLocations.size() == 0)
			System.err.println("no input split locations are local");
		
		// try local first, then remote
		for(String loc : localLocations)
			sortedLocations.add(loc);
		for(String loc : remoteLocations)
			sortedLocations.add(loc);
		
		
		// read from one of the locations for this shard
		for(String loc : split.getLocations()) {
			try {
				connect(loc, conf);
				return;
			}
			catch (IOException e) {
				// try another location
				System.err.println("trying another location for input split");
			}
		}

		String locs = "";
		for(String loc : split.getLocations())
			locs += loc + ", ";

		throw new IOException("could not read from any replicas for shard locations: " + locs);

		// this means the MapReduce will fail - unless maybe the user says not to ...	
	}