| 741 | Status MesosExecutorDriver::start() |
| 742 | { |
| 743 | synchronized (mutex) { |
| 744 | if (status != DRIVER_NOT_STARTED) { |
| 745 | return status; |
| 746 | } |
| 747 | |
| 748 | // Set stream buffering mode to flush on newlines so that we |
| 749 | // capture logs from user processes even when output is redirected |
| 750 | // to a file. On POSIX, the buffer size is determined by the system |
| 751 | // when the `buf` parameter is null. On Windows we have to specify |
| 752 | // the size, so we use 1024 bytes, a number that is arbitrary, but |
| 753 | // large enough to not affect performance. |
| 754 | const size_t bufferSize = |
| 755 | #ifdef __WINDOWS__ |
| 756 | 1024; |
| 757 | #else // __WINDOWS__ |
| 758 | 0; |
| 759 | #endif // __WINDOWS__ |
| 760 | setvbuf(stdout, nullptr, _IOLBF, bufferSize); |
| 761 | setvbuf(stderr, nullptr, _IOLBF, bufferSize); |
| 762 | |
| 763 | bool local; |
| 764 | |
| 765 | UPID slave; |
| 766 | SlaveID slaveId; |
| 767 | FrameworkID frameworkId; |
| 768 | ExecutorID executorId; |
| 769 | string workDirectory; |
| 770 | bool checkpoint; |
| 771 | |
| 772 | Option<string> value; |
| 773 | std::istringstream iss; |
| 774 | hashmap<string, string> env(environment); |
| 775 | |
| 776 | // Check if this is local (for example, for testing). |
| 777 | local = env.contains("MESOS_LOCAL"); |
| 778 | |
| 779 | // Get slave PID from environment. |
| 780 | value = env.get("MESOS_SLAVE_PID"); |
| 781 | if (value.isNone()) { |
| 782 | EXIT(EXIT_FAILURE) |
| 783 | << "Expecting 'MESOS_SLAVE_PID' to be set in the environment"; |
| 784 | } |
| 785 | |
| 786 | slave = UPID(value.get()); |
| 787 | CHECK(slave) << "Cannot parse MESOS_SLAVE_PID '" << value.get() << "'"; |
| 788 | |
| 789 | // Get slave ID from environment. |
| 790 | value = env.get("MESOS_SLAVE_ID"); |
| 791 | if (value.isNone()) { |
| 792 | EXIT(EXIT_FAILURE) |
| 793 | << "Expecting 'MESOS_SLAVE_ID' to be set in the environment"; |
| 794 | } |
| 795 | slaveId.set_value(value.get()); |
| 796 | |
| 797 | // Get framework ID from environment. |
| 798 | value = env.get("MESOS_FRAMEWORK_ID"); |
| 799 | if (value.isNone()) { |
| 800 | EXIT(EXIT_FAILURE) |