Handle new addresses of the balancer and backends from the resolver, and create connection if
not yet connected.
502856
void handleAddresses(
      List<LbAddressGroup> newLbAddressGroups, List<EquivalentAddressGroup> newBackendServers) {
    if (newLbAddressGroups.isEmpty()) {
      // No balancer address: close existing balancer connection and enter fallback mode
      // immediately.
      shutdownLbComm();
      syncContext.execute(new FallbackModeTask());
    } else {
      LbAddressGroup newLbAddressGroup = flattenLbAddressGroups(newLbAddressGroups);
      startLbComm(newLbAddressGroup);
      // Avoid creating a new RPC just because the addresses were updated, as it can cause a
      // stampeding herd. The current RPC may be on a connection to an address not present in
      // newLbAddressGroups, but we're considering that "okay". If we detected the RPC is to an
      // outdated backend, we could choose to re-create the RPC.
      if (lbStream == null) {
        startLbRpc();
      }
      // Start the fallback timer if it's never started
      if (fallbackTimer == null) {
        fallbackTimer = syncContext.schedule(
            new FallbackModeTask(), FALLBACK_TIMEOUT_MS, TimeUnit.MILLISECONDS, timerService);
      }
    }
    fallbackBackendList = newBackendServers;
    if (usingFallbackBackends) {
      // Populate the new fallback backends to round-robin list.
      useFallbackBackends();
    }
    maybeUpdatePicker();
  }
545881
def attach(options = {})
      options = Aws::Util.deep_merge(options,
        auto_scaling_group_name: @group_name,
        load_balancer_names: [@name]
      )
      resp = @client.attach_load_balancers(options)
      resp.data
    end
832005
function(resolvers) {
        return function(path, name, importerPath) {
            var num_resolvers = resolvers.length;
            return new Promise(function(resolve, reject) {
                if (resolvers.length === 0 ) {
                    reject('At least 1 resolver must be provided');
                }

                function try_resolver(index) {
                    resolvers[index](path, name, importerPath)
                        .then(function(m) {
                            resolve(m);
                        })
                        .catch(function() {
                            if (index + 1 === num_resolvers) {
                                reject(new Error('Could not find module: ' + path));
                            } else {
                                try_resolver(index + 1);
                            }
                        });
                }

                try_resolver(0);
            });
        };
    }
259380
def handle_address_save(self, sender, instance, **kwargs):
    
    objects = self.find_associated_with_address(instance)
    for obj in objects:
      self.handle_save(obj.__class__, obj)
256194
private void addReconnectTimer()
    {
        int rcIvl = getNewReconnectIvl();
        ioObject.addTimer(rcIvl, RECONNECT_TIMER_ID);

        // resolve address again to take into account other addresses
        // besides the failing one (e.g. multiple dns entries).
        try {
            addr.resolve(options.ipv6);
        }
        catch (Exception ignored) {
            // This will fail if the network goes away and the
            // address cannot be resolved for some reason. Try
            // not to fail as the event loop will quit
        }

        socket.eventConnectRetried(addr.toString(), rcIvl);
        timerStarted = true;
    }
216764
public final TcpClient resolver(AddressResolverGroup<?> resolver) {
		Objects.requireNonNull(resolver, "resolver");
		return bootstrap(b -> b.resolver(resolver));
	}
718713
def connectionMade(self):
        """"""
        self.endpoint = self.transport.getPeer()
        # get the reference to the Address object in NodeLeader so we can manipulate it properly.
        tmp_addr = Address(f"{self.endpoint.host}:{self.endpoint.port}")
        try:
            known_idx = self.leader.KNOWN_ADDRS.index(tmp_addr)
            self.address = self.leader.KNOWN_ADDRS[known_idx]
        except ValueError:
            # Not found.
            self.leader.AddKnownAddress(tmp_addr)
            self.address = tmp_addr

        self.address.address = "%s:%s" % (self.endpoint.host, self.endpoint.port)
        self.host = self.endpoint.host
        self.port = int(self.endpoint.port)
        self.leader.AddConnectedPeer(self)
        self.leader.RemoveFromQueue(self.address)
        self.leader.peers_connecting -= 1
        logger.debug(f"{self.address} connection established")
        if self.incoming_client:
            # start protocol
            self.SendVersion()
