managed/src/main/java/com/yugabyte/yw/common/PlacementInfoUtil.java
/**
   * Method to check whether the affinitized leaders info changed between the old and new
   * placements. If an AZ is present in the new placement but not the old or vice versa,
   * returns false.
   *
   * @param oldPlacementInfo Placement for the previous state of the Cluster.
   * @param newPlacementInfo Desired placement for the Cluster.
   * @return True if the affinitized leader info has changed and there are no new AZs, else false.
   */
Method to check whether the affinitized leaders info changed between the old and new
placements. If an AZ is present in the new placement but not the old or vice versa,
returns false.

@param oldPlacementInfo Placement for the previous state of the Cluster.
@param newPlacementInfo Desired placement for the Cluster.
@return True if the affinitized leader info has changed and there are no new AZs, else false.
Method to check whether the affinitized leaders info changed between the old and new placements . If an AZ is present in the new placement but not the old or vice versa returns false . @param oldPlacementInfo Placement for the previous state of the Cluster . @param newPlacementInfo Desired placement for the Cluster . @return True if the affinitized leader info has changed and there are no new AZs else false .
public static boolean didAffinitizedLeadersChange(PlacementInfo oldPlacementInfo,
                                                    PlacementInfo newPlacementInfo) {
    HashMap<UUID, Boolean> oldAZMap = new HashMap<UUID, Boolean>();
    for (PlacementCloud oldCloud : oldPlacementInfo.cloudList) {
      for (PlacementRegion oldRegion : oldCloud.regionList) {
        for (PlacementAZ oldAZ : oldRegion.azList) {
          oldAZMap.put(oldAZ.uuid, oldAZ.isAffinitized);
        }
      }
    }
    for (PlacementCloud newCloud : newPlacementInfo.cloudList) {
      for (PlacementRegion newRegion : newCloud.regionList) {
        for (PlacementAZ newAZ : newRegion.azList) {
          if (!oldAZMap.containsKey(newAZ.uuid)) {
            return false;
          }
          if (oldAZMap.get(newAZ.uuid) != newAZ.isAffinitized) {
            return true;
          }
        }
      }
    }
    return false;
  }
public static boolean didAffinitizedLeadersChange ( PlacementInfo oldPlacementInfo , PlacementInfo newPlacementInfo ) { HashMap < UUID , Boolean > oldAZMap = new HashMap < UUID , Boolean > ( ) ; for ( PlacementCloud oldCloud : oldPlacementInfo . cloudList ) { for ( PlacementRegion oldRegion : oldCloud . regionList ) { for ( PlacementAZ oldAZ : oldRegion . azList ) { oldAZMap . put ( oldAZ . uuid , oldAZ . isAffinitized ) ; } } } for ( PlacementCloud newCloud : newPlacementInfo . cloudList ) { for ( PlacementRegion newRegion : newCloud . regionList ) { for ( PlacementAZ newAZ : newRegion . azList ) { if ( ! oldAZMap . containsKey ( newAZ . uuid ) ) { return false ; } if ( oldAZMap . get ( newAZ . uuid ) != newAZ . isAffinitized ) { return true ; } } } } return false ; }
Method to check whether the affinitized leaders info changed between the old and new
 placements.
Method to check whether the affinitized leaders info changed between the old and new placements .
// Map between the old placement's AZs and the affinitized leader info. // affinitized leader info has changed, return true. // No affinitized leader info has changed, return false.