var cachedPeers: Seq[BlockManagerId] = null
  private def replicate(blockId: String, data: ByteBuffer, level:
StorageLevel) {
    val tLevel = StorageLevel(level.useDisk, level.useMemory,
level.deserialized, 1)
    if (cachedPeers == null) {
      cachedPeers = master.getPeers(blockManagerId, level.replication - 1)
    }
    for (peer: BlockManagerId <- cachedPeers) {
      val start = System.nanoTime
      data.rewind()
      logDebug("Try to replicate BlockId " + blockId + " once; The size of
the data is "
        + data.limit() + " Bytes. To node: " + peer)
      if (!BlockManagerWorker.syncPutBlock(PutBlock(blockId, data, tLevel),
        new ConnectionManagerId(peer.host, peer.port))) {
        logError("Failed to call syncPutBlock to " + peer)
      }
      logDebug("Replicated BlockId " + blockId + " once used " +
        (System.nanoTime - start) / 1e6 + " s; The size of the data is " +
        data.limit() + " bytes.")
    }
        
        when the method called firstly, "cachedPeers == null" is true.
        Then "master.getPeers(blockManagerId, level.replication - 1)" execute 
and
we get peers that will be used to replicate blocks.
        But when the method called again, "cachedPeers == null" is false.
    "master.getPeers(blockManagerId, level.replication - 1)" will not
execute, and the peers that will be used to replicate blocks is same to the
peers we get firstly.
        Is it right?



--
View this message in context: 
http://apache-spark-developers-list.1001551.n3.nabble.com/a-question-about-replicate-in-BlockManager-scala-tp271.html
Sent from the Apache Spark Developers List mailing list archive at Nabble.com.

Reply via email to