本文整理汇总了Python中pymesos.MesosSchedulerDriver._started方法的典型用法代码示例。如果您正苦于以下问题:Python MesosSchedulerDriver._started方法的具体用法?Python MesosSchedulerDriver._started怎么用?Python MesosSchedulerDriver._started使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymesos.MesosSchedulerDriver
的用法示例。
在下文中一共展示了MesosSchedulerDriver._started方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_on_failure
# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _started [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)
示例2: test_on_error
# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _started [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)
示例3: test_on_rescind
# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _started [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)
示例4: test_on_offers
# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _started [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)
示例5: test_on_message
# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _started [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)
示例6: test_on_subscribed
# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _started [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'
})