protected List<MessageInfo> fetchPaginatedMetadata(RecoveryNetworkClientCallback callback, int numPages)
      throws Exception {
    RecoveryToken recoveryToken = new RecoveryToken();
    List<MessageInfo> metadataList = new ArrayList<>();
    RecoveryNetworkClient recoveryNetworkClient = createRecoveryClient(callback);
    // Iterate N times to retrieve all blobIDs
    for (Integer ignored : IntStream.rangeClosed(1, numPages).boxed().collect(Collectors.toList())) {
      // Send metadata request
      List<ResponseInfo> responseInfoList =
          recoveryNetworkClient.sendAndPoll(createMetadataRequest(recoveryToken),
              Collections.emptySet(), 0);
      // Receive metadata response
      ReplicaMetadataResponseInfo rinfo = ReplicaMetadataResponse.readFrom(
          new NettyByteBufDataInputStream(responseInfoList.get(0).content()), findTokenHelper, mockClusterMap)
          .getReplicaMetadataResponseInfoList().get(0);
      if (rinfo.getError() == ServerErrorCode.NoError) {
        // Extract token
        recoveryToken = (RecoveryToken) rinfo.getFindToken();
        // Extract ambry metadata
        metadataList.addAll(rinfo.getMessageInfoList());
      }
    }
    assertTrue(recoveryToken.isEndOfPartition());
    assertEquals(azureBlobs.size(), metadataList.size());
    return metadataList;
  }
Downloads all metadata from Azurite in pages by iterating given number of times
@param callback
@param numPages
@return
@throws Exception
ambry-cloud/src/test/java/com/github/ambry/cloud/RecoveryNetworkClientTest.java