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

Method checkpointResourceProviderState

src/resource_provider/storage/provider.cpp:2148–2194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2146
2147
2148void StorageLocalResourceProviderProcess::checkpointResourceProviderState()
2149{
2150 ResourceProviderState state;
2151
2152 foreachvalue (const Operation& operation, operations) {
2153 state.add_operations()->CopyFrom(operation);
2154 }
2155
2156 state.mutable_resources()->CopyFrom(totalResources);
2157
2158 ResourceProviderState::Storage* storage = state.mutable_storage();
2159
2160 // NOTE: We only checkpoint profiles associated with any storage
2161 // pool (i.e., resource that has no volume ID) in the total resources.
2162 // We do not need to checkpoint profiles for resources that have
2163 // volume IDs, as their volume capabilities are already checkpointed.
2164 hashset<string> requiredProfiles;
2165 foreach (const Resource& resource, totalResources) {
2166 if (!resource.disk().source().has_id()) {
2167 CHECK(resource.disk().source().has_profile());
2168 requiredProfiles.insert(resource.disk().source().profile());
2169 }
2170 }
2171
2172 foreach (const string& profile, requiredProfiles) {
2173 CHECK(profileInfos.contains(profile));
2174
2175 const DiskProfileAdaptor::ProfileInfo& profileInfo =
2176 profileInfos.at(profile);
2177
2178 ResourceProviderState::Storage::ProfileInfo& profileInfo_ =
2179 (*storage->mutable_profiles())[profile];
2180
2181 *profileInfo_.mutable_capability() = profileInfo.capability;
2182 *profileInfo_.mutable_parameters() = profileInfo.parameters;
2183 }
2184
2185 const string statePath = slave::paths::getResourceProviderStatePath(
2186 metaDir, slaveId, info.type(), info.name(), info.id());
2187
2188 // NOTE: We ensure the checkpoint is synced to the filesystem to avoid
2189 // resulting in a stale or empty checkpoint when a system crash happens.
2190 Try<Nothing> checkpoint = slave::state::checkpoint(statePath, state, true);
2191 CHECK_SOME(checkpoint)
2192 << "Failed to checkpoint resource provider state to '" << statePath << "': "
2193 << checkpoint.error();
2194}
2195
2196
2197void StorageLocalResourceProviderProcess::sendResourceProviderStateUpdate()

Callers

nothing calls this directly

Calls 7

checkpointFunction · 0.85
CopyFromMethod · 0.80
typeMethod · 0.80
errorMethod · 0.65
nameMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected