예제 #1
0
 def wait_for_instances(self, instance_ids, timeout=600):
     start_time = time.time()
     while True:
         if (time.time() - start_time >= timeout):
             raise TimeoutException()
         try:
             if self._all_started(instance_ids):
                 break
         except Exception:
             pass
         sys.stdout.write(".")
         sys.stdout.flush()
         time.sleep(1)
예제 #2
0
 def _wait_for_hadoop(self, number, timeout=600):
     start_time = time.time()
     jobtracker = self._get_jobtracker()
     if not jobtracker:
         return
     print "Waiting for jobtracker to start"
     previous_running = 0
     while True:
         if (time.time() - start_time >= timeout):
             raise TimeoutException()
         try:
             actual_running = self._number_of_tasktrackers(
                 jobtracker.public_ip, 1)
             break
         except IOError:
             pass
         sys.stdout.write(".")
         sys.stdout.flush()
         time.sleep(1)
     print
     if number > 0:
         print "Waiting for %d tasktrackers to start" % number
         while actual_running < number:
             if (time.time() - start_time >= timeout):
                 raise TimeoutException()
             try:
                 actual_running = self._number_of_tasktrackers(
                     jobtracker.public_ip, 5, 2)
                 if actual_running != previous_running:
                     sys.stdout.write("%d" % actual_running)
                 sys.stdout.write(".")
                 sys.stdout.flush()
                 time.sleep(1)
                 previous_running = actual_running
             except IOError:
                 pass
         print
예제 #3
0
파일: ec2.py 프로젝트: qtt-bigdata/hadoop
 def wait_for_instances(self, instance_ids, timeout=600):
     start_time = time.time()
     while True:
         if (time.time() - start_time >= timeout):
             raise TimeoutException()
         try:
             if self._all_started(
                     self.ec2Connection.get_all_instances(instance_ids)):
                 break
         # don't timeout for race condition where instance is not yet registered
         except EC2ResponseError:
             pass
         sys.stdout.write(".")
         sys.stdout.flush()
         time.sleep(1)
예제 #4
0
  def wait_for_instances(self, reservations, roles=None, timeout=600, sleep=5):
    if roles is None:
      raise Exception("roles are required for Spot Instances")

    try:
      for retry in range(0, timeout, sleep):
        reservations = self.ec2Connection.get_all_spot_instance_requests([r.id for r in reservations])
        if self._all_started(reservations, roles):
          reservations = []
          break
        sys.stdout.write(".")
        sys.stdout.flush()
        time.sleep(sleep)
      else:
        instances = [i.id for i in self._get_instances_with_roles(roles)]
        if instances:
          self.ec2Connection.terminate_instances(instances)
        raise TimeoutException()
    finally:
      print
      map(lambda r: r.cancel(), reservations)