| 160 | { |
| 161 | public: |
| 162 | MesosProcess( |
| 163 | ContentType _contentType, |
| 164 | const lambda::function<void(void)>& connected, |
| 165 | const lambda::function<void(void)>& disconnected, |
| 166 | const lambda::function<void(const queue<Event>&)>& received, |
| 167 | const std::map<std::string, std::string>& environment) |
| 168 | : ProcessBase(generate("executor")), |
| 169 | state(DISCONNECTED), |
| 170 | contentType(_contentType), |
| 171 | callbacks {connected, disconnected, received} |
| 172 | { |
| 173 | GOOGLE_PROTOBUF_VERIFY_VERSION; |
| 174 | |
| 175 | // Load any logging flags from the environment. |
| 176 | logging::Flags flags; |
| 177 | |
| 178 | // Filter out environment variables whose keys don't start with "MESOS_". |
| 179 | // |
| 180 | // TODO(alexr): This should be supported by `FlagsBase`, see MESOS-9001. |
| 181 | std::map<std::string, std::string> mesosEnvironment; |
| 182 | |
| 183 | foreachpair (const string& key, const string& value, environment) { |
| 184 | if (strings::startsWith(key, "MESOS_")) { |
| 185 | mesosEnvironment.emplace(key, value); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | Try<flags::Warnings> load = flags.load(mesosEnvironment, true); |
| 190 | |
| 191 | if (load.isError()) { |
| 192 | EXIT(EXIT_FAILURE) << "Failed to load flags: " << load.error(); |
| 193 | } |
| 194 | |
| 195 | // Initialize libprocess. |
| 196 | process::initialize(); |
| 197 | |
| 198 | // Initialize logging. |
| 199 | if (flags.initialize_driver_logging) { |
| 200 | logging::initialize("mesos", false, flags); |
| 201 | } else { |
| 202 | VLOG(1) << "Disabling initialization of GLOG logging"; |
| 203 | } |
| 204 | |
| 205 | // Log any flag warnings (after logging is initialized). |
| 206 | foreach (const flags::Warning& warning, load->warnings) { |
| 207 | LOG(WARNING) << warning.message; |
| 208 | } |
| 209 | |
| 210 | LOG(INFO) << "Version: " << MESOS_VERSION; |
| 211 | |
| 212 | spawn(new VersionProcess(), true); |
| 213 | |
| 214 | hashmap<string, string> env(mesosEnvironment); |
| 215 | |
| 216 | // Check if this is local (for example, for testing). |
| 217 | local = env.contains("MESOS_LOCAL"); |
| 218 | |
| 219 | Option<string> value; |
nothing calls this directly
no test coverage detected