Search in sources :

Example 1 with Capturable

use of org.apache.beam.runners.dataflow.worker.status.DebugCapture.Capturable in project beam by apache.

the class StreamingDataflowWorker method start.

public void start() {
    running.set(true);
    if (windmillServiceEnabled) {
        // Schedule the background getConfig thread. Blocks until windmillServer stub is ready.
        schedulePeriodicGlobalConfigRequests();
    }
    memoryMonitorThread.start();
    dispatchThread.start();
    commitThread.start();
    ExecutionStateSampler.instance().start();
    // Periodically report workers counters and other updates.
    globalWorkerUpdatesTimer = new Timer("GlobalWorkerUpdatesTimer");
    globalWorkerUpdatesTimer.schedule(new TimerTask() {

        @Override
        public void run() {
            reportPeriodicWorkerUpdates();
        }
    }, 0, options.getWindmillHarnessUpdateReportingPeriod().getMillis());
    refreshWorkTimer = new Timer("RefreshWork");
    if (options.getActiveWorkRefreshPeriodMillis() > 0) {
        refreshWorkTimer.schedule(new TimerTask() {

            @Override
            public void run() {
                refreshActiveWork();
            }
        }, options.getActiveWorkRefreshPeriodMillis(), options.getActiveWorkRefreshPeriodMillis());
    }
    if (windmillServiceEnabled && options.getStuckCommitDurationMillis() > 0) {
        int periodMillis = Math.max(options.getStuckCommitDurationMillis() / 10, 100);
        refreshWorkTimer.schedule(new TimerTask() {

            @Override
            public void run() {
                invalidateStuckCommits();
            }
        }, periodMillis, periodMillis);
    }
    if (options.getPeriodicStatusPageOutputDirectory() != null) {
        statusPageTimer = new Timer("DumpStatusPages");
        statusPageTimer.schedule(new TimerTask() {

            @Override
            public void run() {
                Collection<Capturable> pages = statusPages.getDebugCapturePages();
                if (pages.isEmpty()) {
                    LOG.warn("No captured status pages.");
                }
                Long timestamp = Instant.now().getMillis();
                for (Capturable page : pages) {
                    PrintWriter writer = null;
                    try {
                        File outputFile = new File(options.getPeriodicStatusPageOutputDirectory(), ("StreamingDataflowWorker" + options.getWorkerId() + "_" + page.pageName() + timestamp.toString()).replaceAll("/", "_"));
                        writer = new PrintWriter(outputFile, UTF_8.name());
                        page.captureData(writer);
                    } catch (IOException e) {
                        LOG.warn("Error dumping status page.", e);
                    } finally {
                        if (writer != null) {
                            writer.close();
                        }
                    }
                }
            }
        }, 60 * 1000, 60 * 1000);
    }
    reportHarnessStartup();
}
Also used : Capturable(org.apache.beam.runners.dataflow.worker.status.DebugCapture.Capturable) Timer(java.util.Timer) TimerTask(java.util.TimerTask) AtomicLong(java.util.concurrent.atomic.AtomicLong) Collection(java.util.Collection) IOException(java.io.IOException) File(java.io.File) PrintWriter(java.io.PrintWriter)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 Collection (java.util.Collection)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Capturable (org.apache.beam.runners.dataflow.worker.status.DebugCapture.Capturable)1