本文整理匯總了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'
})