setAvailability()

in common/lib/plugin_service.ts [334:366]


  setAvailability(hostAliases: Set<string>, availability: HostAvailability) {
    if (hostAliases.size === 0) {
      return;
    }

    const hostsToChange = [
      ...new Set(
        this.getAllHosts().filter(
          (host: HostInfo) => hostAliases.has(host.asAlias) || [...host.aliases].some((hostAlias: string) => hostAliases.has(hostAlias))
        )
      )
    ];

    if (hostsToChange.length === 0) {
      logger.debug(Messages.get("PluginService.hostsChangeListEmpty"));
      return;
    }

    const changes = new Map<string, Set<HostChangeOptions>>();
    for (const host of hostsToChange) {
      const currentAvailability = host.getAvailability();
      PluginService.hostAvailabilityExpiringCache.put(host.url, availability, PluginService.DEFAULT_HOST_AVAILABILITY_CACHE_EXPIRE_NANO);
      if (currentAvailability !== availability) {
        let hostChanges = new Set<HostChangeOptions>();
        if (availability === HostAvailability.AVAILABLE) {
          hostChanges = new Set([HostChangeOptions.WENT_UP, HostChangeOptions.HOST_CHANGED]);
        } else {
          hostChanges = new Set([HostChangeOptions.WENT_DOWN, HostChangeOptions.HOST_CHANGED]);
        }
        changes.set(host.url, hostChanges);
      }
    }
  }