Filter some jobs being fed to the simulator. For now, we filter out killed
jobs to facilitate debugging.

@throws IOException
501490
private JobStory getNextJobFiltered() throws IOException {
    while (true) {
      ZombieJob job = producer.getNextJob();
      if (job == null) {
        return null;
      }
      if (job.getOutcome() == Pre21JobHistoryConstants.Values.KILLED) {
        continue;
      }
      if (job.getNumberMaps() == 0) {
        continue;
      }
      if (job.getNumLoggedMaps() == 0) {
        continue;
      }
      return job;
    }
  }
513083
public void disposeAll() {
        for( WeakReference<Com4jObject> ref : objects) {
        	Com4jObject o = ref.get();
        	if(o != null) {
        		o.dispose();
        	}
        }
        objects.clear();
    }
163624
public void setJobs(java.util.Collection<Job> jobs) {
        if (jobs == null) {
            this.jobs = null;
            return;
        }

        this.jobs = new java.util.ArrayList<Job>(jobs);
    }
51883
public void dispose() {
        LOGGER.debug("dispose all Filters for FilterFactory {}...", factory.getClass().getName());
        synchronized (filterCache) {
            if (maintainLifeCycle) {
                Collection<Filter> values = filterCache.values();
                for (Filter filter : values) {
                    try {
                        filter.destroy();
                    } catch (RuntimeException e) {
                        LOGGER.warn("RuntimeException while calling destroy() of filter {}", filter.getClass()
                            .getName(), e);
                    }
                }
            }
            filterCache.clear();
        }
    }
445252
public void close() throws IOException {
    LOG.info(getTask()+" done; removing files.");
    getTask().getProgress().setStatus("closed");
    mapOutputFile.removeAll(getTask().getTaskID());
  }
1275467
public void clear() {
    for (final Pair<ExecutionReference, ExecutableFlow> pair : this.queuedFlowMap.values()) {
      dequeue(pair.getFirst().getExecId());
    }
  }
1264279
public void flush() throws IOException
  {
      if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
      {
        Tr.debug(tc, "flush");
      }
      this.output.flush();
  }
1118753
@Override
  public void onFileDelete(Path rawPath) {
    URI jobSpecUri = this.converter.computeURI(rawPath);
    // TODO: fix version
    listeners.onDeleteJob(jobSpecUri, null);
  }
1229095
public void clean() throws IOException {
    List<Dataset> dataSets = this.datasetFinder.findDatasets();
    this.finishCleanSignal = Optional.of(new CountDownLatch(dataSets.size()));
    for (final Dataset dataset : dataSets) {
      ListenableFuture<Void> future = this.service.submit(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
          if (dataset instanceof CleanableDataset) {
            ((CleanableDataset) dataset).clean();
          }
          return null;
        }
      });
      Futures.addCallback(future, new FutureCallback<Void>() {
        @Override
        public void onFailure(Throwable throwable) {
          DatasetCleaner.this.finishCleanSignal.get().countDown();
          LOG.warn("Exception caught when cleaning " + dataset.datasetURN() + ".", throwable);
          DatasetCleaner.this.throwables.add(throwable);
          Instrumented.markMeter(DatasetCleaner.this.datasetsCleanFailureMeter);
          DatasetCleaner.this.eventSubmitter.submit(RetentionEvents.CleanFailed.EVENT_NAME,
              ImmutableMap.of(RetentionEvents.CleanFailed.FAILURE_CONTEXT_METADATA_KEY,
                  ExceptionUtils.getFullStackTrace(throwable), RetentionEvents.DATASET_URN_METADATA_KEY,
                  dataset.datasetURN()));
        }

        @Override
        public void onSuccess(Void arg0) {
          DatasetCleaner.this.finishCleanSignal.get().countDown();
          LOG.info("Successfully cleaned: " + dataset.datasetURN());
          Instrumented.markMeter(DatasetCleaner.this.datasetsCleanSuccessMeter);
        }
      });
    }
  }
685841
@Override
  public void clear() throws IOException {
    DBUtils.runInsert(connectionFactory, CLEAR_SQL, DBUtils.EMPTY_SQL_PARAMS,
        sqlNumRetries);
    LOG.info("Clear all values");
  }
