MCPcopy Create free account
hub / github.com/apache/mesos / subsystems

Function subsystems

src/linux/cgroups.cpp:122–169  ·  view source on GitHub ↗

Return information about subsystems on the current machine. We get information from /proc/cgroups file. Each line in it describes a subsystem. @return A map from subsystem names to SubsystemInfo instances if succeeds. Error if anything unexpected happens.

Source from the content-addressed store, hash-verified

120// @return A map from subsystem names to SubsystemInfo instances if
121// succeeds. Error if anything unexpected happens.
122static Try<map<string, SubsystemInfo>> subsystems()
123{
124 // TODO(benh): Use os::read to get better error information.
125 ifstream file("/proc/cgroups");
126
127 if (!file.is_open()) {
128 return Error("Failed to open /proc/cgroups");
129 }
130
131 map<string, SubsystemInfo> infos;
132
133 while (!file.eof()) {
134 string line;
135 getline(file, line);
136
137 if (file.fail()) {
138 if (!file.eof()) {
139 return Error("Failed to read /proc/cgroups");
140 }
141 } else {
142 if (line.empty()) {
143 // Skip empty lines.
144 continue;
145 } else if (line.find_first_of('#') == 0) {
146 // Skip the first line which starts with '#' (contains titles).
147 continue;
148 } else {
149 // Parse line to get subsystem info.
150 string name;
151 int hierarchy;
152 int cgroups;
153 bool enabled;
154
155 istringstream ss(line);
156 ss >> dec >> name >> hierarchy >> cgroups >> enabled;
157
158 // Check for any read/parse errors.
159 if (ss.fail() && !ss.eof()) {
160 return Error("Failed to parse /proc/cgroups");
161 }
162
163 infos[name] = SubsystemInfo(name, hierarchy, cgroups, enabled);
164 }
165 }
166 }
167
168 return infos;
169}
170
171
172// Mount a cgroups virtual file system (with proper subsystems

Callers 9

SetUpMethod · 0.85
TEST_FFunction · 0.85
TEST_FFunction · 0.85
createMethod · 0.85
createMethod · 0.85
enabledFunction · 0.85
busyFunction · 0.85
mountedFunction · 0.85
createFunction · 0.85

Calls 10

SubsystemInfoClass · 0.85
readFunction · 0.70
errorMethod · 0.65
ErrorFunction · 0.50
realpathFunction · 0.50
failMethod · 0.45
emptyMethod · 0.45
isErrorMethod · 0.45
isSomeMethod · 0.45
isNoneMethod · 0.45

Tested by 3

SetUpMethod · 0.68
TEST_FFunction · 0.68
TEST_FFunction · 0.68