@Override public long selectFiles(long targetSize, Collection<FileStatus> files) throws IOException { if (targetSize >= getSize()) { files.addAll(curdir); return getSize(); } Selector selector = new Selector(curdir.size(), (double) targetSize / getSize(), rand); ArrayList<Integer> selected = new ArrayList<Integer>(); long ret = 0L; do { int index = selector.next(); selected.add(index); ret += curdir.get(index).getLen(); } while (ret < targetSize); for (Integer i : selected) { files.add(curdir.get(i)); } return ret; }
public SleepJob(Configuration conf, long submissionMillis, JobStory jobdesc, Path outRoot, UserGroupInformation ugi, int seq, int numLocations, String[] hosts) throws IOException { super(conf, submissionMillis, jobdesc, outRoot, ugi, seq); this.fakeLocations = numLocations; this.hosts = hosts.clone(); this.selector = (fakeLocations > 0)? new Selector(hosts.length, (float) fakeLocations / hosts.length, rand.get()) : null; this.mapTasksOnly = conf.getBoolean(SLEEPJOB_MAPTASK_ONLY, false); mapMaxSleepTime = conf.getLong(GRIDMIX_SLEEP_MAX_MAP_TIME, Long.MAX_VALUE); reduceMaxSleepTime = conf.getLong(GRIDMIX_SLEEP_MAX_REDUCE_TIME, Long.MAX_VALUE); }
public SleepJob(Configuration conf, long submissionMillis, JobStory jobdesc, Path outRoot, UserGroupInformation ugi, int seq, int numLocations, String[] hosts) throws IOException { super(conf, submissionMillis, jobdesc, outRoot, ugi, seq); this.fakeLocations = numLocations; this.hosts = hosts; this.selector = (fakeLocations > 0)? new Selector(hosts.length, (float) fakeLocations / hosts.length, rand.get()) : null; this.mapTasksOnly = conf.getBoolean(SLEEPJOB_MAPTASK_ONLY, false); mapMaxSleepTime = conf.getLong(GRIDMIX_SLEEP_MAX_MAP_TIME, Long.MAX_VALUE); reduceMaxSleepTime = conf.getLong(GRIDMIX_SLEEP_MAX_REDUCE_TIME, Long.MAX_VALUE); }