BlockManagerMasterActor类

来源:互联网 发布:em算法再次 编辑:程序博客网 时间:2024/05/21 10:53

变量

private val blockManagerInfo = new mutable.HashMap[BlockManagerId, BlockManagerMasterActor.BlockManagerInfo]

private val blockManagerIdByExecutor = new mutable.HashMap[String, BlockManagerId]

private val blockLocations = new JHashMap[BlockId, mutable.HashSet[BlockManagerId]]


override def preStart() {  //检查blockManager是否正常

    if (!BlockManager.getDisableHeartBeatsForTesting(conf)) {
      import context.dispatcher
      timeoutCheckingTask = context.system.scheduler.schedule(0.seconds, checkTimeoutInterval.milliseconds, self, ExpireDeadHosts)
    }
    super.preStart()

  }


接受的信息

def receive = {

  case RegisterBlockManager(blockMnagerId, maxMemSize, slaveAactor) //从worker节点发来的注册信息

  case UpdateBlockInfo(blockManagerId, blockId, storageLevel, deserializedSize, size)

  case GetLocations(blockId)

  case GetLocationsMultipleBlockIds(blockIds)

  case GetPeers(blockManagerId, size)

  case GetMemoryStatus

  case RemoveBlock(blockId)

  case RemoveExecutor(execId)

  case RemoveExecutor(execId)

  case StopBlockManagerMaster

  case ExpireDeadHosts

  case HeartBeat

  case other

}


初始化

1.val env = SparkEnv.get

2.SparkEnv里会有val blockManagerMaster = new BlockManagerMaster(registerOrLookup("BlockManagerMaster",new BlockManagerMasterActor(isLocal, conf)), conf)

3.

def registerOrLookup(name: String, newActor: => Actor): ActorRef = {
      if (isDriver) { //如果是driver程序
        actorSystem.actorOf(Props(newActor), name = name)
      } else {  //Executor节点,则返回driver程序的blockManagerMaster的ref

            Await.result(actorSystem.actorSelection(url).resolveOne(timeout), timeout)
      }
    }



0 0
原创粉丝点击