137 {
138
139 std::string outputConnection = outputConnectionSpec.substr(0, outputConnectionSpec.find('['));
143 if (!this->
cleanUp(outputConnection).isSuccess()) {
145 return(StatusCode::FAILURE);
146 }
147 return(StatusCode::SUCCESS);
148 }
150 ATH_MSG_DEBUG(
"commitOutput SKIPPED for uninitialized server.");
151 return(StatusCode::SUCCESS);
152 }
153 std::map<void*, RootType> commitCache;
156
157 const char* placementStr = nullptr;
160 if (
sc.isSuccess() && placementStr !=
nullptr && strlen(placementStr) > 6 && num > 0) {
161 const char * matchedChars = strstr(placementStr, "[FILE=");
162 if (!matchedChars){
163 ATH_MSG_ERROR(std::format(
"No matching filename in {}", placementStr));
165 }
169 ATH_MSG_ERROR(std::format(
"Failed to connectOutput for {}", fileName));
171 }
173 bool dataHeaderSeen = false;
174 std::string dataHeaderID;
175 while (num > 0) {
176 std::string objName = "ALL";
177 if (useDetailChronoStat()) {
178 objName = placementStr;
179 }
180
181 {
182 PMonUtils::BasicStopWatch stopWatch("cRep_" + objName, this->m_chronoMap);
183 std::string_view pStr = placementStr;
184 std::string::size_type cpos = pStr.find ("[CONT=");
185 if (cpos == std::string::npos) {
186 ATH_MSG_ERROR(std::format(
"No CONT field in placement string: {}", pStr));
187 return StatusCode::FAILURE;
188 }
189 std::string tokenStr (pStr.substr(0, cpos));
190 std::string contName (pStr.substr(cpos, std::string::npos));
191 std::string::size_type cl1 = contName.find(']');
192 if (cl1 == std::string::npos) {
193 ATH_MSG_ERROR(std::format(
"Missing close bracket after CONT field in placement string: {}", pStr));
194 return StatusCode::FAILURE;
195 }
196 tokenStr.append(contName, cl1 + 1);
197 contName = contName.substr(6, cl1 - 6);
198
199 std::string::size_type ppos = pStr.find ("[PNAME=");
200 if (ppos == std::string::npos) {
201 ATH_MSG_ERROR(std::format(
"No PNAME field in placement string: {}", pStr));
202 return StatusCode::FAILURE;
203 }
204 std::string className (pStr.substr(ppos, std::string::npos));
205 std::string::size_type cl2 = className.find(']');
206 if (cl2 == std::string::npos) {
207 ATH_MSG_ERROR(std::format(
"Missing close bracket after PNAME field in placement string: {}", pStr));
208 return StatusCode::FAILURE;
209 }
210 className = className.substr(7, cl2 - 7);
213 const std::string numStr = std::to_string(num);
215 bool foundContainer = false;
216 std::size_t opPos = contName.find('(');
218 foundContainer = true;
219 } else {
221 if (contName.compare(0, opPos, item) == 0){
222 foundContainer = true;
223 len = item.size();
224 break;
225 }
226 }
227 }
228 if (len > 0 && foundContainer && contName[len] == '(' ) {
229 ServiceHandle<IIncidentSvc> incSvc(
"IncidentSvc",
name());
230
235 memName, {}, memName,
236 "BeginInputMemFile", "EndInputMemFile");
237 }
239 }
240
241 ServiceHandle<IAthMetaDataSvc> metadataSvc(
"MetaDataSvc",
name());
243 sc = metadataSvc->shmProxy(std::format(
"{}[NUM={}]", pStr, numStr));
244 if (
sc.isRecoverable()) {
246 }
else if (
sc.isFailure()) {
249 }
250 } else {
251 Token readToken;
252 readToken.
setOid(Token::OID_t(num, 0));
256
257 if( m_oneDataHeaderForm.value() ) {
258 auto placementWithSwn = [&] { return std::format("{}[SWN={}]", placementStr, num); };
259 if( className == "DataHeaderForm_p6" ) {
260
262 "", placementWithSwn());
263 DHcnv->updateRepRefs(&address, static_cast<DataObject*>(obj)).ignore();
264 tokenStr = "";
265 } else {
266 Placement placement;
269 if (token == nullptr) {
272 }
273 tokenStr = token->toString();
274 }
275 if( className == "DataHeader_p6" ) {
276
278 tokenStr, placementWithSwn());
279 if (!DHcnv->updateRep(&address, static_cast<DataObject*>(obj)).isSuccess()) {
282 }
283 } else
284 if (className !=
"Token" && className !=
"DataHeaderForm_p6" && !classDesc.
IsFundamental()) {
285 commitCache.insert(std::pair<void*, RootType>(obj, classDesc));
286 }
287 placementStr = nullptr;
288 } else {
289
290 Placement placement;
291 placement.
fromString(placementStr); placementStr =
nullptr;
293 if (token == nullptr) {
296 }
297 tokenStr = token->toString();
298 if (className == "DataHeader_p6") {
299
302
303 if (!DHcnv->updateRep(&address, static_cast<DataObject*>(obj)).isSuccess()) {
306 }
307 dataHeaderSeen = true;
308
309
310
311
312
313
314 dataHeaderID = std::format("{}/{}/{}", token->contID(), numStr, token->dbID().toString());
315 } else if (dataHeaderSeen) {
316 dataHeaderSeen = false;
317
318
319 if (className == "DataHeaderForm_p6") {
320
322 tokenStr, dataHeaderID);
323 if (!DHcnv->updateRepRefs(&address, static_cast<DataObject*>(obj)).isSuccess()) {
324 ATH_MSG_ERROR(
"Failed updateRepRefs for obj = " << tokenStr);
326 }
327 } else {
328
329 GenericAddress address(0, 0, "", dataHeaderID);
330 if (!DHcnv->updateRepRefs(&address, nullptr).isSuccess()) {
333 }
334 }
335 }
336 if (className !=
"Token" && className !=
"DataHeaderForm_p6" && !classDesc.
IsFundamental()) {
337 commitCache.insert(std::pair<void*, RootType>(obj, classDesc));
338 }
339 }
340 }
341 }
342
344 while (
sc.isRecoverable()) {
346 }
347 if (!
sc.isSuccess()) {
350 }
351 }
353 while (
sc.isRecoverable()) {
355 }
356 if (
sc.isFailure()) {
357
359 }
360 }
361 if (dataHeaderSeen) {
362
363 GenericAddress address(0, 0, "", std::move(dataHeaderID));
364 if (!DHcnv->updateRepRefs(&address, nullptr).isSuccess()) {
367 }
368 }
369 placementStr = nullptr;
370 }
else if (
sc.isSuccess() && placementStr !=
nullptr && strncmp(placementStr,
"stop", 4) == 0) {
371 return(StatusCode::RECOVERABLE);
372 }
else if (
sc.isRecoverable() || num == -1) {
373 return(StatusCode::RECOVERABLE);
374 }
376 ServiceHandle<IIncidentSvc> incSvc(
"IncidentSvc",
name());
378 {
380 memName, {}, memName,
381 "BeginInputMemFile", "EndInputMemFile");
382 }
383 if (
sc.isFailure()) {
384 ATH_MSG_INFO(
"All SharedWriter clients stopped - exiting");
385 } else {
387 }
388 return(StatusCode::FAILURE);
389 }
390 }
392 ATH_MSG_DEBUG(std::format(
"commitOutput SKIPPED for metadata-only server: {}", outputConnectionSpec));
393 return(StatusCode::SUCCESS);
394 }
395 if (outputConnection.empty()) {
396 outputConnection = std::move(fileName);
397 } else {
398 outputConnection = outputConnectionSpec;
401 }
402 }
403 std::size_t
merge = outputConnection.find(
"?pmerge=");
404 const std::string baseOutputConnection = outputConnection.substr(0, merge);
410 doCommit = true;
412 }
414 for (auto& [ptr, rootType] : commitCache) {
416 }
417 return(status);
418}
#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()