예제 #1
0
  def become_master(self):
    assert not self.is_master()

    logger.info('%s becoming master' % self.server_id)
    self.state.assert_clean()
    self.state.set_election_victory_time()

    # Wake up the thread that does discovery and getting capacity.
    scheduler.update_thread(self, 0)
예제 #2
0
    def become_master(self):
        assert not self.is_master()

        logger.info('%s becoming master' % self.server_id)
        self.state.assert_clean()
        self.state.set_election_victory_time()

        # Wake up the thread that does discovery and getting capacity.
        scheduler.update_thread(self, 0)
예제 #3
0
  def add_resource(self, resource_id, priority, wants, fraction=0, interval=1):
    # Checks that the resource is not yet present; that would be a fatal
    # error.
    r = self._find_resource(resource_id)

    assert not r

    # Adds a new resource object to the state and stores the resource
    # information in it.
    r = self.state.resource.add()
    r.resource_id = resource_id
    r.priority = priority
    r.wants = wants

    # No need to kick off the process of randomly changing the "wants"
    # of this resource if the fraction is zero.
    if fraction > 0:
      assert interval > 0
      _ChangeWants(self.state.client_id, r, fraction, interval)

    # Immediately try and get some capacity for this resource (and,
    # as a consequence, for all other resources as well).
    scheduler.update_thread(self, 0)