def addserver(self, name, host, port):
        self.servers_lock.acquire()
        if name in self.servers:
            (oldhost, oldport, sock) = self.servers[name]
            if host == oldhost or port == oldport:
                # leave this socket connected
                if sock is not None:
                    self.servers_lock.release()
                    return
            if self.verbose and host is not None and sock is not None:
                self.session.info("closing connection with %s @ %s:%s" % \
                                  (name, host, port))
            if sock is not None:
                sock.close()
        self.servers_lock.release()
        if self.verbose and host is not None:
            self.session.info("adding server %s @ %s:%s" % (name, host, port))
        if host is None:
            sock = None
        else:
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            #sock.setblocking(0)
            #error = sock.connect_ex((host, port))
            try:
                sock.connect((host, port))
                self.startrecvloop()
            except Exception, e:
                self.session.warn("error connecting to server %s:%s:\n\t%s" % \
                                  (host, port, e))
                sock.close()
                sock = None
        self.servers_lock.acquire()
        self.servers[name] = (host, port, sock)
        self.servers_lock.release()
Convert a filter query to Riak index query.
dataset/ETHPy150Open coreemu/core/daemon/core/broker.py/CoreBroker.addserver--crossover with--dataset/ETHPy150Open mining/mining/mining/db/backends/mriak/multiquery.py/RiakMultiIndexQuery._filter_to_index_query