| 143 | namespace cluster { |
| 144 | |
| 145 | Try<process::Owned<Master>> Master::start( |
| 146 | const master::Flags& flags, |
| 147 | const Option<zookeeper::URL>& zookeeperUrl, |
| 148 | const Option<mesos::allocator::Allocator*>& allocator, |
| 149 | const Option<Authorizer*>& authorizer, |
| 150 | const Option<std::shared_ptr<process::RateLimiter>>& slaveRemovalLimiter) |
| 151 | { |
| 152 | process::Owned<Master> master(new Master()); |
| 153 | master->zookeeperUrl = zookeeperUrl; |
| 154 | |
| 155 | // If the allocator is not provided, create a default one. |
| 156 | if (allocator.isNone()) { |
| 157 | Try<mesos::allocator::Allocator*> _allocator = |
| 158 | master::allocator::HierarchicalDRFAllocator::create(); |
| 159 | |
| 160 | if (_allocator.isError()) { |
| 161 | return Error( |
| 162 | "Failed to create an instance of HierarchicalDRFAllocator: " + |
| 163 | _allocator.error()); |
| 164 | } |
| 165 | |
| 166 | master->allocator.reset(_allocator.get()); |
| 167 | } |
| 168 | |
| 169 | // If the authorizer is not provided, create a default one. |
| 170 | if (authorizer.isNone()) { |
| 171 | // Indicates whether or not the caller explicitly specified the |
| 172 | // authorization configuration for this master. |
| 173 | bool authorizationSpecified = true; |
| 174 | |
| 175 | vector<string> authorizerNames = strings::split(flags.authorizers, ","); |
| 176 | |
| 177 | if (authorizerNames.empty()) { |
| 178 | return Error("No authorizer specified"); |
| 179 | } |
| 180 | |
| 181 | if (authorizerNames.size() > 1) { |
| 182 | return Error("Multiple authorizers not supported"); |
| 183 | } |
| 184 | |
| 185 | string authorizerName = authorizerNames[0]; |
| 186 | |
| 187 | Result<Authorizer*> authorizer((None())); |
| 188 | if (authorizerName != master::DEFAULT_AUTHORIZER) { |
| 189 | LOG(INFO) << "Creating '" << authorizerName << "' authorizer"; |
| 190 | |
| 191 | authorizer = Authorizer::create(authorizerName); |
| 192 | } else { |
| 193 | // `authorizerName` is `DEFAULT_AUTHORIZER` at this point. |
| 194 | if (flags.acls.isSome()) { |
| 195 | LOG(INFO) << "Creating default '" << authorizerName << "' authorizer"; |
| 196 | |
| 197 | authorizer = Authorizer::create(flags.acls.get()); |
| 198 | CHECK_SOME(authorizer); |
| 199 | } else { |
| 200 | authorizationSpecified = false; |
| 201 | } |
| 202 | } |
nothing calls this directly
no test coverage detected