# Generating A Schedule

+ BALANCE
  + Leader
  + Regions
+ Hot region
+ cluster topology
+ scale in
+ Failure recover
+ Region merge
------------------------------------------------------------
Different schedulers generate Operators to be executed based on their own logic and needs, considering various restrictions and constraints. Let's first explain what an Operator is. An Operator is a collection of operations that apply to a Region and serve a certain scheduling purpose. For example, “Migrate the Leader of Region 2 to Store 5", “Migrate a replica of Region 2 to Store 1, 4, 5", etc.

Operators can be computationally generated by PD or manually created by external API.

Some of the most representative schedules are:
  - Balance
  Distribute Region evenly across all Stores in the cluster. It can be divided into 2 types:
    - The leader pays attention to the Leader of the Region and can be thought of as the purpose of spreading the pressure of processing client request.
    - Region focuses on each peer in the region in order to spread the stress of storage while avoiding disk full.
  - Hot region

For write hotspots, hotspot scheduling attempts to break both the peer and leader of the hotspot region; for read hotspots, since only the leader carries the read pressure, the hotspot scheduling attempts to break the leader of the hotspot region. Please refer to the following sections for details.
  - Cluster topology

The topology for making PD aware of the distribution of different nodes is to ensure high availability and disaster recovery by scheduling individual replicas in different regions as possible. For example, if a cluster has 3 data centers, the safest way to schedule is to place the 3 peers of the region in different data centers, so that if any data center fails, it can continue to provide services.
  - scale in
      scale in down refers to preparing to take a store offline. The store is marked as offline through the command. At this time, PD migrates the region on the node to be offline to another node by scheduling.
  - Failure recover
      Failback means that when a Store fails and cannot be recover, there are peers distributed in the regions on the corresponding Store that are missing replica. At this point, PD needs to make up replicas for these regions on other nodes.
  - Region merge
      Region merge refers to the process of merging adjacent small regions by scheduling in order to avoid large numbers of small regions or even empty regions consuming system resources after deleting data.