public Long getJob() {
		synchronized (lock) {
			long now = System.currentTimeMillis();
			Iterator<Entry<Long, Long>> iterator = runningJobs.entrySet().iterator();
			if (iterator.hasNext()) {
				Entry<Long, Long> entry = iterator.next();
				if ((entry.getValue() + 20000) < now) {
					pendingJobs.add(entry.getKey());
					iterator.remove();
				}
			}
			Long first = null;
			try {
				first = pendingJobs.removeFirst();
				runningJobs.put(first, System.currentTimeMillis());
			} catch (Exception e) {
			}
			log.info("Job counts: " + this + " returning " + first);
			return first;
		}
	}
Gets the id of next job.

@return the next job id, null if no more jobs exist
yarn/yarn/custom-amservice/src/main/java/org/springframework/yarn/examples/CustomAppmaster.java