Convenience override for int ids.

@param finalJobFolderPath
@return
@throws IOException
190745
public JobFolder createJobFolder(final String finalJobFolderPath) throws IOException {
    LOG.log(Level.FINE, "Final job submission Directory: " + finalJobFolderPath);
    return new JobFolder(this.fileSystem, new Path(finalJobFolderPath));
  }
976950
public Path getInputFileForWrite(TaskID mapId, TaskAttemptID reduceTaskId, 
                                   long size)
    throws IOException {
    // TODO *oom* should use a format here
    return lDirAlloc.getLocalPathForWrite(TaskTracker.getIntermediateOutputDir(
                       jobId.toString(), reduceTaskId.toString())
                       + "/map_" + mapId.getId() + ".out", 
                       size, conf);
  }
1049443
public static int[] getBusIds() throws IOException {
        Set<Integer> set = null;
        for (Path device: Files.newDirectoryStream(Paths.get("/sys/bus/i2c/devices"), "*")) {
            String[] tokens = device.toString().split("-");
            if (tokens.length == 2) {
                if (set == null) {
                    set = new HashSet<Integer>();
                }
                set.add(Integer.valueOf(tokens[1]));
            }
        }

        int[] result = null;
        if (set != null) {
            int counter = 0;
            result = new int[set.size()];
            for (Integer value : set) {
                result[counter] = value.intValue();
                counter = counter + 1;
            }
        }
        return result;
    }
676684
@Override
  public void readFields(DataInput in) throws IOException {
    this.filename = Text.readString(in);
    this.jobid = Text.readString(in);
    this.isJobConfFile = in.readBoolean();
    this.isJobHistoryFile = in.readBoolean();
  }
829742
public static List<File> getFilesInDir(final File inputPath) {
    final List<File> fileList = new ArrayList<File>();
    for (final File aFile : Files.fileTreeTraverser().preOrderTraversal(
        inputPath)) {
      if (aFile.isFile()) {
        fileList.add(aFile);
      }
    }
    return fileList;
  }
467039
public void load(File file,boolean ids) throws IOException,FileNotFoundException
    {
	LineNumberReader in = new LineNumberReader(new FileReader(file));
	String line;
	while ((line = in.readLine())!=null) {
	    if (ids) put(Integer.toString(in.getLineNumber()), line, line);
	    else put(line,line);
	}
	in.close();
    }
714118
private void jarDir(File dirOrFile2jar, JarOutputStream jos, String path)
		throws IOException {
		if (mVerbose) {
			System.out.println("checking " + dirOrFile2jar);
		}
		if (dirOrFile2jar.isDirectory()) {
			String[] dirList = dirOrFile2jar.list();
			String subPath = (path == null) ? "" : (path + dirOrFile2jar.getName() + SEP);
			if (path != null) {
				JarEntry je = new JarEntry(subPath);
				je.setTime(dirOrFile2jar.lastModified());
				jos.putNextEntry(je);
				jos.flush();
				jos.closeEntry();
			}
			for (int i = 0; i < dirList.length; i++) {
				File f = new File(dirOrFile2jar, dirList[i]);
				jarDir(f, jos, subPath);
			}
		} else if (dirOrFile2jar.exists()) {
			if (dirOrFile2jar.getCanonicalPath().equals(mDestJarName)) {
				if (mVerbose) {
					System.out.println("skipping " + dirOrFile2jar.getPath());
				}
				return;
			}

			if (mVerbose) {
				System.out.println("adding " + dirOrFile2jar.getPath());
			}
			FileInputStream fis = new FileInputStream(dirOrFile2jar);
			try {
				JarEntry entry = new JarEntry(path + dirOrFile2jar.getName());
				entry.setTime(dirOrFile2jar.lastModified());
				jos.putNextEntry(entry);
				while ((mByteCount = fis.read(mBuffer)) != -1) {
					jos.write(mBuffer, 0, mByteCount);
					if (mVerbose) {
						System.out.println("wrote " + mByteCount + " bytes");
					}
				}
				jos.flush();
				jos.closeEntry();
			} catch (IOException ioe) {
				throw ioe;
			} finally {
				fis.close();
			}
		}
	}
