Code Monkey home page Code Monkey logo

amadou's People

Contributors

jonas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amadou's Issues

Merge ProcessContext and SparkRunner.Context

Motivation

One context to rule them all.

Input

  • case class ProcessContext(
    jobId: String,
    processingDate: DateInterval,
    processId: String = java.util.UUID.randomUUID().toString,
    startTime: Long = System.currentTimeMillis) {
    def duration: Long = System.currentTimeMillis - startTime
    }
  • class Context[+I](job: Job, processContext: ProcessContext, spark: SparkSession, date: DateInterval, value: I)
    extends Stage.Context(spark, date, value) {
    override def withValue[U](value: U) = new Context(job, processContext, spark, date, value)
    override def run[T](stage: Stage[I, T], result: => T): Stage.Result[T] = {
    def runStage(callCount: Int): Stage.Result[T] = {
    logger.info(s"[$processContext] Running stage ${stage.name} try #$callCount")
    counters.foreach(_.clear())
    messaging.publishStageStarting(processContext, stage.name)
    Try(result) match {
    case v @ Success(_) =>
    messaging.publishStageComplete(processContext, stage.name)
    messaging.publishMetrics(processContext, stage.name, collectMetrics())
    v
    case Failure(failure) =>
    if (callCount >= job.maxRetries) {
    logger.error(s"[$processContext] Giving up after ${job.maxRetries} retries", failure)
    messaging.publishStageFailed(processContext, stage.name, failure)
    messaging.publishProcessFailed(processContext, failure)
    throw failure
    } else {
    logger.error(s"[$processContext] Will retry stage $stage in ${job.delayBetweenRetries}", failure)
    messaging.publishStageRetrying(processContext, stage.name)
    Thread.sleep(job.delayBetweenRetries.toMillis)
    runStage(callCount + 1)
    }
    }
    }
    runStage(1)
    }
    }

Output

  • A single component which maintains the current context of a job/stage.

Context should provide both event and processing date

Motivation

The naming convention from Apache Beam is very good and amadou should use it. This would also allow to make certain parts easier to test by removing use of hard coded processing date (e.g. Day.today).

Input

  • Current context class

Output

  • Context class updated with date renamed to eventDate and a new processingDate member.

Do not emit recordsProcessed for records where no Spark reads where done

Motivation

Each stage automatically emits the recordsProcessed metric which may lead to zero values for stages that do not do any Spark reads. Avoid the zero values to not skew the dashboard which does a mean on the values returned for a given day.

Input

The sparkRecordsRead counter.

Output

No recordsProcessed custom metric is emitted for stages that does no reads.

Gracefully handle Kafka connection issues

Failure to resolve a Kafka broker will crash a job

Caused by: org.apache.kafka.common.config.ConfigException: DNS resolution failed for url in bootstrap.servers: broker-1.kafka.mesos:6000
	at org.apache.kafka.common.utils.ClientUtils.parseAndValidateAddresses(ClientUtils.java:38)
	at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:189)
	at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:129)
	at com.mediative.amadou.monitoring.KafkaMessagingSystem.<init>(KafkaMessagingSystem.scala:26)
	at com.mediative.amadou.monitoring.MessagingSystem$.create(MessagingSystem.scala:33)
	at com.mediative.amadou.SparkRunner.<init>(SparkRunner.scala:140)
	at com.mediative.mpn.brain.dataflow.jobs.national.National$.<init>(National.scala:14)
	at com.mediative.mpn.brain.dataflow.jobs.national.National$.<clinit>(National.scala)
	... 1 more

Check number of rows uploaded to BQ matches expected

Motivation

Ensure that all data in a dataset is written to BQ.

Input

  • job.getStatistics.getLoad.getOutputRows

Output

  • BigQueryClient.load fails if output rows != dataset rows.

Test

  • Test with mock BQ client that triggers the failure

Retry message should use the stage name

From emitted log:

17/04/26 14:15:55 ERROR AAA$: [ProcessContext(aaa,2017-04-26,98fc8de3-259c-4c3c-865c-8e9dc1003372,1493215211215)] Will retry stage com.mediative.amadou.Stage$$anon$3@2cfbeac4 in 20 minutes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.