当前位置: 首页>>代码示例>>Python>>正文


Python MesosSchedulerDriver.on_event方法代码示例

本文整理汇总了Python中pymesos.MesosSchedulerDriver.on_event方法的典型用法代码示例。如果您正苦于以下问题:Python MesosSchedulerDriver.on_event方法的具体用法?Python MesosSchedulerDriver.on_event怎么用?Python MesosSchedulerDriver.on_event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymesos.MesosSchedulerDriver的用法示例。


在下文中一共展示了MesosSchedulerDriver.on_event方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_on_failure

# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import on_event [as 别名]
def test_on_failure(mocker):
    ID = str(uuid.uuid4())
    sched = mocker.Mock()
    framework = {'id': {'value': ID}}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver._started = True
    executor_id = dict(value=str(uuid.uuid4()))
    agent_id = dict(value=str(uuid.uuid4()))
    status = random.randint(0, 256)
    event = {
        'type': 'FAILURE',
        'failure': {
            'executor_id': executor_id,
            'agent_id': agent_id,
            'status': status
        }
    }
    driver.on_event(event)
    sched.executorLost.assert_called_once_with(driver, executor_id,
                                               agent_id, status)

    event = {
        'type': 'FAILURE',
        'failure': {
            'agent_id': agent_id,
        }
    }
    driver.on_event(event)
    sched.slaveLost.assert_called_once_with(driver, agent_id)
开发者ID:windreamer,项目名称:pymesos,代码行数:32,代码来源:test_scheduler.py

示例2: test_on_error

# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import on_event [as 别名]
def test_on_error(mocker):
    ID = str(uuid.uuid4())
    sched = mocker.Mock()
    framework = {'id': {'value': ID}}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver._started = True
    msg = 'error message'
    event = {
        'type': 'ERROR',
        'error': {
            'message': msg
        }
    }
    driver.on_event(event)
    sched.error.assert_called_once_with(driver, msg)
开发者ID:windreamer,项目名称:pymesos,代码行数:18,代码来源:test_scheduler.py

示例3: test_on_rescind

# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import on_event [as 别名]
def test_on_rescind(mocker):
    ID = str(uuid.uuid4())
    sched = mocker.Mock()
    framework = {'id': {'value': ID}}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver._started = True
    offer_id = {'value': str(uuid.uuid4())}
    event = {
        'type': 'RESCIND',
        'rescind': {
            'offer_id': offer_id
        }
    }
    driver.on_event(event)
    sched.offerRescinded.assert_called_once_with(driver, offer_id)
开发者ID:windreamer,项目名称:pymesos,代码行数:18,代码来源:test_scheduler.py

示例4: test_on_offers

# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import on_event [as 别名]
def test_on_offers(mocker):
    ID = str(uuid.uuid4())
    sched = mocker.Mock()
    framework = {'id': {'value': ID}}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver._started = True
    offers = [{
        'offer_id': {'value': str(uuid.uuid4())}
    } for _ in range(random.randint(1, 10))]
    event = {
        'type': 'OFFERS',
        'offers': {
            'offers': offers
        }
    }
    driver.on_event(event)
    sched.resourceOffers.assert_called_once_with(driver, offers)
开发者ID:windreamer,项目名称:pymesos,代码行数:20,代码来源:test_scheduler.py

示例5: test_on_message

# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import on_event [as 别名]
def test_on_message(mocker):
    ID = str(uuid.uuid4())
    sched = mocker.Mock()
    framework = {'id': {'value': ID}}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver._started = True
    executor_id = {'value': str(uuid.uuid4())}
    agent_id = {'value': str(uuid.uuid4())}
    message = ''.join(random.choice(string.printable)
                      for _ in range(random.randint(1, 100)))
    data = encode_data(message.encode('utf8'))

    event = {
        'type': 'MESSAGE',
        'message': {
            'executor_id': executor_id,
            'agent_id': agent_id,
            'data': data
        }
    }
    driver.on_event(event)
    sched.frameworkMessage.assert_called_once_with(driver, executor_id,
                                                   agent_id, data)
开发者ID:windreamer,项目名称:pymesos,代码行数:26,代码来源:test_scheduler.py

示例6: test_on_subscribed

# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import on_event [as 别名]
def test_on_subscribed(mocker):
    sched = mocker.Mock()
    framework = {}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver.version = '1.0.0'
    driver._started = True
    driver._master = 'mock_addr:12345'
    framework_id = {
        'value': str(uuid.uuid4())
    }

    event = {
        'type': 'SUBSCRIBED',
        'subscribed': {
            'framework_id': framework_id
        }
    }
    driver.on_event(event)
    sched.registered.assert_called_once_with(driver, framework_id, {
        'hostname': 'mock_addr',
        'port': 12345,
        'version': '1.0.0'
    })
开发者ID:windreamer,项目名称:pymesos,代码行数:26,代码来源:test_scheduler.py


注:本文中的pymesos.MesosSchedulerDriver.on_event方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。