code: private static int getZoneOffset(String myZone, boolean preferSameZone, String[] availZones) {
          for (int i = 0; i < availZones.length; i++) {
              if (myZone != null && (availZones[i].equalsIgnoreCase(myZone.trim()) == preferSameZone)) {
                  return i;
              }
          }
          logger.warn("DISCOVERY: Could not pick a zone based on preferred zone settings. My zone - {}," +
                  " preferSameZone - {}. Defaulting to {}", myZone, preferSameZone, availZones[0]);
  
          return 0;
      }
docs: Gets the zone to pick up for this instance.