public void serializeTokens(Map<String, Pair<Long, FindToken>> peerReplicaAndToken, OutputStream outputStream)
        throws IOException {
      CrcOutputStream crcOutputStream = new CrcOutputStream(outputStream);
      DataOutputStream writer = new DataOutputStream(crcOutputStream);
      try {
        // write the current version
        writer.writeShort(CURRENT_VERSION);
        for (Map.Entry<String, Pair<Long, FindToken>> peerToken : peerReplicaAndToken.entrySet()) {
          // write the peer key: hostname:mountpoint
          writer.writeInt(peerToken.getKey().getBytes().length);
          writer.write(peerToken.getKey().getBytes());
          // write the timestamp
          writer.writeLong(peerToken.getValue().getFirst());
          // Write the remote token
          writer.write(peerToken.getValue().getSecond().toBytes());
        }

        long crcValue = crcOutputStream.getValue();
        writer.writeLong(crcValue);
      } catch (IOException e) {
        logger.error("IO error while serializing remote peer tokens", e);
        throw e;
      } finally {
        if (outputStream instanceof FileOutputStream) {
          // flush and overwrite file
          ((FileOutputStream) outputStream).getChannel().force(true);
        }
        writer.close();
      }
    }
Serialize the remote tokens to the file
@param peerReplicaAndToken the mapping from the replicas to the remote tokens
@param outputStream the file output stream to write to
ambry-store/src/main/java/com/github/ambry/store/RemoteTokenTracker.java