/** * Start the {@link TaskScheduler}. * * @param name the name of the {@link TaskScheduler} */ @Override final void startImpl(Optional<String> name) { this.executorService = ExecutorsUtils.loggingDecorator(Executors.newScheduledThreadPool(0, ExecutorsUtils.newDaemonThreadFactory(Optional.of(LOGGER), name))); }
@Override public void startImpl() { this.executor = Executors.newSingleThreadScheduledExecutor( ExecutorsUtils.newDaemonThreadFactory(Optional.of(log), Optional.of("metrics-" + name + "-scheduler"))); this.reportingPeriodSeconds = parsePeriodToSeconds( config.hasPath(REPORTING_INTERVAL) ? config.getString(REPORTING_INTERVAL) : DEFAULT_REPORTING_INTERVAL_PERIOD); ensureMetricFilterIsInitialized(config); this.scheduledTask = Optional.<ScheduledFuture>of(this.executor.scheduleAtFixedRate(new Runnable() { @Override public void run() { report(); } }, 0, this.reportingPeriodSeconds, TimeUnit.SECONDS)); }
protected void executeItertorExecutor(Iterator<Callable<Void>> callableIterator) throws IOException { try { IteratorExecutor<Void> executor = new IteratorExecutor<>(callableIterator, this.threadPoolSize, ExecutorsUtils.newDaemonThreadFactory(Optional.of(log), Optional.of(this.getClass().getSimpleName()))); List<Either<Void, ExecutionException>> results = executor.executeAndGetResults(); IteratorExecutor.logFailures(results, log, 10); } catch (InterruptedException ie) { throw new IOException("Dataset finder is interrupted.", ie); } }
List<Either<Void, ExecutionException>> results = new IteratorExecutor<>(callableIterator, this.threadPoolOfGettingDatasetState, ExecutorsUtils.newDaemonThreadFactory(Optional.of(LOGGER), Optional.of("GetFsDatasetStateStore-"))) .executeAndGetResults(); int maxNumberOfErrorLogs = 10;
List<Either<Void, ExecutionException>> executionResults = new IteratorExecutor<>(callableIterator, this.getTaskCommitThreadPoolSize(), ExecutorsUtils.newDaemonThreadFactory(Optional.of(log), Optional.of("Task-committing-pool-%d"))) .executeAndGetResults(); IteratorExecutor.logFailures(executionResults, log, 10);
List<Future<Void>> futures = new IteratorExecutor<>(callableIterator, maxThreads, ExecutorsUtils.newDaemonThreadFactory(Optional.of(log), Optional.of("Copy-file-listing-pool-%d"))) .execute();