904006
def sync_with(self, config, conflict_resolver):
        ''''''
        if not config.has_section(self._name):
            config.add_section(self._name)
        resolved = self._sync_and_resolve(config, conflict_resolver)
        self._add_new_items(config, resolved)
638725
public void check() {
        List<InetSocketAddress> newAddrs = getAddresses();
        if (newAddrs != null && !newAddrs.equals(currentAddrs)) {

            if (addressChangeListener != null) {
                currentAddrs = newAddrs;
                addressChangeListener.changeAddresses(newAddrs);
            } else {
                LOGGER.error("Address change listener is null for JNDI key {}, cannot notify about new value {}", getJndiKey(), newAddrs);
            }
        }
    }
578303
def _startup(cls):
        
        for endpoint_name in sorted(hookenv.relation_types()):
            # populate context based on attached relations
            relf = relation_factory(endpoint_name)
            if not relf or not issubclass(relf, cls):
                continue

            rids = sorted(hookenv.relation_ids(endpoint_name))
            # ensure that relation IDs have the endpoint name prefix, in case
            # juju decides to drop it at some point
            rids = ['{}:{}'.format(endpoint_name, rid) if ':' not in rid
                    else rid for rid in rids]
            endpoint = relf(endpoint_name, rids)
            cls._endpoints[endpoint_name] = endpoint
            endpoint.register_triggers()
            endpoint._manage_departed()
            endpoint._manage_flags()
            for relation in endpoint.relations:
                hookenv.atexit(relation._flush_data)
1242842
def refresh(self, serviceDefinition=True):
        
        url = self._url + "/MapServer/refresh"
        params = {
            "f" : "json",
            "serviceDefinition" : serviceDefinition
        }

        res =  self._post(url=self._url,
                             param_dict=params,
                             securityHandler=self._securityHandler,
                             proxy_url=self._proxy_url,
                             proxy_port=self._proxy_port)
        self.__init()
        return res
1341970
def register_incoming_conn(self, conn):
        """"""
        assert conn, "conn is required"
        conn.set_outbound_pending_change_callback(self._on_conn_change)
        self.connections.appendleft(conn)
        self._set_on_close_cb(conn)
        self._on_conn_change()
1061089
def update(self, address, updater, prune=False):
        '''
        
        '''

        node = self._get_or_create(address)

        node.data = updater(node.data)

        if prune:
            node.children.clear()
356668
def new_connection_status(self, conn_status):
        """"""
        if conn_status.status == CONNECTION_STATUS_CONNECTED:
            self._mz.update_members()
        if (conn_status.status == CONNECTION_STATUS_DISCONNECTED or
                conn_status.status == CONNECTION_STATUS_LOST):
            self._mz.reset_members()
242399
public final Future<List<InetAddress>> resolveAll(String inetHost, Iterable<DnsRecord> additionals) {
        return resolveAll(inetHost, additionals, executor().<List<InetAddress>>newPromise());
    }
979084
public function checkGatewayConnections($addresses_list)
    {
        if (empty($addresses_list)) {
            return;
        }
        foreach ($addresses_list as $addr) {
            if (!isset($this->_waitingConnectGatewayAddresses[$addr])) {
                $this->tryToConnectGateway($addr);
            }
        }
    }
1072729
def custom_resolve(self):
        
        if not callable(self.custom_resolver):
            return
        new_addresses = []
        for address in self.addresses:
            for new_address in self.custom_resolver(address):
                new_addresses.append(new_address)
        self.addresses = new_addresses