This methods  arranges for the data node to send the block report at the next heartbeat.
513263
public void scheduleBlockReport(long delay) {
    if (delay > 0) { // send BR after random delay
      lastBlockReport = System.currentTimeMillis()
                            - ( anode.blockReportInterval - R.nextInt((int)(delay)));
    } else { // send at next heartbeat
      lastBlockReport = lastHeartbeat - anode.blockReportInterval;
    }
    resetBlockReportTime = true; // reset future BRs for randomness
  }
697252
@Override
	protected void writeAllocationBlock( int blockIndex ) throws DataStoreException
    {
    	byte[] allocationBlock = serializeAllocationBlock(blockIndex);
        journal.writeMetaDataBlock(AT_HEADER_SIZE+blockIndex*AT_BLOCK_SIZE, allocationBlock);
    }
970057
public DatanodeCommand[] sendHeartbeat(DatanodeRegistration nodeReg,
                                       long capacity,
                                       long dfsUsed,
                                       long remaining,
                                       long namespaceUsed,
                                       int xmitsInProgress,
                                       int xceiverCount) throws IOException {
    verifyRequest(nodeReg);
    myMetrics.numHeartbeat.inc();
    return namesystem.handleHeartbeat(nodeReg, capacity, dfsUsed, remaining, namespaceUsed,
        xceiverCount, xmitsInProgress);
  }
753398
public void insertBlock(AbstractBaseDTNode<I, D> blockRoot) {
        blockRoot.removeFromBlockList();

        blockRoot.setNextElement(next);
        if (getNextElement() != null) {
            next.setPrevElement(blockRoot);
        }
        blockRoot.setPrevElement(this);
        next = blockRoot;
    }
1289245
private CompletableFuture<Void> sendHeartbeats() {
    checkMetadata();
    Stream<GossipMember> clusterMembers = members.values().stream()
        .filter(member -> !member.id().equals(localMember.id()));

    Stream<GossipMember> providerMembers = discoveryService.getNodes().stream()
        .filter(node -> !members.containsKey(MemberId.from(node.id().id())))
        .map(node -> new GossipMember(MemberId.from(node.id().id()), node.address()));

    return Futures.allOf(Stream.concat(clusterMembers, providerMembers)
        .map(member -> {
          LOGGER.trace("{} - Sending heartbeat: {}", localMember.id(), member);
          return sendHeartbeat(member).exceptionally(v -> null);
        }).collect(Collectors.toList()))
        .thenApply(v -> null);
  }
1103880
def add_next_block(prev_block, data)
      if valid_block?(prev_block)
        blockchain << next_block(data)
      else
        raise InvalidBlockError
      end
    end
164081
private Future<?> startHeartbeat(final WebSocket websocket, final int heartbeatInterval) {
        // first heartbeat should assume last heartbeat was answered properly
        heartbeatAckReceived.set(true);
        return api.getThreadPool().getScheduler().scheduleWithFixedDelay(() -> {
            try {
                if (heartbeatAckReceived.getAndSet(false)) {
                    sendHeartbeat(websocket);
                    logger.debug("Sent heartbeat (interval: {})", heartbeatInterval);
                } else {
                    websocket.sendClose(WebSocketCloseReason.HEARTBEAT_NOT_PROPERLY_ANSWERED.getNumericCloseCode(),
                                        WebSocketCloseReason.HEARTBEAT_NOT_PROPERLY_ANSWERED.getCloseReason());
                }
            } catch (Throwable t) {
                logger.error("Failed to send heartbeat or close web socket!", t);
            }
        }, 0, heartbeatInterval, TimeUnit.MILLISECONDS);
    }
887618
@Override
    public void prepare ( CommonServerMessageBlockRequest next ) {
        if ( isReceived() ) {
            ( (ServerMessageBlock2) next ).setTreeId(getTreeId());
        }
        super.prepare(next);
    }
750374
async def post_heartbeat(self, msg, _context):
        """"""

        name = msg.get('name')

        await self.service_manager.send_heartbeat(name)
1146735
void afterRead(Node<K, V> node) {
        final int bufferIndex = readBufferIndex();
        final long writeCount = recordRead(bufferIndex, node);
        drainOnReadIfNeeded(bufferIndex, writeCount);
        notifyListener();
    }
1213593
def on_send(self, frame):
        
        if frame.cmd == CMD_CONNECT or frame.cmd == CMD_STOMP:
            if self.heartbeats != (0, 0):
                frame.headers[HDR_HEARTBEAT] = '%s,%s' % self.heartbeats
        if self.next_outbound_heartbeat is not None:
            self.next_outbound_heartbeat = monotonic() + self.send_sleep
376659
private void sendHubHeartbeats()
  {
    RackHeartbeat rack = _rack;
    
    UpdateRackHeartbeat updateRack = rack.getUpdate();
    UpdatePodSystem updatePod = getUpdatePodSystem();
    
    long now = CurrentTime.currentTime();
    
    if (! isJoinComplete()) {
      updatePod = null;
    }

    // send hub update to all servers in the rack
    for (ServerHeartbeat rackServer : _rack.getServers()) {
      if (rackServer == null || rackServer == _serverSelf) {
        continue;
      }

      ServerTarget target = createTargetServer(rackServer);
      
      target.hubHeartbeat(getServerSelf().getUpdate(),
                             updateRack,
                             updatePod,
                             now);
    }
  }
