def __init__(self):
        # We're running inside an instance
        cfg.update_from_metadata()
        util.setup_api(service_account=True)

        # Just for addinstance
        self.spawn_scheduler = util.Scheduler(cfg.num_workers)
        # For monitoring, deletion, anything else. We can be doing more of these at
        # a time without threatening API quota limits
        self.other_scheduler = util.Scheduler(cfg.num_workers * 2)
        self.state = CluserState.DOWN
        self.instances = {}
        self.errors = []
        self.first_free_slave = 0
        self.live_slaves = 0
        # For long-running remote tasks, such as transfers. Each operation is a
        # dictionary with state and original parameters.
        self.operations = {}
        self.op_counter = 0
        # This protects writing: self.state, state of each self.instances,
        # self.live_slaves
        self.cv = threading.Condition()
        # This is data forwarded to us about the status of the JobTracker
        self.latest_data = {}
        self.last_update = 0
  def __init__(self):
    # We're running inside an instance
    cfg.update_from_metadata()
    util.setup_api(service_account=True)

    # Just for addinstance
    self.spawn_scheduler = util.Scheduler(cfg.num_workers)
    # For monitoring, deletion, anything else. We can be doing more of these at
    # a time without threatening API quota limits
    self.other_scheduler = util.Scheduler(cfg.num_workers * 2)
    self.state = CluserState.DOWN
    self.instances = {}
    self.errors = []
    self.first_free_slave = 0
    self.live_slaves = 0
    # For long-running remote tasks, such as transfers. Each operation is a
    # dictionary with state and original parameters.
    self.operations = {}
    self.op_counter = 0
    # This protects writing: self.state, state of each self.instances,
    # self.live_slaves
    self.cv = threading.Condition()
    # This is data forwarded to us about the status of the JobTracker
    self.latest_data = {}
    self.last_update = 0
Example #3
0
def main():
    cfg.update_from_metadata()
    state = 'READY'
    try:
        setup()
    except subprocess.CalledProcessError as e:
        logging.error('Setup failed: %s', str(e))
        state = 'FAILED'
    os.execl('/home/hadoop/snitch.py', '/home/hadoop/snitch.py', state)
def main():
  cfg.update_from_metadata()
  state = 'READY'
  try:
    setup()
  except subprocess.CalledProcessError as e:
    logging.error('Setup failed: %s', str(e))
    state = 'FAILED'
  os.execl('/home/hadoop/snitch.py', '/home/hadoop/snitch.py', state)
Example #5
0
def start_snitch(app):
  """Set up a status handler and launch the snitch's webserver."""
  cfg.update_from_metadata()
  state = sys.argv[1]

  # The coordinator will poll this
  @app.route('/status')
  def status():
    return json.dumps({'state': state}) + '\n'

  # Bottle's wrapper around cherrypy doesn't let us setup SSL, so do this
  # ourselves
  server = cherrypy.wsgiserver.CherryPyWSGIServer(('0.0.0.0', cfg.port), app)
  server.quiet = True
  server.ssl_certificate = '/etc/ssl/certs/ssl-cert-snakeoil.pem'
  server.ssl_private_key = '/etc/ssl/private/ssl-cert-snakeoil.key'
  try:
    server.start()
  finally:
    server.stop()