138 {
139
140 std::string outputConnection = outputConnectionSpec.substr(0, outputConnectionSpec.find('['));
144 if (!this->
cleanUp(outputConnection).isSuccess()) {
146 return(StatusCode::FAILURE);
147 }
148 return(StatusCode::SUCCESS);
149 }
151 ATH_MSG_DEBUG(
"commitOutput SKIPPED for uninitialized server.");
152 return(StatusCode::SUCCESS);
153 }
154 std::map<void*, RootType> commitCache;
157
158 const char* placementStr = nullptr;
161 if (
sc.isSuccess() && placementStr !=
nullptr && strlen(placementStr) > 6 && num > 0) {
162 const char * matchedChars = strstr(placementStr, "[FILE=");
163 if (!matchedChars){
164 ATH_MSG_ERROR(std::format(
"No matching filename in {}", placementStr));
166 }
170 ATH_MSG_ERROR(std::format(
"Failed to connectOutput for {}", fileName));
172 }
174 bool dataHeaderSeen = false;
175 std::string dataHeaderID;
176 while (num > 0) {
177 std::string objName = "ALL";
178 if (useDetailChronoStat()) {
179 objName = placementStr;
180 }
181
182 {
183 PMonUtils::BasicStopWatch stopWatch("cRep_" + objName, this->m_chronoMap);
184 std::string_view pStr = placementStr;
185 std::string::size_type cpos = pStr.find ("[CONT=");
186 if (cpos == std::string::npos) {
187 ATH_MSG_ERROR(std::format(
"No CONT field in placement string: {}", pStr));
188 return StatusCode::FAILURE;
189 }
190 std::string tokenStr (pStr.substr(0, cpos));
191 std::string contName (pStr.substr(cpos, std::string::npos));
192 std::string::size_type cl1 = contName.find(']');
193 if (cl1 == std::string::npos) {
194 ATH_MSG_ERROR(std::format(
"Missing close bracket after CONT field in placement string: {}", pStr));
195 return StatusCode::FAILURE;
196 }
197 tokenStr.append(contName, cl1 + 1);
198 contName = contName.substr(6, cl1 - 6);
199
200 std::string::size_type ppos = pStr.find ("[PNAME=");
201 if (ppos == std::string::npos) {
202 ATH_MSG_ERROR(std::format(
"No PNAME field in placement string: {}", pStr));
203 return StatusCode::FAILURE;
204 }
205 std::string className (pStr.substr(ppos, std::string::npos));
206 std::string::size_type cl2 = className.find(']');
207 if (cl2 == std::string::npos) {
208 ATH_MSG_ERROR(std::format(
"Missing close bracket after PNAME field in placement string: {}", pStr));
209 return StatusCode::FAILURE;
210 }
211 className = className.substr(7, cl2 - 7);
214 const std::string numStr = std::to_string(num);
216 bool foundContainer = false;
217 std::size_t opPos = contName.find('(');
219 foundContainer = true;
220 } else {
222 if (contName.compare(0, opPos, item) == 0){
223 foundContainer = true;
224 len = item.size();
225 break;
226 }
227 }
228 }
229 if (len > 0 && foundContainer && contName[len] == '(' ) {
230 ServiceHandle<IIncidentSvc> incSvc(
"IncidentSvc",
name());
231
236 memName, {}, memName,
237 "BeginInputMemFile", "EndInputMemFile");
238 }
240 }
241
242 ServiceHandle<IAthMetaDataSvc> metadataSvc(
"MetaDataSvc",
name());
244 sc = metadataSvc->shmProxy(std::format(
"{}[NUM={}]", pStr, numStr));
245 if (
sc.isRecoverable()) {
247 }
else if (
sc.isFailure()) {
250 }
251 } else {
252 Token readToken;
253 readToken.
setOid(Token::OID_t(num, 0));
257
258 if( m_oneDataHeaderForm.value() ) {
259 auto placementWithSwn = [&] { return std::format("{}[SWN={}]", placementStr, num); };
260 if( className == "DataHeaderForm_p6" ) {
261
263 "", placementWithSwn());
264 DHcnv->updateRepRefs(&address, static_cast<DataObject*>(obj)).ignore();
265 tokenStr = "";
266 } else {
267 Placement placement;
270 if (token == nullptr) {
273 }
274 tokenStr = token->toString();
275 }
276 if( className == "DataHeader_p6" ) {
277
279 tokenStr, placementWithSwn());
280 if (!DHcnv->updateRep(&address, static_cast<DataObject*>(obj)).isSuccess()) {
283 }
284 } else
285 if (className !=
"Token" && className !=
"DataHeaderForm_p6" && !classDesc.
IsFundamental()) {
286 commitCache.insert(std::pair<void*, RootType>(obj, classDesc));
287 }
288 placementStr = nullptr;
289 } else {
290
291 Placement placement;
292 placement.
fromString(placementStr); placementStr =
nullptr;
294 if (token == nullptr) {
297 }
298 tokenStr = token->toString();
299 if (className == "DataHeader_p6") {
300
303
304 if (!DHcnv->updateRep(&address, static_cast<DataObject*>(obj)).isSuccess()) {
307 }
308 dataHeaderSeen = true;
309
310
311
312
313
314
315 dataHeaderID = std::format("{}/{}/{}", token->contID(), numStr, token->dbID().toString());
316 } else if (dataHeaderSeen) {
317 dataHeaderSeen = false;
318
319
320 if (className == "DataHeaderForm_p6") {
321
323 tokenStr, dataHeaderID);
324 if (!DHcnv->updateRepRefs(&address, static_cast<DataObject*>(obj)).isSuccess()) {
325 ATH_MSG_ERROR(
"Failed updateRepRefs for obj = " << tokenStr);
327 }
328 } else {
329
330 GenericAddress address(0, 0, "", dataHeaderID);
331 if (!DHcnv->updateRepRefs(&address, nullptr).isSuccess()) {
334 }
335 }
336 }
337 if (className !=
"Token" && className !=
"DataHeaderForm_p6" && !classDesc.
IsFundamental()) {
338 commitCache.insert(std::pair<void*, RootType>(obj, classDesc));
339 }
340 }
341 }
342 }
343
345 while (
sc.isRecoverable()) {
347 }
348 if (!
sc.isSuccess()) {
351 }
352 }
354 while (
sc.isRecoverable()) {
356 }
357 if (
sc.isFailure()) {
358
360 }
361 }
362 if (dataHeaderSeen) {
363
364 GenericAddress address(0, 0, "", std::move(dataHeaderID));
365 if (!DHcnv->updateRepRefs(&address, nullptr).isSuccess()) {
368 }
369 }
370 placementStr = nullptr;
371 }
else if (
sc.isSuccess() && placementStr !=
nullptr && strncmp(placementStr,
"stop", 4) == 0) {
372 return(StatusCode::RECOVERABLE);
373 }
else if (
sc.isRecoverable() || num == -1) {
374 return(StatusCode::RECOVERABLE);
375 }
377 ServiceHandle<IIncidentSvc> incSvc(
"IncidentSvc",
name());
379 {
381 memName, {}, memName,
382 "BeginInputMemFile", "EndInputMemFile");
383 }
384 if (
sc.isFailure()) {
385 ATH_MSG_INFO(
"All SharedWriter clients stopped - exiting");
386 } else {
388 }
389 return(StatusCode::FAILURE);
390 }
391 }
393 ATH_MSG_DEBUG(std::format(
"commitOutput SKIPPED for metadata-only server: {}", outputConnectionSpec));
394 return(StatusCode::SUCCESS);
395 }
396 if (outputConnection.empty()) {
397 outputConnection = std::move(fileName);
398 } else {
399 outputConnection = outputConnectionSpec;
402 }
403 }
404 std::size_t
merge = outputConnection.find(
"?pmerge=");
405 const std::string baseOutputConnection = outputConnection.substr(0, merge);
411 doCommit = true;
413 }
415 for (auto& [ptr, rootType] : commitCache) {
417 }
418 return(status);
419}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
bool merge(const StringPool &other)
Merge another pool into this one.
virtual StatusCode commitOutput(const std::string &outputConnectionSpec, bool doCommit) override
Implementation of IConversionSvc: Commit pending output.
std::map< std::string, int > m_fileCommitCounter
Force SharedWriter to flush data to output file at given intervals, needed by parallel compression.
Gaudi::Property< std::string > m_streamPortString
Extension to use ROOT TMemFile for event data, "?pmerge=<host>:<port>".
virtual StatusCode cleanUp(const std::string &connection) override
Implement cleanUp to call all registered IAthenaPoolCleanUp cleanUp() function.
virtual void setObjPtr(void *&obj, const Token *token) override
bool m_streamServerActive
StatusCode abortSharedWrClients(int client_n)
Send abort to SharedWriter clients if the server quits on error.
Gaudi::Property< std::string > m_metadataContainerProp
For SharedWriter: To use MetadataSvc to merge data placed in a certain container.
virtual StatusCode connectOutput(const std::string &outputConnectionSpec, const std::string &openMode) override
Implementation of IConversionSvc: Connect to the output connection specification with open mode.
Gaudi::Property< std::vector< std::string > > m_metadataContainersAug
Gaudi::Property< bool > m_parallelCompression
Use Athena Object sharing for metadata only, event data is collected and send via ROOT TMemFile.
Gaudi::Property< std::map< std::string, int > > m_fileFlushSetting
virtual Token * registerForWrite(Placement *placement, const void *obj, const RootType &classDesc) override
const std::string & auxString() const
Access auxiliary string.
Placement & fromString(const std::string &from)
Build from the string representation of a placement.
static TScopeAdapter ByNameNoQuiet(const std::string &name, Bool_t load=kTRUE)
Bool_t IsFundamental() const
Token & setOid(const OID_t &oid)
Set object identifier.
Token & setAuxString(std::string &&auxString)
Set auxiliary string.
static const DbType POOL_StorageType
char rootType(char typeidType)
This function is used internally in the code when creating primitive dynamic auxiliary branches.
static constexpr CLID ID()