@Override
  public Pair<List<RepairRequestRecord>, Long> getRepairRequestsExcludingHost(long partitionId, String sourceHostName,
      int sourceHostPort, long pageToken) throws SQLException {
    long startTime = time.milliseconds();
    long nextPageToken = 0;
    try (Connection connection = dataSource.getConnection()) {
      try (PreparedStatement statement = connection.prepareStatement(
          GET_REQUESTS_QUERY_EXCLUDE_SOURCE_REPLICA_BY_PAGE)) {
        statement.setLong(1, partitionId);
        statement.setString(2, sourceHostName);
        statement.setInt(3, sourceHostPort);
        statement.setTimestamp(4, new Timestamp(pageToken));
        statement.setInt(5, config.listMaxResults + 1);
        try (ResultSet resultSet = statement.executeQuery()) {
          List<RepairRequestRecord> result = new ArrayList<>();
          while (resultSet.next()) {
            String blobId = Base64.encodeBase64URLSafeString(resultSet.getBytes(1));
            String hostName = resultSet.getString(2);
            int hostPort = resultSet.getInt(3);
            OperationType operationType = OperationType.values()[resultSet.getShort(4)];
            Timestamp operationTime = resultSet.getTimestamp(5);
            short lifeVersion = resultSet.getShort(6);
            Timestamp expirationTime = resultSet.getTimestamp(7);
            RepairRequestRecord record =
                new RepairRequestRecord(blobId, partitionId, hostName, hostPort, operationType, operationTime.getTime(),
                    lifeVersion, expirationTime != null ? expirationTime.getTime() : Utils.Infinite_Time);
            if (result.size() < config.listMaxResults) {
              result.add(record);
            }
            // update the pagination token
            // LOCAL_CONSISTENCY_TODO
            // one risk is that all the records has the same operation time and RepairRequest handler fails to fix any of them.
            // then, the next page won't advance
            nextPageToken = record.getOperationTimeMs();
          }
          metrics.repairDbGetRequestTimeInMs.update(time.milliseconds() - startTime);

          // restart from the beginning.
          if (result.size() < config.listMaxResults) {
            nextPageToken = 0;
          }
          return new Pair(result, nextPageToken);
        }
      }
    } catch (SQLException e) {
      metrics.repairDbErrorGetCount.inc();
      logger.error("failed to get records from {} due to {}", dataSource, e.getMessage());
      throw e;
    }
  }
Select the records from one partition but exclude the record with this source name and port.
@param partitionId partition id
@param sourceHostName the host name of the source replica
@param sourceHostPort the host port of the source replica
@param pageToken the token for the next page
@return pair of the oldest {@link RepairRequestRecord}s and token for the next page
ambry-mysql/src/main/java/com/github/ambry/repair/MysqlRepairRequestsDb.java