예제 #1
0
def actually_offload_proxy(name=None, ip=None, srv=None, pipeline=None):
    name, ip, srv = nameipsrv(name, ip, srv)
    region = region_by_name(name)
    client_table_key = region + ':clientip->srv'
    packed_srv = redis_util.pack_srv(srv)
    #XXX: a proxy -> {clients} index is sorely needed!
    # Getting the set of clients assigned to this proxy takes a long time
    # currently.  Let's get it done before pulling the replacement proxy,
    # so we're less likely to be left with an empty proxy if interrupted.
    clients = set(pip
                  for pip, psrv in redis_shell.hgetall(client_table_key).iteritems()
                  if psrv == packed_srv)
    dest = pull_from_srvq(region)
    # It's still possible that we'll crash or get rebooted here, so the
    # destination server will be left empty. The next closed proxy compaction
    # job will find this proxy and assign some users to it or mark it for
    # retirement.
    dest_psrv = redis_util.pack_srv(dest.srv)
    redis_shell.hmset(client_table_key, {pip: dest_psrv for pip in clients})
    print "Offloaded clients from %s (%s) to %s (%s)" % (name, ip, dest.name, dest.ip)
예제 #2
0
def actually_offload_proxy(name=None, ip=None, srv=None, pipeline=None):
    name, ip, srv = nameipsrv(name, ip, srv)
    region = region_by_name(name)
    client_table_key = region + ':clientip->srv'
    packed_srv = redis_util.pack_srv(srv)
    #XXX: a proxy -> {clients} index is sorely needed!
    # Getting the set of clients assigned to this proxy takes a long time
    # currently.  Let's get it done before pulling the replacement proxy,
    # so we're less likely to be left with an empty proxy if interrupted.
    clients = set(
        pip for pip, psrv in redis_shell.hgetall(client_table_key).iteritems()
        if psrv == packed_srv)
    dest = pull_from_srvq(region)
    # It's still possible that we'll crash or get rebooted here, so the
    # destination server will be left empty. The next closed proxy compaction
    # job will find this proxy and assign some users to it or mark it for
    # retirement.
    dest_psrv = redis_util.pack_srv(dest.srv)
    redis_shell.hmset(client_table_key, {pip: dest_psrv for pip in clients})
    print "Offloaded clients from %s (%s) to %s (%s)" % (name, ip, dest.name,
                                                         dest.ip)
예제 #3
0
def assign_clientip_to_srv(clientip, srvname=None, srvip=None, srv=None):
    nis = redis_util.nameipsrv(srvname, srvip, srv)
    region = region_by_name(nis.name)
    redis_shell.hset(region + ':clientip->srv',
                     redis_util.pack_ip(clientip),
                     redis_util.pack_srv(nis.srv))
예제 #4
0
def assign_clientip_to_srv(clientip, srvname=None, srvip=None, srv=None):
    nis = redis_util.nameipsrv(srvname, srvip, srv)
    region = region_by_name(nis.name)
    redis_shell.hset(region + ':clientip->srv', redis_util.pack_ip(clientip),
                     redis_util.pack_srv(nis.srv))