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

    https://github.com/apache/flink/pull/328#discussion_r23485570
  
    --- Diff: 
flink-runtime/src/main/scala/org/apache/flink/runtime/taskmanager/TaskManager.scala
 ---
    @@ -175,62 +175,79 @@ import scala.collection.JavaConverters._
       }
     
       private def tryJobManagerRegistration(): Unit = {
    -    registrationAttempts = 0
    -    import context.dispatcher
    -    registrationScheduler = Some(context.system.scheduler.schedule(
    -      TaskManager.REGISTRATION_DELAY, TaskManager.REGISTRATION_INTERVAL,
    -      self, RegisterAtJobManager))
    +    registrationDuration = 0 seconds
    +
    +    registered = false
    +
    +    context.system.scheduler.scheduleOnce(registrationDelay, self, 
RegisterAtJobManager)
       }
     
       override def receiveWithLogMessages: Receive = {
         case RegisterAtJobManager => {
    -      registrationAttempts += 1
    +      if(!registered) {
    +        registrationDuration += registrationDelay
    +        // double delay for exponential backoff
    +        registrationDelay *= 2
     
    -      if (registered) {
    -        registrationScheduler.foreach(_.cancel())
    -      }
    -      else if (registrationAttempts <= 
TaskManager.MAX_REGISTRATION_ATTEMPTS) {
    +        if (registrationDuration > maxRegistrationDuration) {
    +          log.warning("TaskManager could not register at JobManager {} 
after {}.", jobManagerAkkaURL,
     
    -        log.info("Try to register at master {}. Attempt #{}", 
jobManagerAkkaURL,
    -          registrationAttempts)
    -        val jobManager = context.actorSelection(jobManagerAkkaURL)
    +            maxRegistrationDuration)
     
    -        jobManager ! RegisterTaskManager(connectionInfo, 
hardwareDescription, numberOfSlots)
    -      }
    -      else {
    -        log.error("TaskManager could not register at JobManager.");
    -        self ! PoisonPill
    +          self ! PoisonPill
    +        } else if (!registered) {
    +          log.info(s"Try to register at master ${jobManagerAkkaURL}. 
${registrationAttempts}. " +
    +            s"Attempt")
    +          val jobManager = context.actorSelection(jobManagerAkkaURL)
    +
    +          jobManager ! RegisterTaskManager(connectionInfo, 
hardwareDescription, numberOfSlots)
    +
    +          context.system.scheduler.scheduleOnce(registrationDelay, self, 
RegisterAtJobManager)
    +        }
           }
         }
     
         case AcknowledgeRegistration(id, blobPort) => {
    -      if (!registered) {
    +      if(!registered) {
    +        finishRegistration(id, blobPort)
             registered = true
    -        currentJobManager = sender
    -        instanceID = id
    -
    -        context.watch(currentJobManager)
    -
    -        log.info("TaskManager successfully registered at JobManager {}.",
    -          currentJobManager.path.toString)
    -
    -        setupNetworkEnvironment()
    -        setupLibraryCacheManager(blobPort)
    +      } else {
    +        if (log.isDebugEnabled) {
    --- End diff --
    
    Small nit, with slf4j formatting we do not need to check isDebugEnabled 
anymore because it uses parameterized messages feature that check for it before 
materialize the string. 
    It will the keep the code cleaner =)


---
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.
---

Reply via email to