Github user manuzhang commented on a diff in the pull request:
https://github.com/apache/incubator-gearpump/pull/134#discussion_r97216883
--- Diff:
core/src/main/scala/org/apache/gearpump/cluster/master/AppManager.scala ---
@@ -217,40 +206,56 @@ private[cluster] class AppManager(kvService:
ActorRef, launcher: AppMasterLaunch
LOG.error(failed.reason)
}
- private def getAppMasterStatus(appId: Int): AppMasterStatus = {
- if (activeAppMasters.contains(appId)) {
- AppMasterActive
- } else if (deadAppMasters.contains(appId)) {
- AppMasterInActive
- } else if (appMasterRegistry.contains(appId)) {
- AppMasterPending
- } else {
- AppMasterNonExist
- }
- }
+ def appMasterMessage: Receive = {
+ case RegisterAppMaster(appId, appMaster, workerInfo) =>
+ val appInfo = applicationRegistry.get(appId)
+ appInfo match {
+ case Some(info) =>
+ LOG.info(s"Register AppMaster for app: $appId")
+ val updatedInfo = info.onAppMasterRegister(appMaster,
workerInfo.ref)
+ context.watch(appMaster)
+ applicationRegistry += appId -> updatedInfo
+ kvService ! PutKV(MASTER_GROUP, MASTER_STATE,
MasterState(nextAppId, applicationRegistry))
+ sender ! AppMasterRegistered(appId)
+ case None =>
+ LOG.error(s"Can not find submitted application $appId")
+ }
- private def shutDownExecutorTimeOut(): Unit = {
- LOG.error(s"Shut down executor time out")
- }
+ case ApplicationStatusChanged(appId, newStatus, timeStamp, error) =>
+ applicationRegistry.get(appId) match {
+ case Some(appRuntimeInfo) =>
+ var updatedStatus: ApplicationRuntimeInfo = null
+ LOG.info(s"Application $appId change to ${newStatus.toString} at
$timeStamp")
+ newStatus match {
+ case ApplicationStatus.Active =>
+ updatedStatus = appRuntimeInfo.onActived(timeStamp)
+ sender ! AppMasterActivated(appId)
+ case [email protected] =>
+ killAppMasterExecutor(appId, appRuntimeInfo.worker)
+ updatedStatus = appRuntimeInfo.onTerminalStatus(timeStamp,
finished)
+ appResultListeners.getOrElse(appId, List.empty).foreach{
client =>
+ client ! ApplicationFinished(appId)
+ }
+ case [email protected] =>
+ killAppMasterExecutor(appId, appRuntimeInfo.worker)
+ updatedStatus = appRuntimeInfo.onTerminalStatus(timeStamp,
failed)
+ appResultListeners.getOrElse(appId, List.empty).foreach{
client =>
+ client ! ApplicationFailed(appId, error)
+ }
+ case [email protected] =>
+ updatedStatus = appRuntimeInfo.onTerminalStatus(timeStamp,
terminated)
+ case _ =>
--- End diff --
what is for ? Any comments ?
---
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 [email protected] or file a JIRA ticket
with INFRA.
---