code: DatanodeDescriptor[] getValidTargets() {
      if (targetGSs == null) {
        return null;
      }
      int count = 0;
      long lastBlockGS = this.getLastBlock().getGenerationStamp();
      for (long targetGS : targetGSs) {
        if (lastBlockGS == targetGS) {
          count++;
        }
      }
      if (count == 0) {
        return null;
      } if (count == targets.length) {
        return targets;
      } else {
        DatanodeDescriptor[] validTargets = new DatanodeDescriptor[count];
        for (int i=0, numOfValidTargets=0; i<targets.length; i++) {
          if (lastBlockGS == targetGSs[i]) {
            validTargets[numOfValidTargets++] = targets[i];
            if (numOfValidTargets == count) {
              return validTargets;
            }
          }
        }
        return validTargets;
      }
    }
docs: Return the targets with generation stamp matching that of the last block