MCPcopy Create free account
hub / github.com/apache/impala / Init

Method Init

be/src/util/os-info.cc:57–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55#endif
56
57void OsInfo::Init() {
58 DCHECK(!initialized_);
59 struct stat info;
60 // Read from /etc/os-release
61 if (stat("/etc/os-release", &info) == 0) {
62 ifstream os_distribution("/etc/os-release", ios::in);
63 string line;
64 while (os_distribution.good() && !os_distribution.eof()) {
65 getline(os_distribution, line);
66 vector<string> fields;
67 split(fields, line, is_any_of("="), token_compress_on);
68 if (fields[0].compare("PRETTY_NAME") == 0) {
69 os_distribution_ = fields[1].data();
70 // remove quotes around os distribution
71 os_distribution_.erase(
72 remove(os_distribution_.begin(), os_distribution_.end(), '\"'),
73 os_distribution_.end());
74 break;
75 }
76 }
77 if (os_distribution.is_open()) os_distribution.close();
78 } else if (stat("/etc/redhat-release", &info) == 0) {
79 // Only old distributions like centos 6, redhat 6
80 ifstream os_distribution("/etc/redhat-release", ios::in);
81 if (os_distribution.good()) getline(os_distribution, os_distribution_);
82 if (os_distribution.is_open()) os_distribution.close();
83 }
84
85 // Read from /proc/version
86 ifstream os_version("/proc/version", ios::in);
87 if (os_version.good()) getline(os_version, os_version_);
88 if (os_version.is_open()) os_version.close();
89
90 // Read the current clocksource to see if CLOCK_MONOTONIC is known to be fast. "tsc" is
91 // fast, while "xen" is slow (40 times slower than "tsc" on EC2). If CLOCK_MONOTONIC is
92 // known to be slow, we use CLOCK_MONOTONIC_COARSE, which uses jiffies, with a
93 // resolution measured in milliseconds, rather than nanoseconds.
94 std::ifstream clocksource_file(
95 "/sys/devices/system/clocksource/clocksource0/current_clocksource");
96 if (clocksource_file.good()) {
97 std::string clocksource;
98 clocksource_file >> clocksource;
99 clock_name_ = "clocksource: '" + clocksource + "', clockid_t: ";
100 if (HAVE_CLOCK_MONOTONIC_COARSE && clocksource != "tsc") {
101 clock_name_ += "CLOCK_MONOTONIC_COARSE";
102 fast_clock_ = CLOCK_MONOTONIC_COARSE;
103 } else {
104 clock_name_ += "CLOCK_MONOTONIC";
105 fast_clock_ = CLOCK_MONOTONIC;
106 }
107 }
108
109 initialized_ = true;
110}
111
112string OsInfo::DebugString() {
113 DCHECK(initialized_);

Callers 14

TESTFunction · 0.45
SetUpMethod · 0.45
CreateBloomFilterMethod · 0.45
TESTFunction · 0.45
SetUpMethod · 0.45
LoadComperatorMethod · 0.45
CreateBloomFilterFunction · 0.45
TESTFunction · 0.45
TEST_FFunction · 0.45
TESTFunction · 0.45
TEST_FFunction · 0.45
CreateCompressorMethod · 0.45

Calls 10

removeFunction · 0.85
eofMethod · 0.80
eraseMethod · 0.80
statClass · 0.70
compareMethod · 0.65
closeMethod · 0.65
dataMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
is_openMethod · 0.45

Tested by 12

TESTFunction · 0.36
SetUpMethod · 0.36
CreateBloomFilterMethod · 0.36
TESTFunction · 0.36
SetUpMethod · 0.36
LoadComperatorMethod · 0.36
CreateBloomFilterFunction · 0.36
TESTFunction · 0.36
TEST_FFunction · 0.36
TESTFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36