def scenario_four(reporter):
    root_job = ServerJob('root', 0, 3)
    regional_job = ServerJob('regional', 1, 3, root_job)

    for i in xrange(0, 5):
        c = Client('client', regional_job)
        c.add_resource('resource0', 0, 100, 0.1, 10)

    reporter.schedule('resource0')
    reporter.set_filename('scenario_four')

    return regional_job
def scenario_five(reporter, num_clients=5):
    root_job = ServerJob('root', 0, 3)

    for i in xrange(1, 4):
        region_job = ServerJob('region:%i' % i, 1, 3, root_job)

        for j in xrange(1, 4):
            dc_job = ServerJob('dc:%d:%d' % (i, j), 2, 3, region_job)

            for k in xrange(1, num_clients + 1):
                client = Client('client:%d:%d' % (i, j), dc_job)
                client.add_resource('resource0', 0, 15, 0.1, 10)

    reporter.schedule('resource0')
    reporter.set_filename('scenario_five')
Exemple #3
0
def lose_master():
    job = ServerJob.get_random_server_job()
    t = random.randint(0, 60)
    logger.info('Random mishap: Losing master job %s for %d seconds' %
                (job.get_job_name(), t))
    job.lose_master()
    scheduler.add_relative(t, lambda: job.trigger_master_election())
def lose_master():
  job = ServerJob.get_random_server_job()
  t = random.randint(0, 60)
  logger.info(
      'Random mishap: Losing master job %s for %d seconds' %
      (job.get_job_name(), t))
  job.lose_master()
  scheduler.add_relative(t, lambda: job.trigger_master_election())
Exemple #5
0
def scenario_one(reporter):
  job = ServerJob('root', 0, 3)

  for i in xrange(0, 5):
    c = Client('client', job)
    c.add_resource('resource0', 0, 110, 0.1, 10)

  reporter.schedule('resource0')
  reporter.set_filename('scenario_one')

  return job
Exemple #6
0
  def gather_reporting_data(self, resource_id):
    logger.info('Gathering reporting data')
    now = clock.get_time()

    # Adds a record to the data set for this timestamp.
    self.data[now] = dict()
    self.summaries[now] = dict()

    # Adds a summary record for the clients
    p = ReportingData()
    p.total_wants = 0
    p.total_has = 0
    self.summaries[now]['clients'] = p
    self.all_summaries.add('clients')

    # Step 1: Goes through all the clients in the system, gets their
    # reporting data and adds it to the data set.
    for client in Client.all_clients():
      client_id = client.get_client_id()
      self.all_clients.add(client_id)
      data = client.get_reporting_data(resource_id)

      if data:
        self.data[now][client_id] = data
        logger.debug('%s: %s' % (client_id, str(data)))
        p.total_wants += data.wants
        p.total_has += data.has
      else:
        logger.warning('No reporting data received from %s' % client_id)

    # Step 2: Find the master server of every job, get its reporting data
    # and add it to the data set.
    for job in ServerJob.all_server_jobs():
      current_master = job.get_master()

      # If this job does not have a master then we got nothing to do.
      if not current_master:
        continue

      job_name = job.get_job_name()
      self.all_server_jobs.add(job_name)
      data = current_master.get_reporting_data(resource_id)

      if data:
        self.data[now][job_name] = data
        logger.debug('%s: %s' % (job_name, str(data)))
        key = 'level %d' % current_master.get_server_level()
        self.all_summaries.add(key)

        if not key in self.summaries[now]:
          p = ReportingData()
          p.total_wants = 0
          p.total_has = 0
          p.total_leases = 0
          p.total_outstanding = 0
          self.summaries[now][key] = p
        else:
          p = self.summaries[now][key]

        p.total_wants += data.wants
        p.total_has += data.has
        p.total_leases += data.leases
        p.total_outstanding += data.outstanding
      else:
        logger.warning(
            'No reporting data received from %s' %
            current_master.get_server_id())
Exemple #7
0
def trigger_master_election():
    job = ServerJob.get_random_server_job()
    logger.info('Random mishap: Triggering master election in job %s' %
                job.get_job_name())
    job.trigger_master_election()
def trigger_master_election():
  job = ServerJob.get_random_server_job()
  logger.info(
      'Random mishap: Triggering master election in job %s' %
      job.get_job_name())
  job.trigger_master_election()