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

Method usage

src/slave/containerizer/mesos/isolators/network/port_mapping.cpp:3128–3254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3126
3127
3128Future<ResourceStatistics> PortMappingIsolatorProcess::usage(
3129 const ContainerID& containerId)
3130{
3131 ResourceStatistics result;
3132
3133 // Do nothing for unmanaged container.
3134 if (unmanaged.contains(containerId)) {
3135 return result;
3136 }
3137
3138 if (!infos.contains(containerId)) {
3139 VLOG(1) << "Unknown container " << containerId;
3140 return result;
3141 }
3142
3143 Info* info = CHECK_NOTNULL(infos[containerId]);
3144
3145 if (info->pid.isNone()) {
3146 return result;
3147 }
3148
3149 Result<hashmap<string, uint64_t>> stat =
3150 link::statistics(veth(info->pid.get()));
3151
3152 if (stat.isError()) {
3153 return Failure(
3154 "Failed to retrieve statistics on link " +
3155 veth(info->pid.get()) + ": " + stat.error());
3156 } else if (stat.isNone()) {
3157 return Failure("Failed to find link: " + veth(info->pid.get()));
3158 }
3159
3160 // Note: The RX/TX statistics on the two ends of the veth are the
3161 // exact opposite, because of its 'tunnel' nature. We sample on the
3162 // host end of the veth pair, which means we have to reverse RX and
3163 // TX to reflect statistics inside the container.
3164
3165 // +----------+ +----------+
3166 // | | | |
3167 // | |RX<--------------+TX| |
3168 // | | | |
3169 // | veth | | eth0 |
3170 // | | | |
3171 // | |TX+-------------->RX| |
3172 // | | | |
3173 // +----------+ +----------+
3174
3175 Option<uint64_t> rx_packets = stat->get("tx_packets");
3176 if (rx_packets.isSome()) {
3177 result.set_net_rx_packets(rx_packets.get());
3178 }
3179
3180 Option<uint64_t> rx_bytes = stat->get("tx_bytes");
3181 if (rx_bytes.isSome()) {
3182 result.set_net_rx_bytes(rx_bytes.get());
3183 }
3184
3185 Option<uint64_t> rx_errors = stat->get("tx_errors");

Callers 1

executeMethod · 0.45

Calls 14

vethFunction · 0.85
FailureClass · 0.85
deferFunction · 0.85
errorMethod · 0.65
statisticsFunction · 0.50
subprocessFunction · 0.50
joinFunction · 0.50
containsMethod · 0.45
isNoneMethod · 0.45
getMethod · 0.45
isErrorMethod · 0.45
isSomeMethod · 0.45

Tested by

no test coverage detected