private void updateReplicationSet(Set<PartitionId> highPriorityPartitions) {

    if (highPriorityPartitions.isEmpty()) {
      return;
    }

    try {
      // Identify truly new high-priority partitions that aren't already being replicated
      Set<PartitionId> newHighPriorityPartitions = new HashSet<>(highPriorityPartitions);
      newHighPriorityPartitions.removeAll(currentlyReplicatingPriorityPartitions);

      if (newHighPriorityPartitions.isEmpty() && isHighPriorityReplicationRunning.get()) {
        logger.info("No new high-priority partitions identified, continuing with current replication set");
        return;
      }

      // If we're not already in high-priority mode, start it
      if (!isHighPriorityReplicationRunning.get()) {
        replicationPrioritizationMetrics.recordNormalToHighPriorityTransition();
        // Start high-priority replication with all identified high-priority partitions
        startHighPriorityReplication(highPriorityPartitions);
      } else {
        // We're already in high-priority mode, just add the new partitions
        if (!newHighPriorityPartitions.isEmpty()) {
          logger.info("Adding {} new high-priority partitions to existing replication set",
              newHighPriorityPartitions.size());

          // Record new high priority partitions
          replicationPrioritizationMetrics.recordPartitionsAddedToHighPriority(newHighPriorityPartitions);

          // Enable replication for the new high-priority partitions
          currentlyReplicatingPriorityPartitions.addAll(newHighPriorityPartitions);

          replicationPrioritizationMetrics.updateCurrentlyReplicatingPriorityPartitions(currentlyReplicatingPriorityPartitions);


          // Ensure we have at least the minimum batch size
          if (currentlyReplicatingPriorityPartitions.size() < minBatchSizeForHighPriorityPartitions) {
            addNewPartitions();
          }

          // Update the priority settings
          controlReplicationThreads();

          // Record activity timestamp
          lastReplicationActivityMs = time.milliseconds();
        }
      }
    } catch (Exception e) {
      logger.error("Error updating replication set", e);
    }
  }
Updates the replication set based on the high priority partitions.
@param highPriorityPartitions The set of partitions that should be prioritized.
ambry-prioritization/src/main/java/com/github/ambry/replica/prioritization/ReplicationPrioritizationManager.java