'This function uses the sge stats to decide whether or not to
remove a node from the cluster.'

def _eval_remove_node(self):

    qlen = len(self.stat.get_queued_jobs())
    if (qlen != 0):
        return
    if (not self.has_cluster_stabilized()):
        return
    num_nodes = len(self._cluster.nodes)
    if (num_nodes <= self.min_nodes):
        log.info(('Not    removing    nodes:    already    at    or    below    minimum    (%d)' % self.min_nodes))
        return
    max_remove = (num_nodes - self.min_nodes)
    log.info('Looking    for    nodes    to    remove...')
    remove_nodes = self._find_nodes_for_removal(max_remove=max_remove)
    if (not remove_nodes):
        log.info('No    nodes    can    be    removed    at    this    time')
    for node in remove_nodes:
        if (node.update() != 'running'):
            log.error(('Node    %s    is    already    dead    -    not    removing' % node.alias))
            continue
        log.warn(('Removing    %s:    %s    (%s)' % (node.alias, node.id, node.dns_name)))
        try:
            self._cluster.remove_node(node)
            self.__last_cluster_mod_time = utils.get_utc_now()
        except Exception:
            log.error(('Failed    to    remove    node    %s' % node.alias), exc_info=True)
