code: private void executeWork() {
          StatusTrail st = null;        
          if ((st = newWorkQueue.removeFirst()) != null) {
              log.info("New task {}", st);
              DataSource ds = db().getDataSource(st.getDataSourceId());//TODO: Cache the DataSource table.
              String frozenSql = materializeTemplate(ds.getTemplateSql(), st.getNominalTime(), st.getNominalTime(), st.getNominalTime() + JobFreq.valueOf(ds.getFrequency()).inMillis());
              log.info("Sql is {}", frozenSql);
              Either<String, Either<Joiner4All, Mapper4All>> result = druidDriver.query(frozenSql, null, null, false, "sql", true);
              if (result.isLeft()) {
                  String taskId = result.left().get();// Because we forced async mode we will get back taskId.
                  log.info("Submitted task {} to overlord ", taskId);
                  st.setTaskId(taskId);
                  st.setStatus(JobStatus.in_progress);
                  db().updateStatusTrail(st);
                  // Quite possible st may exist in Q- when an item is removed and executed
                  // during which time if work generator generates the same st and 
                  // updates Q because it still found the ST as not_done.
                  if (newWorkQueue.contains(st)) {
                      newWorkQueue.remove(st);
                      log.warn("newWorkQueue had one more entry for st {} which was just set to in_progress", st);
                  }                
              } else {// Something wrong. Insert always returns left.
                  log.error("Got weird result (expected to run insert) {}", result.right().get());
              }
          }
      }
docs: Run the jobs which are eligible to run.