Exemplo n.º 1
0
def get_status(handler):
    """Check status. 
       query args: 
         scenario=name 
         session=name
         check_database=true|false (default true)
         local_cache=true|false (default true)
    """
    request = handler.request
    cache = Cache(get_hostname(request))
    response = dict(version=version, data={})
    args = dict(
        (key, value[0]) for key, value in request.arguments.iteritems())
    local_cache = asbool(args.get('local_cache', True))
    redis_server = get_redis_server(local_cache)
    response['data']['cache_server'] = {'local': local_cache}
    response['data']['info'] = {
        'cluster': handler.settings.get('cluster_name'),
        'graphite_host': handler.settings.get('graphite.host')
    }

    try:
        result = redis_server.ping()
        response['data']['cache_server']['status'] = 'ok' if result else 'bad'
    except Exception, e:
        response['data']['cache_server']['status'] = 'bad'
        response['data']['cache_server']['error'] = str(e)
        return response
Exemplo n.º 2
0
def get_status(handler):
    """Check status. 
       query args: 
         scenario=name 
         session=name
         check_database=true|false (default true)
         local_cache=true|false (default true)
    """
    request = handler.request
    cache = Cache(get_hostname(request))
    response = dict(version=version, data={})   
    args = dict((key, value[0]) for key, value in request.arguments.iteritems()) 
    local_cache = asbool(args.get('local_cache', True))
    redis_server = get_redis_server(local_cache)
    response['data']['cache_server'] = {'local' : local_cache}
    response['data']['info'] = {
        'cluster' : handler.settings.get('cluster_name'),
        'graphite_host' : handler.settings.get('graphite.host')
    }

    try:
        result = redis_server.ping()
        response['data']['cache_server']['status'] = 'ok' if result else 'bad'   
    except Exception, e:
        response['data']['cache_server']['status'] = 'bad'
        response['data']['cache_server']['error'] = str(e)
        return response   
Exemplo n.º 3
0
 def remove(self, module_name):
     key = self.key(module_name)
     log.debug('remove {0} module from cache'.format(key))
     return Queue(key, server=get_redis_server(local=False)).delete()
Exemplo n.º 4
0
 def add(self, module_name, code):
     key = self.key(module_name)
     log.debug('add {0} module to cache'.format(key))
     q = Queue(key, server=get_redis_server(local=False))
     q.put(code)