Example #1
0
 def start(self):
     from twisted.internet.defer import Deferred
     from logs import lg
     from main.config import conf
     from main import events
     from raid import eccmap
     from services import driver
     from customer import fire_hire
     self.starting_deferred = Deferred()
     self.starting_deferred.addErrback(
         lambda err: lg.warn('service %r was not started: %r' %
                             (self.service_name, err.getErrorMessage()
                              if err else 'unknown reason')))
     self.all_suppliers_hired_event_sent = False
     if driver.is_on('service_entangled_dht'):
         self._do_join_suppliers_dht_layer()
     eccmap.Update()
     fire_hire.A('init')
     fire_hire.A().addStateChangedCallback(self._on_fire_hire_ready, None,
                                           'READY')
     conf().addConfigNotifier('services/customer/suppliers-number',
                              self._on_suppliers_number_modified)
     conf().addConfigNotifier('services/customer/needed-space',
                              self._on_needed_space_modified)
     events.add_subscriber(self._on_supplier_modified, 'supplier-modified')
     events.add_subscriber(self._on_dht_layer_connected,
                           event_id='dht-layer-connected')
     if fire_hire.IsAllHired():
         self.starting_deferred.callback(True)
         self.starting_deferred = None
         lg.info('all my suppliers are already hired')
         return True
     fire_hire.A('restart')
     return self.starting_deferred
Example #2
0
 def _on_suppliers_number_modified(self, path, value, oldvalue, result):
     from logs import lg
     from customer import fire_hire
     from raid import eccmap
     lg.info('my desired suppliers number changed')
     eccmap.Update()
     self._do_check_all_hired()
     fire_hire.ClearLastFireTime()
     fire_hire.A('restart')
Example #3
0
 def start(self):
     from customer import fire_hire
     from main.config import conf
     from main import events
     from raid import eccmap
     eccmap.Update()
     fire_hire.A('init')
     conf().addCallback('services/customer/suppliers-number',
                        self._on_suppliers_number_modified)
     conf().addCallback('services/customer/needed-space',
                        self._on_needed_space_modified)
     events.add_subscriber(self._on_supplier_modified, 'supplier-modified')
     self._do_cleanup_dht_suppliers()
     return True
Example #4
0
 def _on_suppliers_number_modified(self, path, value, oldvalue, result):
     from customer import fire_hire
     from raid import eccmap
     eccmap.Update()
     fire_hire.ClearLastFireTime()
     fire_hire.A('restart')