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


Python MesosSchedulerDriver._send方法代码示例

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


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

示例1: test_acknowledge_status_update

# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _send [as 别名]
def test_acknowledge_status_update(mocker):
    ID = str(uuid.uuid4())
    sched = mocker.Mock()
    framework = {'id': {'value': ID}}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver._send = mocker.Mock()
    agent_id = dict(value=str(uuid.uuid4()))
    task_id = dict(value=str(uuid.uuid4()))
    uid = encode_data(uuid.uuid4().bytes)
    status = {
        'agent_id': agent_id,
        'task_id': task_id,
        'uuid': uid
    }
    driver.acknowledgeStatusUpdate(status)
    driver._send.assert_called_once_with({
        'type': 'ACKNOWLEDGE',
        'framework_id': {
            'value': ID
        },
        'acknowledge': {
            'agent_id': agent_id,
            'task_id': task_id,
            'uuid': uid
        }
    })
开发者ID:windreamer,项目名称:pymesos,代码行数:29,代码来源:test_scheduler.py

示例2: test_accept_offers

# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _send [as 别名]
def test_accept_offers(mocker):
    ID = str(uuid.uuid4())
    sched = mocker.Mock()
    framework = {'id': {'value': ID}}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver._send = mocker.Mock()
    offer_ids = [str(uuid.uuid4()) for _ in range(random.randint(1, 10))]
    operations = [{
        'type': 'LAUNCH',
        'launch': {
            'task_infos': [
                {
                    'name': '1',
                },
                {
                    'name': '2',
                }
            ]
        }
    }]
    driver.acceptOffers(offer_ids, operations)
    driver._send.assert_called_once_with({
        'type': 'ACCEPT',
        'framework_id': {
            'value': ID
        },
        'accept': {
            'offer_ids': offer_ids,
            'operations': operations,
        }
    })
开发者ID:windreamer,项目名称:pymesos,代码行数:34,代码来源:test_scheduler.py

示例3: test_reconcile_tasks

# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _send [as 别名]
def test_reconcile_tasks(mocker):
    ID = str(uuid.uuid4())
    sched = mocker.Mock()
    framework = {'id': {'value': ID}}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver._send = mocker.Mock()
    task_ids = [str(uuid.uuid4()) for _ in range(random.randint(1, 10))]
    tasks = [
        {
            'task_id': {
                'value': id
            }
        }
        for id in task_ids
    ]
    driver.reconcileTasks(tasks)
    driver._send.assert_called_once_with({
        'type': 'RECONCILE',
        'framework_id': {
            'value': ID
        },
        'reconcile': {
            'tasks': tasks
        }
    })
开发者ID:windreamer,项目名称:pymesos,代码行数:28,代码来源:test_scheduler.py

示例4: test_send_framework_message

# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _send [as 别名]
def test_send_framework_message(mocker):
    ID = str(uuid.uuid4())
    sched = mocker.Mock()
    framework = {'id': {'value': ID}}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver._send = mocker.Mock()
    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)))
    message = encode_data(message.encode('utf-8'))
    driver.sendFrameworkMessage(executor_id, agent_id, message)
    driver._send.assert_not_called()
    driver._stream_id = 'a-stream-id'
    driver.sendFrameworkMessage(executor_id, agent_id, message)
    driver._send.assert_called_once_with({
        'type': 'MESSAGE',
        'framework_id': {
            'value': ID
        },
        'message': {
            'agent_id': agent_id,
            'executor_id': executor_id,
            'data': message,
        }
    })
开发者ID:douban,项目名称:pymesos,代码行数:29,代码来源:test_scheduler.py

示例5: test_reconcile_operations

# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _send [as 别名]
def test_reconcile_operations(mocker):
    ID = str(uuid.uuid4())
    sched = mocker.Mock()
    framework = {'id': {'value': ID}}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver._send = mocker.Mock()
    op_ids = [str(uuid.uuid4()) for _ in range(random.randint(1, 10))]
    operations = [
        {
            'operation_id': {
                'value': id
            }
        }
        for id in op_ids
    ]
    driver.reconcileOperations(operations)
    driver._send.assert_not_called()
    driver._stream_id = 'a-stream-id'
    driver.reconcileOperations(operations)
    driver._send.assert_called_once_with({
        'type': 'RECONCILE_OPERATIONS',
        'framework_id': {
            'value': ID
        },
        'reconcile_operations': {
            'operations': operations
        }
    })
开发者ID:douban,项目名称:pymesos,代码行数:31,代码来源:test_scheduler.py

示例6: test_acknowledge_operation_status_update

# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _send [as 别名]
def test_acknowledge_operation_status_update(mocker):
    ID = str(uuid.uuid4())
    sched = mocker.Mock()
    framework = {'id': {'value': ID}}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver._send = mocker.Mock()
    agent_id = dict(value=str(uuid.uuid4()))
    operation_id = dict(value=str(uuid.uuid4()))
    uid = encode_data(uuid.uuid4().bytes)
    status = {
        'agent_id': agent_id,
        'operation_id': operation_id,
        'uuid': uid
    }
    driver.acknowledgeOperationStatusUpdate(status)
    driver._send.assert_not_called()
    driver._stream_id = 'a-stream-id'
    driver.acknowledgeOperationStatusUpdate(status)
    driver._send.assert_called_once_with({
        'type': 'ACKNOWLEDGE_OPERATION_STATUS',
        'framework_id': {
            'value': ID
        },
        'acknowledge_operation_status': {
            'agent_id': agent_id,
            'operation_id': operation_id,
            'uuid': uid,
        }
    })
开发者ID:douban,项目名称:pymesos,代码行数:32,代码来源:test_scheduler.py

示例7: test_revive_offers

# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _send [as 别名]
def test_revive_offers(mocker):
    ID = str(uuid.uuid4())
    sched = mocker.Mock()
    framework = {'id': {'value': ID}}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver._send = mocker.Mock()
    driver._stream_id = str(uuid.uuid4())
    driver.reviveOffers()
    driver._send.assert_called_once_with({
        'type': 'REVIVE',
        'framework_id': {
            'value': ID
        },
    })
开发者ID:windreamer,项目名称:pymesos,代码行数:17,代码来源:test_scheduler.py

示例8: test_teardown

# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _send [as 别名]
def test_teardown(mocker):
    ID = str(uuid.uuid4())
    sched = mocker.Mock()
    framework = {'id': {'value': ID}}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver._send = mocker.Mock()
    driver.stream_id = str(uuid.uuid4())
    assert driver.connected
    driver._teardown()
    driver._send.assert_called_once_with({
        'type': 'TEARDOWN',
        'framework_id': {
            'value': ID
        },
    })
开发者ID:windreamer,项目名称:pymesos,代码行数:18,代码来源:test_scheduler.py

示例9: test_decline_offer

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

示例10: test_kill_task

# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _send [as 别名]
def test_kill_task(mocker):
    ID = str(uuid.uuid4())
    sched = mocker.Mock()
    framework = {'id': {'value': ID}}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver._send = mocker.Mock()
    driver.killTask({"value": "my-task"})
    driver._send.assert_not_called()
    driver._stream_id = str(uuid.uuid4())
    driver.killTask({"value": "my-task"})
    driver._send.assert_called_once_with({
        'type': 'KILL',
        'framework_id': {'value': ID},
        'kill': {
            'task_id': {'value': 'my-task'},
        }
    })
开发者ID:douban,项目名称:pymesos,代码行数:20,代码来源:test_scheduler.py

示例11: test_suppress_offers_roles

# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _send [as 别名]
def test_suppress_offers_roles(mocker):
    ID = str(uuid.uuid4())
    sched = mocker.Mock()
    framework = {'id': {'value': ID}}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver._send = mocker.Mock()
    driver._stream_id = str(uuid.uuid4())
    driver.suppressOffers(['role1', 'role2'])
    driver._send.assert_called_once_with({
        'type': 'SUPPRESS',
        'framework_id': {
            'value': ID
        },
        'suppress': {
            'roles': ['role1', 'role2']
        }
    })
开发者ID:douban,项目名称:pymesos,代码行数:20,代码来源:test_scheduler.py

示例12: test_request_resources

# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _send [as 别名]
def test_request_resources(mocker):
    ID = str(uuid.uuid4())
    sched = mocker.Mock()
    framework = {'id': {'value': ID}}
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    driver._send = mocker.Mock()
    requests = [{
        'agent_id': {'value': str(uuid.uuid4())},
        'resources': {}
    } for _ in range(random.randint(1, 10))]
    driver.requestResources(requests)
    driver._send.assert_called_once_with({
        'type': 'REQUEST',
        'framework_id': {
            'value': ID
        },
        'request': {
            'requests': requests
        }
    })
开发者ID:windreamer,项目名称:pymesos,代码行数:23,代码来源:test_scheduler.py

示例13: test_send

# 需要导入模块: from pymesos import MesosSchedulerDriver [as 别名]
# 或者: from pymesos.MesosSchedulerDriver import _send [as 别名]
def test_send(mocker):
    sched = mocker.Mock()
    framework = mocker.Mock()
    master = mocker.Mock()
    driver = MesosSchedulerDriver(sched, framework, master)
    resp = mocker.Mock(
        status=200,
        read=mocker.Mock(return_value='{}')
    )
    conn = mocker.Mock(
        getresponse=mocker.Mock(return_value=resp)
    )
    driver._get_conn = mocker.Mock(return_value=conn)
    assert driver._send({}) == {}
    driver._get_conn.assert_called_once_with()
    conn.request.assert_called_once_with(
        'POST', '/api/v1/scheduler',
        body=json.dumps({
        }).encode('utf-8'),
        headers={
            'Content-Type': 'application/json'
        }
    )
开发者ID:windreamer,项目名称:pymesos,代码行数:25,代码来源:test_scheduler.py


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