Github user steveloughran commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8744#discussion_r43387678
  
    --- Diff: 
yarn/src/history/main/scala/org/apache/spark/deploy/history/yarn/YarnHistoryService.scala
 ---
    @@ -0,0 +1,1328 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.deploy.history.yarn
    +
    +import java.io.InterruptedIOException
    +import java.net.{ConnectException, URI}
    +import java.util.concurrent.atomic.{AtomicBoolean, AtomicInteger}
    +import java.util.concurrent.{LinkedBlockingDeque, TimeUnit}
    +
    +import scala.collection.JavaConverters._
    +import scala.collection.mutable
    +
    +import com.codahale.metrics.{Counter, MetricRegistry, Timer}
    +import org.apache.hadoop.security.UserGroupInformation
    +import org.apache.hadoop.yarn.api.records.timeline.{TimelineDomain, 
TimelineEntity, TimelineEvent}
    +import org.apache.hadoop.yarn.api.records.{ApplicationAttemptId, 
ApplicationId}
    +import org.apache.hadoop.yarn.client.api.TimelineClient
    +import org.apache.hadoop.yarn.conf.YarnConfiguration
    +
    +import org.apache.spark.deploy.history.yarn.YarnTimelineUtils._
    +import org.apache.spark.metrics.source.Source
    +import org.apache.spark.scheduler._
    +import org.apache.spark.scheduler.cluster.{SchedulerExtensionService, 
SchedulerExtensionServiceBinding}
    +import org.apache.spark.util.{SystemClock, Utils}
    +import org.apache.spark.{Logging, SparkContext}
    +
    +/**
    + * A Yarn Extension Service to post lifecycle events to a registered YARN 
Timeline Server.
    + *
    + * Posting algorithm
    + *
    + * 1. The service subscribes to all events coming from the Spark Context.
    + * 1. These events are serialized into JSON objects for publishing to the 
timeline service through
    + * HTTP(S) posts.
    + * 1. Events are buffered into `pendingEvents` until a batch is aggregated 
into a
    + * [[TimelineEntity]] for posting.
    + * 1. That aggregation happens when a lifecycle event (application 
start/stop) takes place,
    + * or the number of pending events in a running application exceeds the 
limit set in
    + * `spark.hadoop.yarn.timeline.batch.size`.
    + * 1. Posting operations take place in a separate thread from the spark 
event listener.
    + * 1. If an attempt to post to the timeline server fails, the service 
sleeps and then
    + * it is re-attempted after the retry period defined by
    + * `spark.hadoop.yarn.timeline.post.retry.interval`.
    + * 1. If the number of events buffered in the history service exceed the 
limit set in
    + * `spark.hadoop.yarn.timeline.post.limit`, then further events other than 
application start/stop
    + * are dropped.
    + * 1. When the service is stopped, it will make a best-effort attempt to 
post all queued events.
    + * the call of [[stop()]] can block up to the duration of
    + * `spark.hadoop.yarn.timeline.shutdown.waittime` for this to take place.
    + * 1. No events are posted until the service receives a 
[[SparkListenerApplicationStart]] event.
    + *
    + * If the spark context has a metrics registry, then the internal counters 
of queued entities,
    + * post failures and successes, and the performance of the posting 
operation are all registered
    + * as metrics.
    + *
    + * The shutdown logic is somewhat convoluted, as the posting thread may be 
blocked on HTTP IO
    + * when the shutdown process begins. In this situation, the thread 
continues to be blocked, and
    + * will be interrupted once the wait time has expired. All time consumed 
during the ongoing
    + * operation will be counted as part of the shutdown time period.
    + */
    +private[spark] class YarnHistoryService extends SchedulerExtensionService
    +  with Logging with Source {
    --- End diff --
    
    OK, I'll pull out the counters into their source subclass


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to