28553
@SubscribeEvent
	public void onDataSave(ChunkDataEvent.Save event)
	{
		Set<BlockPos> coords = chunks(event.getChunk()).get(event.getChunk());
		if (!coords.isEmpty())
			writeLongArray(event.getData(), coords);
	}
321883
private void sendIncrementalBlockReport(long startTime) throws Exception {

    // check if there are newly received blocks
    Block[] receivedAndDeletedBlockArray = null;
    int numBlocksReceivedAndDeleted = 0;
    int currentPendingRequests = 0;

    synchronized (receivedAndDeletedBlockList) {
      
      // construct the ACKs array
      lastDeletedReport = startTime;
      numBlocksReceivedAndDeleted = receivedAndDeletedBlockList.size();
      if (numBlocksReceivedAndDeleted > 0) {
        receivedAndDeletedBlockArray = receivedAndDeletedBlockList
            .toArray(new Block[numBlocksReceivedAndDeleted]);
        receivedAndDeletedBlockList.clear();
        currentPendingRequests = pendingReceivedRequests;
        pendingReceivedRequests = 0;
      }
    }
    // process received + deleted
    // if exception is thrown, add all blocks to the retry list
    if (receivedAndDeletedBlockArray != null) {            
      long[] failed = null;
      try {
        IncrementalBlockReport ibr = new IncrementalBlockReport(receivedAndDeletedBlockArray);

        long rpcStartTime = 0;
        if (LOG.isDebugEnabled()) {
          rpcStartTime = System.nanoTime();
          LOG.debug("sending blockReceivedAndDeletedNew "
                    + receivedAndDeletedBlockArray.length +
                    " blocks to " + namenodeAddress);
        }
        failed = avatarnode.blockReceivedAndDeletedNew(nsRegistration, ibr);
        if (LOG.isDebugEnabled()) {
          LOG.debug("finished blockReceivedAndDeletedNew " +
                    "to " + namenodeAddress +
                    " time: " + (System.nanoTime() - rpcStartTime) + " ns");
        }

        boolean isPrimaryCached = isPrimaryServiceCached();
        // if we talk to primary failed must be null
        // if we talk to standby failed shouldn't be null
        if(isPrimaryCached && failed!=null){
          //this should never happen
          //the primary can't switch to standby
          throw new IOException("Primary started acting as standby");
        } else if (!isPrimaryCached && failed == null) {
          String msg = "Received null response from standby for incremental"
              + " block report. ";
          if (clearPrimaryCommandProcessed) {
            LOG.info(msg + "Failover is in progress"
                + " - will not clear primary again");
          } else {
            LOG.info(msg + "Standby is acting as primary. Clearing primary");
            // failover - we need to refresh our knowledge
            this.clearPrimary();
          }
        }
      } catch (Exception e) {
        processFailedBlocks(
            receivedAndDeletedBlockArray, currentPendingRequests);
        throw e;
      }
      if(failed != null && failed.length != 0){
        processFailedReceivedDeleted(failed, receivedAndDeletedBlockArray);
      }
    }
  }
436459
void afterRead(Node<K, V> node, long now, boolean recordHit) {
    if (recordHit) {
      statsCounter().recordHits(1);
    }

    boolean delayable = skipReadBuffer() || (readBuffer.offer(node) != Buffer.FULL);
    if (shouldDrainBuffers(delayable)) {
      scheduleDrainBuffers();
    }
    refreshIfNeeded(node, now);
  }
1074497
private void processOverReplicatedBlocksAsync() {

    // blocks should not be scheduled for deletion during safemode
    if (isInSafeMode()) {
      return;
    }
    
    if (delayOverreplicationMonitorTime > now()) {
      LOG.info("Overreplication monitor delayed for "
          + ((delayOverreplicationMonitorTime - now()) / 1000) + " seconds");
      return;
    }
    nameNode.clearOutstandingNodes();
    
    final int nodes = heartbeats.size();
    List<Block> blocksToProcess = new ArrayList<Block>(Math.min(
        overReplicatedBlocks.size(),
        ReplicationConfigKeys.overreplicationWorkMultiplier * nodes));
    
    for (int i = 0; i < ReplicationConfigKeys.overreplicationWorkMultiplier; i++) {
      writeLock();
      try {
        NameNode.getNameNodeMetrics().numOverReplicatedBlocks.set(overReplicatedBlocks.size());
        overReplicatedBlocks.pollNToList(nodes, blocksToProcess);
        if (overReplicatedBlocks.isEmpty()) {
          break;
        }
      } finally {
        writeUnlock();
      }
    }

    for (Block block : blocksToProcess) {
      if (NameNode.stateChangeLog.isDebugEnabled()) {
        NameNode.stateChangeLog
            .debug("BLOCK* NameSystem.processOverReplicatedBlocksAsync: " + block);
      }
      if (block instanceof OverReplicatedBlock) {
        OverReplicatedBlock opb = (OverReplicatedBlock)block;
        processOverReplicatedBlock(block, (short) -1, opb.addedNode, opb.delNodeHint);
      } else {
        processOverReplicatedBlock(block, (short) -1, null, null);
      }
        
    }
  }
517174
def send(self, ws, seq):
        

        payload = {'op': 1, 'd': seq}
        payload = json.dumps(payload)
        logger.debug("Sending heartbeat with payload {}".format(payload))
        ws.send(payload)
        return