14#include "arcane/std/internal/BasicReader.h"
15#include "arcane/std/internal/BasicWriter.h"
17#include "arcane/utils/StringBuilder.h"
18#include "arcane/utils/OStringStream.h"
19#include "arcane/utils/PlatformUtils.h"
21#include "arcane/core/IXmlDocumentHolder.h"
22#include "arcane/core/IParallelMng.h"
23#include "arcane/core/CheckpointService.h"
24#include "arcane/core/Directory.h"
25#include "arcane/core/IParallelReplication.h"
26#include "arcane/core/IVariableUtilities.h"
27#include "arcane/core/VerifierService.h"
28#include "arcane/core/IVariableMng.h"
29#include "arcane/core/CheckpointInfo.h"
31#include "arcane/std/ArcaneBasicCheckpoint_axl.h"
38using namespace Arcane::impl;
46class ArcaneBasicCheckpointService
58 XmlNode root = xml_doc->documentNode().documentElement();
63 md.m_version = version;
96 info() <<
"USE DEFAULT FILE NAME index=" << currentIndex();
104 info() <<
"FILE_NAME is " << buf;
107 Directory _defaultDirectory()
122class ArcaneBasic2CheckpointService
123:
public ArcaneBasicCheckpointService
128 : ArcaneBasicCheckpointService(sbi)
143 <<
" version=" << md.m_version
147 if (filename.
null()) {
149 filename = dump_dir.
file(_defaultFileName());
152 filename = filename +
"_n" + currentIndex();
153 info() <<
" READ CHECKPOINT FILENAME = " << filename;
156 bool want_parallel =
false;
157 m_reader =
new BasicReader(app, pm, A_NULL_RANK, filename, want_parallel);
158 m_reader->initialize();
177 auto open_mode = BasicReaderWriterCommon::OpenModeAppend;
180 if (write_index == 0)
181 open_mode = BasicReaderWriterCommon::OpenModeTruncate;
184 if (filename.
null()) {
186 filename = dump_dir.
file(_defaultFileName());
189 filename = filename +
"_n" + write_index;
194 version =
options()->formatVersion();
198 data_compressor =
options()->dataCompressor.instanceRef();
202 info() <<
"Writing checkpoint with 'ArcaneBasicCheckpointService'"
203 <<
" version=" << version
204 <<
" filename='" << filename <<
"'\n";
211 want_parallel =
false;
212 m_writer =
new BasicWriter(app, pm, filename, open_mode, version, want_parallel);
213 m_writer->setDataCompressor(data_compressor);
214 m_writer->initialize();
225 const int meta_data_version = 1;
226 ostr() <<
" version='" << meta_data_version <<
"'";
240class ArcaneBasic2CheckpointReaderService
265 Integer index = ci.checkpointIndex();
266 bool has_replication = ci.nbReplication() > 1;
267 Int32 replication_rank = ci.replicationRank();
268 info() <<
"USE DEFAULT FILE NAME index=" << index;
270 String buf =
"arcanedump";
271 if (has_replication) {
273 buf = buf + replication_rank;
275 info() <<
"FILE_NAME is " << buf;
287 String reader_meta_data_str = ci.readerMetaData();
288 auto md = ArcaneBasicCheckpointService::MetaData::parse(reader_meta_data_str,
traceMng());
290 info() <<
"Basic2CheckpointReader GET META DATA READER " << reader_meta_data_str
291 <<
" version=" << md.m_version;
294 String filename = dump_dir.
file(_defaultFileName(ci));
295 filename = filename +
"_n" + ci.checkpointIndex();
297 info() <<
" READ CHECKPOINT FILENAME = " << filename;
299 bool want_parallel =
false;
300 m_reader =
new BasicReader(m_application, pm, ci.subDomainRank(), filename, want_parallel);
301 m_reader->initialize();
#define ARCANE_THROW(exception_class,...)
Macro for throwing an exception with formatting.
#define ARCANE_SERVICE_INTERFACE(ainterface)
Macro to declare an interface when registering a service.
AbstractService(const ServiceBuildInfo &)
Constructor from a ServiceBuildInfo.
ArcaneArcaneBasicCheckpointObject(const Arcane::ServiceBuildInfo &sbi)
Constructeur.
CaseOptionsArcaneBasicCheckpoint * options() const
Options du jeu de données du service.
Protection reading (version 2).
void notifyBeginRead(const CheckpointReadInfo &cri) override
Notifies that a protection will be read with information from checkpoint_info.
void notifyEndRead() override
Notifies the end of reading a protection.
IDataReader2 * dataReader() override
Returns the data reader associated with this protection reader.
Basic protection/recovery (version 2).
String readerServiceName() const override
Name of the reader service associated with this writer.
Basic protection/recovery (version 1).
String readerServiceName() const override
Name of the reader service associated with this writer.
void notifyEndRead() override
Notifies that a protection has just been read.
void notifyBeginRead() override
Notifies that a protection will be read with current parameters.
void notifyBeginWrite() override
Notifies that a checkpoint is going to be written with the current parameters.
IDataReader * dataReader() override
Returns the associated reader.
void notifyEndWrite() override
Notifies that a checkpoint has just been written.
IDataWriter * dataWriter() override
Returns the associated writer.
void close() override
Closes the checkpoints.
Information about a checkpoint.
Checkpoint reading information.
String readerMetaData() const override
Metadata for the reader associated with this writer.
String baseDirectoryName() const override
Name of the checkpoint base directory.
void setReaderMetaData(const String &s) override
Metadata associated with this reader.
void setFileName(const String &file_name) override
Sets the name of the checkpoint file.
RealConstArrayView checkpointTimes() const override
Checkpoint times.
String fileName() const override
Name of the checkpoint file.
constexpr Integer size() const noexcept
Number of elements in the array.
Class managing a directory.
String file(const String &file_name) const override
Returns the full path of the file file_name in the directory.
Interface for the protection/recovery reading service (V2).
Interface for the protection/recovery reading service.
Interface of the checkpoint/recovery write service.
Interface for reading data of a variable (Version 2).
Interface for reading variable data.
Interface for writing variable data.
Interface of the parallelism manager for a subdomain.
virtual IParallelReplication * replication() const =0
Replication information.
virtual bool isParallel() const =0
Returns true if the execution is parallel.
Brief information on parallel subdomain replication.
virtual bool hasReplication() const =0
Indicates if replication is active.
virtual Int32 replicationRank() const =0
Rank in the replication (from 0 to nbReplication()-1).
virtual IParallelMng * parallelMng()=0
Returns the parallelism manager.
static IXmlDocumentHolder * loadFromBuffer(Span< const Byte > buffer, const String &name, ITraceMng *tm)
Loads an XML document.
Output stream linked to a String.
Exception in a reader or writer.
Reference to an instance.
Encapsulation of an automatically destructing pointer.
IApplication * application() const
Access to the associated IApplication.
Structure containing the information to create a service.
Service creation properties.
Unicode character string.
bool null() const
Returns true if the string is null.
Span< const Byte > bytes() const
Returns the conversion of the instance into UTF-8 encoding.
TraceMessage info() const
Flow for an information message.
ITraceMng * traceMng() const
Trace manager.
XmlNode attr(const String &name, bool throw_exception=false) const
Returns the attribute of name name.
Integer valueAsInteger(bool throw_exception=false) const
Node value converted to integer.
#define ARCANE_REGISTER_SERVICE(aclass, a_service_property,...)
Macro for registering a service.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
@ ST_Application
The service is used at the application level.
@ ST_CaseOption
The service is used at the dataset level.
@ ST_SubDomain
The service is used at the subdomain level.
std::int32_t Int32
Signed integer type of 32 bits.