897298
@Override
	public IJobXMLSource loadJSL(String id) {

		IJobXMLSource jobXML = loadJobFromDirectory(JOB_XML_PATH, id);

		return jobXML;
	}
421151
private int getFileId(Path filePath, Connection conn) throws SQLException {
        int fileId = readFileId(filePath, conn);
        if (fileId == -1) {
            Statement stmt = conn.createStatement();
            String insertFileSql = "insert into file (path, name) values ('" + filePath.getParent()
                    + "', '" + filePath.getFileName() + "');";
            stmt.executeUpdate(insertFileSql);
            stmt.close();

            fileId = readFileId(filePath, conn);
            if (fileId == -1) {
                throw new InternalError("Impossible to read the ID for the file " + filePath + " in database "
                        + databasePath);
            }

            stmt.close();
        }

        return fileId;
    }
432455
public static List<String> couchStyleRevisionHistoryToFullRevisionIDs(final int start, List<String> ids) {
        List<String> revisionHistory = new ArrayList<String>();
        int generation = start;
        for (String revIdHash : ids) {
            revisionHistory.add(generation + "-" + revIdHash);
            generation--;
        }
        Collections.reverse(revisionHistory);
        return revisionHistory;
    }
584234
private static int getMapperId(long key, int numReducers, int maxKeySpace) {
    key = key - getFirstSumKey(numReducers, maxKeySpace);
    return (int) (key / numReducers);
  }
400919
public static JobId of(String project, String job) {
    return newBuilder().setProject(checkNotNull(project)).setJob(checkNotNull(job)).build();
  }
1016381
public List<Integer> getQueuedFlowIds() {
    final List<Integer> allIds = new ArrayList<>();
    try {
      getExecutionIdsHelper(allIds, this.executorLoader.fetchQueuedFlows());
    } catch (final ExecutorManagerException e) {
      this.logger.error("Failed to get queued flow ids.", e);
    }
    return allIds;
  }
524438
private int readID3v2Header(InputStream in) throws IOException
	{		
		byte[] id3header = new byte[4];
		int size = -10;
		in.read(id3header,0,3);
		// Look for ID3v2
		if ( (id3header[0]=='I') && (id3header[1]=='D') && (id3header[2]=='3'))
		{
			in.read(id3header,0,3);
			//int majorVersion = id3header[0];
			//int revision = id3header[1];
			in.read(id3header,0,4);
			size = (int) (id3header[0] << 21) + (id3header[1] << 14) + (id3header[2] << 7) + (id3header[3]);
		}
		return (size+10);
	}
716714
public static void addInputPath(Job job, 
                                  Path path) throws IOException {
    Configuration conf = job.getConfiguration();
    FileSystem fs = FileSystem.get(conf);
    path = path.makeQualified(fs);
    String dirStr = StringUtils.escapeString(path.toString());
    String dirs = conf.get("mapred.input.dir");
    conf.set("mapred.input.dir", dirs == null ? dirStr : dirs + "," + dirStr);
  }
