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();
}
Aggregations