mesos 1.2.0实验性的支持了一个框架多个role.
message FrameworkInfo {
...
// Roles are the entities to which allocations are made.
// The framework must have at least one role in order to
// be offered resources. Note that `role` is deprecated
// in favor of `roles` and only one of these fields must
// be used. Since we cannot distinguish between empty
// `roles` and the default unset `role`, we require that
// frameworks set the `MULTI_ROLE` capability if
// setting the `roles` field.
//
// NOTE: The implmentation for supporting `roles`
// is not complete, DO NOT USE the `roles` field.
optional string role = 6 [default = "*", deprecated=true];
repeated string roles = 12; // EXPERIMENTAL.
...
message Capability {
enum Type {
...
// This expresses the ability for the framework to be
// "multi-tenant" via using the newly introduced `roles`
// field, and examining `Offer.allocation_info` to determine
// which role the offers are being made to. We also
// expect that "single-tenant" schedulers eventually
// provide this and move away from the deprecated
// `role` field.
//
// NOTE: The implementation for supporting multiple
// roles is not complete, DO NOT USE THIS.
MULTI_ROLE = 6; // EXPERIMENTAL.
}
optional Type type = 1;
}
}
Roles是进行分配的实体。框架必须至少有一个role才能提供资源。 请注意,如果使用了“role”就不赞成使用“roles”,只能使用其中一个字段。
由于我们无法区分空的“roles”和默认的未设置的“role”,所以如果设置“roles”字段,我们要求框架设置“MULTI_ROLE”功能。
MULTI_ROLE表示框架通过使用新引入的“roles”字段“多租户”的能力,并检查“Offer.allocation_info”以确定提供的role。 我们也期望“单租户”调度人员最终提供这种安排,并远离已弃用的“role”字段。
注册试验:
生成FrameworkInfo:
framework = mesos_pb2.FrameworkInfo()
framework.user = 'root'
framework.name = 'mhc'
framework.checkpoint = True
framework.roles.append("mhc1")
framework.roles.append("mhc2")
capability = framework.capabilities.add()
capability.type = 6
通过mesos /frameworks 查看框架信息
{
"id": "9270833d-e7f7-4e74-a396-6f70a63676f0-0002",
"name": "mhc",
"pid": "scheduler-11316f0f-8fa3-4af9-b0a3-46587a68bc31@192.168.111.120:34883",
"used_resources": {
"disk": 0.0,
"mem": 0.0,
"gpus": 0.0,
"cpus": 0.0
},
"offered_resources": {
"disk": 455.0,
"mem": 911.0,
"gpus": 0.0,
"cpus": 1.0,
"ports": "[31000-32000]"
},
"capabilities": [
"MULTI_ROLE"
],
"hostname": "webtest",
"webui_url": "",
"active": true,
"connected": true,
"recovered": false,
"user": "root",
"failover_timeout": 0.0,
"checkpoint": true,
"registered_time": 1492104533.63482,
"unregistered_time": 0.0,
"resources": {
"disk": 455.0,
"mem": 911.0,
"gpus": 0.0,
"cpus": 1.0,
"ports": "[31000-32000]"
},
"roles": [
"mhc1",
"mhc2"
],
"tasks": [],
"unreachable_tasks": [],
"completed_tasks": [],
"offers": [
{
"id": "9270833d-e7f7-4e74-a396-6f70a63676f0-O6",
"framework_id": "9270833d-e7f7-4e74-a396-6f70a63676f0-0002",
"slave_id": "9270833d-e7f7-4e74-a396-6f70a63676f0-S0",
"resources": {
"disk": 455.0,
"mem": 911.0,
"gpus": 0.0,
"cpus": 1.0,
"ports": "[31000-32000]"
}
}
],
"executors": []
}