455886
public void filter(ClientRequestContext request) throws IOException
    {
        if(!request.getHeaders().containsKey("X-Query-Key"))
            request.getHeaders().add("X-Query-Key", this.querykey);
    }
254508
void selectJobsToInitialize() {
    for (String queue : jobQueues.keySet()) {
      ArrayList<JobInProgress> jobsToInitialize = getJobsToInitialize(queue);
      printJobs(jobsToInitialize);
      JobInitializationThread t = threadsToQueueMap.get(queue);
      for (JobInProgress job : jobsToInitialize) {
        t.addJobsToQueue(queue, job);
      }
    }
  }
643995
private void clearNioBuffers() {
        int count = nioBufferCount;
        if (count > 0) {
            nioBufferCount = 0;
            Arrays.fill(NIO_BUFFERS.get(), 0, count, null);
        }
    }
410629
public synchronized void close() throws IOException {
        if (!opened) {
            return;
        }
        //
        opened = false;
        accessor.close();
        appender.close();
        hints.clear();
        inflightWrites.clear();
        //
        if (managedWriter) {
            ((ExecutorService) writer).shutdown();
            writer = null;
        }
        if (managedDisposer) {
            disposer.shutdown();
            disposer = null;
        }
    }
828999
@Override
    public void filterWrite(NextFilter nextFilter, IoSession session,
            WriteRequest writeRequest) throws Exception {

        Object data = writeRequest.getMessage();

        if (data instanceof IoBuffer) {
            write(session, (IoBuffer) data);
        } else {
            throw new IllegalArgumentException(
                    "This filter should only buffer IoBuffer objects");
        }
    }
650644
private void populateTasks(List<Flow> flows) throws IOException {
    if (flows == null || flows.size() == 0) {
      return;
    }

    // for simplicity, we assume that flows are ordered and consecutive
    JobKey startJob = null;
    // find the first job
    for (Flow f : flows) {
      List<JobDetails> jobs = f.getJobs();
      if (jobs != null && jobs.size() > 0) {
        startJob = jobs.get(0).getJobKey();
        break;
      }
    }

    if (startJob == null) {
      LOG.info("No start job found for flows");
      return;
    }

    byte[] startKey =
        Bytes.add(jobKeyConv.toBytes(startJob), Constants.SEP_BYTES);
    Scan scan = new Scan();
    scan.setStartRow(startKey);
    // expect a lot of tasks on average
    scan.setCaching(500);

    Table taskTable = hbaseConnection
        .getTable(TableName.valueOf(Constants.HISTORY_TASK_TABLE));
    ResultScanner scanner = taskTable.getScanner(scan);
    try {
      Result currentResult = scanner.next();
      for (Flow f : flows) {
        for (JobDetails j : f.getJobs()) {
          // within each job we advance through the scanner til we pass keys
          // matching the current job
          while (currentResult != null && !currentResult.isEmpty()) {
            TaskKey taskKey = taskKeyConv.fromBytes(currentResult.getRow());
            // see if this task belongs to the current job
            int comparison = j.getJobKey().compareTo(taskKey);
            if (comparison < 0) {
              // advance to next job (without advancing current result)
              break;
            } else if (comparison > 0) {
              // advance tasks up to current job
            } else {
              // belongs to the current job
              TaskDetails task = new TaskDetails(taskKey);
              task.populate(
                  currentResult.getFamilyMap(Constants.INFO_FAM_BYTES));
              j.addTask(task);
            }
            currentResult = scanner.next();
          }
          if (LOG.isDebugEnabled()) {
            LOG.debug("Added " + j.getTasks().size() + " tasks to job "
                + j.getJobKey().toString());
          }
        }
      }
    } finally {
      scanner.close();
      taskTable.close();
    }
  }
231940
public void clear() throws IOException
   {
      if (out != null)
      {
         out.truncate(0);
         out.close();
         out = PrivilegedFileHelper.fileOutputStream(logFile).getChannel();
         out.position(1024 * fileSize - 1);
         out.write(ByteBuffer.wrap(new byte[]{0}));
         out.position(0);
         out.force(false);
      }
   }