flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tillrohrmann <...@git.apache.org>
Subject [GitHub] flink pull request: [FLINK-1529] [jobmanager] Improve error handli...
Date Thu, 12 Feb 2015 18:06:05 GMT
Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/385#discussion_r24602575
  
    --- Diff: flink-runtime/src/main/scala/org/apache/flink/runtime/jobmanager/JobManager.scala
---
    @@ -653,11 +693,87 @@ object JobManager {
         (archiveCount, profilingEnabled, cleanupInterval, executionRetries, delayBetweenRetries)
       }
     
    -  def startActor(configuration: Configuration)(implicit actorSystem: ActorSystem): ActorRef
= {
    -    startActor(Props(classOf[JobManager], configuration))
    +  /**
    +   * Create the job manager members as (instanceManager, scheduler, libraryCacheManager,
    +   *              archiverProps, accumulatorManager, profiler, defaultExecutionRetries,
    +   *              delayBetweenRetries, timeout)
    +   *
    +   * @param configuration The configuration from which to parse the config values.
    +   * @return The members for a default JobManager.
    +   */
    +  def createJobManagerComponents(configuration: Configuration) :
    +    (InstanceManager, FlinkScheduler, BlobLibraryCacheManager,
    +      Props, AccumulatorManager, Option[Props], Int, Long, FiniteDuration, Int) = {
    +
    +    val timeout: FiniteDuration = AkkaUtils.getTimeout(configuration)
    +
    +    val (archiveCount, profilingEnabled, cleanupInterval, executionRetries, delayBetweenRetries)
=
    +      parseConfiguration(configuration)
    +
    +    val archiveProps: Props = Props(classOf[MemoryArchivist], archiveCount)
    +
    +    val profilerProps: Option[Props] = if (profilingEnabled) {
    +      Some(Props(classOf[JobManagerProfiler]))
    +    } else {
    +      None
    +    }
    +
    +    val accumulatorManager: AccumulatorManager = new AccumulatorManager(Math.min(1, archiveCount))
    +
    +    var blobServer: BlobServer = null
    +    var instanceManager: InstanceManager = null
    +    var scheduler: FlinkScheduler = null
    +    var libraryCacheManager: BlobLibraryCacheManager = null
    +
    +    try {
    +      blobServer = new BlobServer(configuration)
    +      instanceManager = new InstanceManager()
    +      scheduler = new FlinkScheduler()
    +      libraryCacheManager = new BlobLibraryCacheManager(blobServer, cleanupInterval)
    +
    +      instanceManager.addInstanceListener(scheduler)
    +    }
    +    catch {
    +      case t: Throwable => {
    +        if (libraryCacheManager != null) {
    +          libraryCacheManager.shutdown()
    +        }
    +        if (scheduler != null) {
    +          scheduler.shutdown()
    +        }
    +        if (instanceManager != null) {
    +          instanceManager.shutdown()
    +        }
    +        if (blobServer != null) {
    +          blobServer.shutdown()
    +        }
    +        throw t;
    +      }
    +    }
    +
    +    (instanceManager, scheduler, libraryCacheManager, archiveProps, accumulatorManager,
    +      profilerProps, executionRetries, delayBetweenRetries, timeout, archiveCount)
    +  }
    +
    +  def startActor(configuration: Configuration, actorSystem: ActorSystem): ActorRef =
{
    +
    +    val (instanceManager, scheduler, libraryCacheManager, archiveProps, accumulatorManager,
    +      profilerProps, executionRetries, delayBetweenRetries,
    +      timeout, _) = createJobManagerComponents(configuration)
    +
    +    val profiler: Option[ActorRef] =
    +                 profilerProps.map( props => actorSystem.actorOf(props, PROFILER_NAME)
)
    --- End diff --
    
    Nice functional style :-)


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message