private DatanodeID[] getDatanodes(HttpServletRequest request)
  throws IOException {
    final String datanodes = request.getParameter("candidates");
    if (datanodes == null) {
      return null;
    }
    final String[] datanodeStrs = datanodes.split(" ");
    if (datanodeStrs.length == 0) {
      return null;
    }
    final DatanodeID[] dnIDs = new DatanodeID[datanodeStrs.length];
    for (int i=0; i<dnIDs.length; i++) {
      String hostName = datanodeStrs[i];
      int colon = datanodeStrs[i].indexOf(":");
      if (colon < 0) {
        throw new IOException("Invalid datanode name " + 
            datanodeStrs[i] + ", expecting name:port pair");
      } 
      hostName = datanodeStrs[i].substring(0, colon);
      int infoPort;
      try {
        infoPort = Integer.parseInt(datanodeStrs[i].substring(colon+1));
      } catch (NumberFormatException ne) {
        throw new IOException("Invalid datanode name " + 
            datanodeStrs[i] + ", expecting name:port pair", ne);
      }
      dnIDs[i] = new DatanodeID(hostName, null, infoPort, -1);
    }
    return dnIDs;
  }
private DatanodeID [ ] getDatanodes ( HttpServletRequest request ) throws IOException { final String datanodes = request . getParameter ( "candidates" ) ; if ( datanodes == null ) { return null ; } final String [ ] datanodeStrs = datanodes . split ( " " ) ; if ( datanodeStrs . length == 0 ) { return null ; } final DatanodeID [ ] dnIDs = new DatanodeID [ datanodeStrs . length ] ; for ( int i = 0 ; i < dnIDs . length ; i ++ ) { String hostName = datanodeStrs [ i ] ; int colon = datanodeStrs [ i ] . indexOf ( ":" ) ; if ( colon < 0 ) { throw new IOException ( "Invalid datanode name " + datanodeStrs [ i ] + ", expecting name:port pair" ) ; } hostName = datanodeStrs [ i ] . substring ( 0 , colon ) ; int infoPort ; try { infoPort = Integer . parseInt ( datanodeStrs [ i ] . substring ( colon + 1 ) ) ; } catch ( NumberFormatException ne ) { throw new IOException ( "Invalid datanode name " + datanodeStrs [ i ] + ", expecting name:port pair" , ne ) ; } dnIDs [ i ] = new DatanodeID ( hostName , null , infoPort , - 1 ) ; } return dnIDs ; }
Get the datanode candidates from the request