Search in sources :

Example 1 with RifRecordLoadResult

use of gov.cms.bfd.pipeline.ccw.rif.load.RifRecordLoadResult in project beneficiary-fhir-data by CMSgov.

the class DefaultDataSetMonitorListener method dataAvailable.

/**
 * @see
 *     gov.cms.bfd.pipeline.ccw.rif.extract.s3.DataSetMonitorListener#dataAvailable(gov.cms.bfd.model.rif.RifFilesEvent)
 */
@Override
public void dataAvailable(RifFilesEvent rifFilesEvent) {
    Timer.Context timerDataSet = appMetrics.timer(MetricRegistry.name(PipelineApplication.class.getSimpleName(), "dataSet", "processed")).time();
    Consumer<Throwable> errorHandler = error -> {
        /*
           * This will be called on the same thread used to run each
           * RifLoader task (probably a background one). This is not
           * the right place to do any error _recovery_ (that'd have
           * to be inside RifLoader itself), but it is likely the
           * right place to decide when/if a failure is "bad enough"
           * that the rest of processing should be stopped. Right now
           * we stop that way for _any_ failure, but we probably want
           * to be more discriminating than that.
           */
        errorOccurred(error);
    };
    Consumer<RifRecordLoadResult> resultHandler = result -> {
    /*
           * Don't really *need* to do anything here. The RifLoader
           * already records metrics for each data set.
           */
    };
    /*
     * Each ETL stage produces a stream that will be handed off to
     * and processed by the next stage.
     */
    for (RifFileEvent rifFileEvent : rifFilesEvent.getFileEvents()) {
        Slf4jReporter dataSetFileMetricsReporter = Slf4jReporter.forRegistry(rifFileEvent.getEventMetrics()).outputTo(LOGGER).build();
        dataSetFileMetricsReporter.start(2, TimeUnit.MINUTES);
        RifFileRecords rifFileRecords = rifProcessor.produceRecords(rifFileEvent);
        rifLoader.process(rifFileRecords, errorHandler, resultHandler);
        dataSetFileMetricsReporter.stop();
        dataSetFileMetricsReporter.report();
    }
    timerDataSet.stop();
}
Also used : RifFileEvent(gov.cms.bfd.model.rif.RifFileEvent) MetricRegistry(com.codahale.metrics.MetricRegistry) Logger(org.slf4j.Logger) RifFileRecords(gov.cms.bfd.model.rif.RifFileRecords) LoggerFactory(org.slf4j.LoggerFactory) RifRecordLoadResult(gov.cms.bfd.pipeline.ccw.rif.load.RifRecordLoadResult) CcwRifLoadJob(gov.cms.bfd.pipeline.ccw.rif.CcwRifLoadJob) DataSetMonitorListener(gov.cms.bfd.pipeline.ccw.rif.extract.s3.DataSetMonitorListener) RifFilesEvent(gov.cms.bfd.model.rif.RifFilesEvent) RifFilesProcessor(gov.cms.bfd.pipeline.ccw.rif.extract.RifFilesProcessor) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) Slf4jReporter(com.codahale.metrics.Slf4jReporter) Timer(com.codahale.metrics.Timer) RifLoader(gov.cms.bfd.pipeline.ccw.rif.load.RifLoader) Timer(com.codahale.metrics.Timer) RifRecordLoadResult(gov.cms.bfd.pipeline.ccw.rif.load.RifRecordLoadResult) Slf4jReporter(com.codahale.metrics.Slf4jReporter) RifFileEvent(gov.cms.bfd.model.rif.RifFileEvent) RifFileRecords(gov.cms.bfd.model.rif.RifFileRecords)

Aggregations

MetricRegistry (com.codahale.metrics.MetricRegistry)1 Slf4jReporter (com.codahale.metrics.Slf4jReporter)1 Timer (com.codahale.metrics.Timer)1 RifFileEvent (gov.cms.bfd.model.rif.RifFileEvent)1 RifFileRecords (gov.cms.bfd.model.rif.RifFileRecords)1 RifFilesEvent (gov.cms.bfd.model.rif.RifFilesEvent)1 CcwRifLoadJob (gov.cms.bfd.pipeline.ccw.rif.CcwRifLoadJob)1 RifFilesProcessor (gov.cms.bfd.pipeline.ccw.rif.extract.RifFilesProcessor)1 DataSetMonitorListener (gov.cms.bfd.pipeline.ccw.rif.extract.s3.DataSetMonitorListener)1 RifLoader (gov.cms.bfd.pipeline.ccw.rif.load.RifLoader)1 RifRecordLoadResult (gov.cms.bfd.pipeline.ccw.rif.load.RifRecordLoadResult)1 TimeUnit (java.util.concurrent.TimeUnit)1 Consumer (java.util.function.Consumer)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1