// This will move servers into a bandwidth pool, removing them from their previous bandwidth pool and optionally remove the bandwidth pool on completion.
968029
func (r Network_Bandwidth_Version1_Allotment) RequestVdrContentUpdates(hardwareToAdd []datatypes.Hardware, hardwareToRemove []datatypes.Hardware, cloudsToAdd []datatypes.Virtual_Guest, cloudsToRemove []datatypes.Virtual_Guest, optionalAllotmentId *int, adcToAdd []datatypes.Network_Application_Delivery_Controller, adcToRemove []datatypes.Network_Application_Delivery_Controller) (resp bool, err error) {
	params := []interface{}{
		hardwareToAdd,
		hardwareToRemove,
		cloudsToAdd,
		cloudsToRemove,
		optionalAllotmentId,
		adcToAdd,
		adcToRemove,
	}
	err = r.Session.DoRequest("SoftLayer_Network_Bandwidth_Version1_Allotment", "requestVdrContentUpdates", params, &r.Options, &resp)
	return
}
1311864
func (c *Client) updateServers(servers []string, idx uint64) {
	c.mu.Lock()
	defer c.mu.Unlock()

	// If the new index isn't greater than the current index then ignore
	// changes to the peer list. Prevents out of order request handling
	// nuking a more recent version of the peer list.
	if idx < c.idx {
		return
	}
	c.idx = idx
	servers = formatURLs(servers)

	// First add any new servers
	for _, s := range servers {
		if _, ok := c.servers[s]; !ok {
			c.servers[s] = c.httpClient(s)
		}
	}

	// Then remove any that are no longer current
	for addr := range c.servers {
		present := false
		for _, s := range servers {
			if _, ok := c.servers[s]; ok {
				present = true
				break
			}
		}
		if !present {
			delete(c.servers, addr)
		}
	}
}
192673
func (conn *ProtectedConnBase) cleanup() {
	conn.mutex.Lock()
	defer conn.mutex.Unlock()

	if conn.socketFd != socketError {
		//fmt.Printf("####Close %d\n", conn.socketFd)
		syscall.Close(conn.socketFd)
		conn.socketFd = socketError
	}
}
675615
func ServerFinalizer(f httptransport.ServerFinalizerFunc) ServerOption {
	return func(s *Server) { s.finalizer = f }
}
1158820
func (c *Client) RemoveResourcePool(poolID string) error {
	return c.call("RemoveResourcePool", poolID, nil)
}
864305
func (l *serverList) shuffleServers() {
	for i := len(l.servers) - 1; i > 0; i-- {
		j := rand.Int31n(int32(i + 1))
		l.servers[i], l.servers[j] = l.servers[j], l.servers[i]
	}
}
350741
func Pool(b []byte) {
	if b == nil {
		return
	}
	c := cap(b)

	// Our smallest buffer is 64 bytes, so we discard smaller buffers.
	if c < 64 {
		return
	}

	// We need to put the incoming buffer into the NEXT buffer,
	// since a buffer guarantees AT LEAST the number of bytes available
	// that is the top of this buffer.
	// That is the reason for dividing the cap by 2, so it gets into the NEXT bucket.
	// We add 2 to avoid rounding down if size is exactly power of 2.
	pn := poolNum((c + 2) >> 1)
	if pn != -1 {
		pools[pn].Put(b[0:0])
	}
	// if we didn't have a slot for this []byte, we just drop it and let the GC
	// take care of it.
}
969308
func (r *amqpRequester) Teardown() error {
	if err := r.channel.Close(); err != nil {
		return err
	}
	return r.conn.Close()
}
226085
func (pool *serverPool) removeEntry(entry *poolEntry) {
	pool.newSelect.remove((*discoveredEntry)(entry))
	pool.knownSelect.remove((*knownEntry)(entry))
	entry.removed = true
	delete(pool.entries, entry.node.ID())
}
300504
func (rb *Rebalancer) UpsertServer(u *url.URL, options ...ServerOption) error {
	rb.mtx.Lock()
	defer rb.mtx.Unlock()

	if err := rb.next.UpsertServer(u, options...); err != nil {
		return err
	}
	weight, _ := rb.next.ServerWeight(u)
	if err := rb.upsertServer(u, weight); err != nil {
		rb.next.RemoveServer(u)
		return err
	}
	rb.reset()
	return nil
}
1062058
func (mt *MultiplexTransport) Cleanup(p Peer) {
	mt.conns.RemoveAddr(p.RemoteAddr())
	_ = p.CloseConn()
}
1031757
func (m *Manager) RemoveServer(s *metadata.Server) {
	m.listLock.Lock()
	defer m.listLock.Unlock()
	l := m.getServerList()

	// Remove the server if known
	for i := range l.servers {
		if l.servers[i].Name == s.Name {
			newServers := make([]*metadata.Server, 0, len(l.servers)-1)
			newServers = append(newServers, l.servers[:i]...)
			newServers = append(newServers, l.servers[i+1:]...)
			l.servers = newServers

			m.saveServerList(l)
			return
		}
	}
}
631077
func (pool *serverPool) saveNodes() {
	list := make([]*poolEntry, len(pool.knownQueue.queue))
	for i := range list {
		list[i] = pool.knownQueue.fetchOldest()
	}
	enc, err := rlp.EncodeToBytes(list)
	if err == nil {
		pool.db.Put(pool.dbKey, enc)
	}
}
1128026
func (is *InfoSyncer) RemoveServerInfo() {
	if is.etcdCli == nil {
		return
	}
	err := ddl.DeleteKeyFromEtcd(is.serverInfoPath, is.etcdCli, keyOpDefaultRetryCnt, keyOpDefaultTimeout)
	if err != nil {
		logutil.Logger(context.Background()).Error("remove server info failed", zap.Error(err))
	}
}
308577
func (l *LoadBalancer) RemoveBackend(b NetAddr) {
	l.Lock()
	defer l.Unlock()
	l.currentIndex = -1
	for i := range l.backends {
		if l.backends[i].Equals(b) {
			l.backends = append(l.backends[:i], l.backends[i+1:]...)
			l.dropConnections(b)
			return
		}
	}
}
416043
func (r *redisRequester) Teardown() error {
	if err := r.conn.Close(); err != nil {
		return err
	}
	r.conn = nil
	return nil
}
1247171
func (gs *GRPCClient) RemoveServer(sv *Server) {
	if _, ok := gs.clientMap.Load(sv.ID); ok {
		// TODO: do I need to disconnect client?
		gs.clientMap.Delete(sv.ID)
		logger.Log.Debugf("[grpc client] removed server %s", sv.ID)
	}
}