예제 #1
0
def main(args):
  scheduler = ExampleScheduler()
  framework = mesos_pb2.FrameworkInfo(
      user='******',
      name='example',
  )
  driver = PesosSchedulerDriver(
      scheduler=scheduler,
      framework=framework,
      master_uri=args[0],
  )

  task = Task(
      'hello_world',
      Resources(1, 256, 256),
      # Command('echo hello world'),
      Executor(
          command=Command(
              '/home/vagrant/pesos.pex /vagrant/pesos/bin/example_executor.py',
              shell=True,
          ),
          resources=Resources(1, 256, 256),
      ),
  )

  scheduler.add_pending(task)

  print('Starting driver')
  driver.start()

  print('Joining driver')
  driver.join()
예제 #2
0
def main(args):
    scheduler = ExampleScheduler()
    framework = mesos_pb2.FrameworkInfo(
        user='******',
        name='example',
    )
    driver = PesosSchedulerDriver(
        scheduler=scheduler,
        framework=framework,
        master_uri=args[0],
    )

    task = Task(
        'hello_world',
        Resources(1, 256, 256),
        # Command('echo hello world'),
        Executor(
            command=Command(
                '/home/vagrant/pesos.pex /vagrant/pesos/bin/example_executor.py',
                shell=True,
            ),
            resources=Resources(1, 256, 256),
        ),
    )

    scheduler.add_pending(task)

    print('Starting driver')
    driver.start()

    print('Joining driver')
    driver.join()
예제 #3
0
def main(args):
  scheduler = ExampleScheduler()
  framework = FrameworkInfo(
      user=getpass.getuser(),
      name='example',
  )
  driver = PesosSchedulerDriver(
      scheduler=scheduler,
      framework=framework,
      master_uri=args[0],
  )

  print('Starting driver')
  driver.start()

  print('Joining driver')
  driver.join()
예제 #4
0
  def test_scheduler_master_failover(self):
    disconnected_event, disconnected_call, disconnected_side_effect = self.mock_method()
    registered_event, registered_call, registered_side_effect = self.mock_method()
    reregistered_event, reregistered_call, reregistered_side_effect = self.mock_method()
    scheduler = mock.create_autospec(Scheduler, spec_set=True)
    scheduler.disconnected = mock.Mock(side_effect=disconnected_side_effect)
    scheduler.registered = mock.Mock(side_effect=registered_side_effect)
    scheduler.reregistered = mock.Mock(side_effect=reregistered_side_effect)

    standby_master = MockMaster()
    self.context.spawn(standby_master)

    driver = PesosSchedulerDriver(
        scheduler, self.framework_info, str(self.master.pid), context=self.context)
    assert driver.start() == mesos_pb2.DRIVER_RUNNING

    driver.scheduler_process.connected.wait(timeout=MAX_TIMEOUT)
    assert driver.scheduler_process.connected.is_set()

    registered_event.wait(timeout=MAX_TIMEOUT)
    assert registered_event.is_set()

    # now fail the current master
    driver.detector.appoint(None)
    disconnected_event.wait(timeout=MAX_TIMEOUT)
    assert disconnected_event.is_set()

    # now appoint the new master
    driver.detector.appoint(standby_master.pid)
    standby_master.reregister_event.wait(timeout=MAX_TIMEOUT)
    assert standby_master.reregister_event.is_set()
    assert standby_master.frameworks == self.master.frameworks
    reregistered_event.wait(timeout=MAX_TIMEOUT)
    assert reregistered_event.is_set()
    assert reregistered_call.mock_calls == [
        mock.call(driver, pid_to_master_info(standby_master.master_id, standby_master.pid))]
    assert driver.stop() == mesos_pb2.DRIVER_STOPPED
예제 #5
0
  def test_scheduler_scheduler_failover(self):
    reregistered_event, reregistered_call, reregistered_side_effect = self.mock_method()
    scheduler = mock.create_autospec(Scheduler, spec_set=True)
    scheduler.reregistered = mock.Mock(side_effect=reregistered_side_effect)

    self.framework_info.id.MergeFrom(self.framework_id)

    driver = PesosSchedulerDriver(
        scheduler, self.framework_info, str(self.master.pid), context=self.context)
    assert driver.start() == mesos_pb2.DRIVER_RUNNING

    driver.scheduler_process.connected.wait(timeout=MAX_TIMEOUT)
    assert driver.scheduler_process.connected.is_set()

    reregistered_event.wait(timeout=MAX_TIMEOUT)
    assert reregistered_event.is_set()

    assert len(self.master.frameworks) == 1

    framework_id = next(iter(self.master.frameworks))
    assert reregistered_call.mock_calls == [
        mock.call(driver, pid_to_master_info(self.master.master_id, self.master.pid))]

    assert driver.stop() == mesos_pb2.DRIVER_STOPPED