696878
TaskDeploymentDescriptor createDeploymentDescriptor(
			ExecutionAttemptID executionId,
			LogicalSlot targetSlot,
			@Nullable JobManagerTaskRestore taskRestore,
			int attemptNumber) throws ExecutionGraphException {

		// Produced intermediate results
		List<ResultPartitionDeploymentDescriptor> producedPartitions = new ArrayList<>(resultPartitions.size());

		// Consumed intermediate results
		List<InputGateDeploymentDescriptor> consumedPartitions = new ArrayList<>(inputEdges.length);

		boolean lazyScheduling = getExecutionGraph().getScheduleMode().allowLazyDeployment();

		for (IntermediateResultPartition partition : resultPartitions.values()) {

			List<List<ExecutionEdge>> consumers = partition.getConsumers();

			if (consumers.isEmpty()) {
				//TODO this case only exists for test, currently there has to be exactly one consumer in real jobs!
				producedPartitions.add(ResultPartitionDeploymentDescriptor.from(
						partition,
						KeyGroupRangeAssignment.UPPER_BOUND_MAX_PARALLELISM,
						lazyScheduling));
			} else {
				Preconditions.checkState(1 == consumers.size(),
						"Only one consumer supported in the current implementation! Found: " + consumers.size());

				List<ExecutionEdge> consumer = consumers.get(0);
				ExecutionJobVertex vertex = consumer.get(0).getTarget().getJobVertex();
				int maxParallelism = vertex.getMaxParallelism();
				producedPartitions.add(ResultPartitionDeploymentDescriptor.from(partition, maxParallelism, lazyScheduling));
			}
		}

		final InputChannelDeploymentDescriptor[] icddArray = new InputChannelDeploymentDescriptor[0];

		for (ExecutionEdge[] edges : inputEdges) {
			List<InputChannelDeploymentDescriptor> partitions = InputChannelDeploymentDescriptor.fromEdges(
				Arrays.asList(edges),
				lazyScheduling);

			// If the produced partition has multiple consumers registered, we
			// need to request the one matching our sub task index.
			// TODO Refactor after removing the consumers from the intermediate result partitions
			int numConsumerEdges = edges[0].getSource().getConsumers().get(0).size();

			int queueToRequest = subTaskIndex % numConsumerEdges;

			IntermediateResult consumedIntermediateResult = edges[0].getSource().getIntermediateResult();
			final IntermediateDataSetID resultId = consumedIntermediateResult.getId();
			final ResultPartitionType partitionType = consumedIntermediateResult.getResultType();

			consumedPartitions.add(new InputGateDeploymentDescriptor(resultId, partitionType, queueToRequest, partitions.toArray(icddArray)));
		}

		final Either<SerializedValue<JobInformation>, PermanentBlobKey> jobInformationOrBlobKey = getExecutionGraph().getJobInformationOrBlobKey();

		final TaskDeploymentDescriptor.MaybeOffloaded<JobInformation> serializedJobInformation;

		if (jobInformationOrBlobKey.isLeft()) {
			serializedJobInformation = new TaskDeploymentDescriptor.NonOffloaded<>(jobInformationOrBlobKey.left());
		} else {
			serializedJobInformation = new TaskDeploymentDescriptor.Offloaded<>(jobInformationOrBlobKey.right());
		}

		final Either<SerializedValue<TaskInformation>, PermanentBlobKey> taskInformationOrBlobKey;

		try {
			taskInformationOrBlobKey = jobVertex.getTaskInformationOrBlobKey();
		} catch (IOException e) {
			throw new ExecutionGraphException(
				"Could not create a serialized JobVertexInformation for " +
					jobVertex.getJobVertexId(), e);
		}

		final TaskDeploymentDescriptor.MaybeOffloaded<TaskInformation> serializedTaskInformation;

		if (taskInformationOrBlobKey.isLeft()) {
			serializedTaskInformation = new TaskDeploymentDescriptor.NonOffloaded<>(taskInformationOrBlobKey.left());
		} else {
			serializedTaskInformation = new TaskDeploymentDescriptor.Offloaded<>(taskInformationOrBlobKey.right());
		}

		return new TaskDeploymentDescriptor(
			getJobId(),
			serializedJobInformation,
			serializedTaskInformation,
			executionId,
			targetSlot.getAllocationId(),
			subTaskIndex,
			attemptNumber,
			targetSlot.getPhysicalSlotNumber(),
			taskRestore,
			producedPartitions,
			consumedPartitions);
	}
1319725
@Override
  public int compareTo(ID o) {
    TaskID that = (TaskID)o;
    int jobComp = this.jobId.compareTo(that.jobId);
    if(jobComp == 0) {
      if(this.isMap == that.isMap) {
        return this.id - that.id;
      }
      else return this.isMap ? -1 : 1;
    }
    else return jobComp;
  }