'Send statistics to server.'

def _SendStatistics(self):

    try:
        stat = self.handler_cls.GetStatistics()
        body = stat.SerializeToString()
        headers = {'Content-Length': len(body)}
        res = self.pool.urlopen('POST', '/server/state', headers=headers, body=body)
        if (res.status == constants.RESPONSE_SERVER_NOT_REGISTERED):
            self.Register()
            return True
        if (res.status != constants.RESPONSE_OK):
            logging.warning('Could    not    send    statistics    to    data    master.')
            return False
        mapping = rdf_data_server.DataServerMapping.FromSerializedString(res.data)
        self.handler_cls.SERVICE.SaveServerMapping(mapping)
        return True
    except (urllib3.exceptions.MaxRetryError, errors.DataServerError):
        logging.warning('Could    not    send    statistics    to    data    master.')
        return False
