Changeset 3297

Show
Ignore:
Timestamp:
12/17/09 10:41:54 (10 years ago)
Author:
cemeyer
Message:

#781: Integrate DORadvertise.repy into advertise.repy.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • seattle/trunk/seattlelib/advertise.repy

    r2789 r3297  
    1616include openDHTadvertise.repy 
    1717include centralizedadvertise.repy 
    18  
     18include DORadvertise.repy 
    1919include parallelize.repy 
    2020 
     21 
     22# All the names of services we can support. 
     23_advertise_all_services = ("central", "DHT", "DOR") 
     24 
     25 
    2126nodemanager_announce_context = {} 
    22 nodemanager_announce_context["skipDHT"] = 0 
    23 nodemanager_announce_context["previousDHTskip"] = 1 
    24 nodemanager_announce_context["skipcentral"] = 0 
    25 nodemanager_announce_context["previouscentralskip"] = 1 
     27for service in _advertise_all_services: 
     28  nodemanager_announce_context["skip" + service] = 0 
     29  nodemanager_announce_context["previous" + service + "skip"] = 1 
    2630nodemanager_announce_context_lock = getlock() 
    2731 
     
    3943  which_service, key, value, ttlval, exceptions, finishedref = args 
    4044 
    41   if which_service not in ("central", "DHT"): 
     45  if which_service not in _advertise_all_services: 
    4246    raise AdvertiseError("Incorrect service type used in internal function _try_advertise_announce.") 
    4347 
     
    4549    if which_service == "central": 
    4650      centralizedadvertise_announce(key, value, ttlval) 
     51    elif which_service == "DOR": 
     52      DORadvertise_announce(key, value, ttlval) 
    4753    else: 
    4854      openDHTadvertise_announce(key, value, ttlval) 
     
    117123  onefinished = [False] 
    118124 
    119   for service_type in ("central", "DHT"): 
     125  for service_type in _advertise_all_services: 
    120126    if nodemanager_announce_context["skip" + service_type] == 0: 
    121127      parallize_worksets.append((service_type, key, value, ttlval, \ 
     
    157163  which_service, key, maxvals, finishedref = args 
    158164 
    159   if which_service not in ("central", "DHT"): 
     165  if which_service not in _advertise_all_services: 
    160166    raise AdvertiseError("Incorrect service type used in internal function _try_advertise_lookup.") 
    161167 
     
    163169    if which_service == "central": 
    164170      results = centralizedadvertise_lookup(key, maxvals) 
     171    elif which_service == "DOR": 
     172      results = DORadvertise_lookup(key, maxvals=maxvals) 
    165173    else: 
    166174      results = openDHTadvertise_lookup(key, maxvals) 
     
    175183 
    176184 
    177 def advertise_lookup(key, maxvals=100, lookuptype=['central','opendht'], \ 
     185def advertise_lookup(key, maxvals=100, lookuptype=['central','opendht','DOR'], \ 
    178186    concurrentevents=2, graceperiod=10, timeout=60): 
    179187  """ 
     
    189197            Maximum number of values to return. 
    190198 
    191     lookuptype (optional, defaults to ['central', 'opendht']): 
     199    lookuptype (optional, defaults to ['central', 'opendht', 'DOR']): 
    192200            Which services to employ looking up values. 
    193201     
     
    221229    if type == "central": 
    222230      parallel_worksets.append(("central", key, maxvals, onefinished)) 
     231    elif type == "DOR": 
     232      parallel_worksets.append(("DOR", key, maxvals, onefinished)) 
    223233    elif type == "opendht": 
    224234      parallel_worksets.append(("DHT", key, maxvals, onefinished))