evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RecordRingItem.h
Go to the documentation of this file.
1 //
2 // Copyright 2020, Jefferson Science Associates, LLC.
3 // Subject to the terms in the LICENSE file found in the top-level directory.
4 //
5 // EPSCI Group
6 // Thomas Jefferson National Accelerator Facility
7 // 12000, Jefferson Ave, Newport News, VA 23606
8 // (757)-269-7100
9 
10 
11 #ifndef EVIO_6_0_RECORDRINGITEM_H
12 #define EVIO_6_0_RECORDRINGITEM_H
13 
14 
15 #include <memory>
16 #include <atomic>
17 #include <functional>
18 
19 
20 #include "Disruptor/Sequence.h"
21 #include "RecordOutput.h"
22 #include "ByteOrder.h"
23 #include "Compressor.h"
24 
25 
26 namespace evio {
27 
35 
36  private:
37 
38  // These static members are NOT THREAD SAFE! Fortunately, the chances that an
39  // application uses more than one RecordSupply is remote. The chances that
40  // their construction occurs at the same time is even more remote.
41 
43  static ByteOrder factoryByteOrder;
45  static int factoryMaxEventCount;
47  static int factoryMaxBufferSize;
49  static Compressor::CompressionType factoryCompressionType;
50 
52  static uint64_t idValue;
53 
54 
56  std::shared_ptr<RecordOutput> record;
57 
60 
62  int64_t sequence = 0UL;
63 
65  std::shared_ptr<Disruptor::ISequence> sequenceObj = nullptr;
66 
68  std::atomic<bool> splitFileAfterWriteBool{false};
69 
71  std::atomic<bool> forceToDiskBool{false};
72 
77  std::atomic<bool> checkDisk{false};
78 
81  std::atomic<bool> lastItem{false};
82 
84  bool alreadyReleased = false;
85 
87  uint64_t id = 0;
88 
89 
90  public:
91 
92 
93  static const std::function< std::shared_ptr<RecordRingItem> () >& eventFactory();
94 
95  static void setEventFactorySettings(ByteOrder & order, uint32_t maxEventCount, uint32_t maxBufferSize,
96  Compressor::CompressionType & compressionType);
97 
98 
100  RecordRingItem(const RecordRingItem & item);
101  ~RecordRingItem() = default;
102 
103  RecordRingItem & operator=(const RecordRingItem & other) = delete;
104 
105  void reset();
106 
107  std::shared_ptr<RecordOutput> & getRecord();
108  ByteOrder & getOrder();
109  int64_t getSequence() const;
110  std::shared_ptr<Disruptor::ISequence> & getSequenceObj();
111 
112  void fromProducer(int64_t seq);
113  void fromConsumer(int64_t seq, std::shared_ptr<Disruptor::ISequence> & seqObj);
114 
115  bool splitFileAfterWrite();
116  void splitFileAfterWrite(bool split);
117 
118  bool forceToDisk();
119  void forceToDisk(bool force);
120 
121  bool isCheckDisk();
122  void setCheckDisk(bool check);
123 
124  bool isLastItem();
125  void setLastItem(bool last);
126 
127  bool isAlreadyReleased() const;
128  void setAlreadyReleased(bool released);
129 
130  uint64_t getId() const;
131  void setId(uint64_t idVal);
132 
133  };
134 
135 }
136 
137 
138 #endif //EVIO_6_0_RECORDRINGITEM_H
void setLastItem(bool last)
Set whether this is the last item in the supply to be used.
Definition: RecordRingItem.cpp:250
CompressionType
Enum of supported data compression types.
Definition: Compressor.h:65
std::shared_ptr< RecordOutput > & getRecord()
Get the contained record.
Definition: RecordRingItem.cpp:148
Numerical values associated with endian byte order.
Definition: ByteOrder.h:53
void reset()
Assignment operator.
Definition: RecordRingItem.cpp:131
static const std::function< std::shared_ptr< RecordRingItem >) > & eventFactory()
Function to create RecordRingItems by RingBuffer.
Definition: RecordRingItem.cpp:32
std::shared_ptr< Disruptor::ISequence > & getSequenceObj()
Get the Sequence object allowing ring consumer to get/release this item.
Definition: RecordRingItem.cpp:169
void fromConsumer(int64_t seq, std::shared_ptr< Disruptor::ISequence > &seqObj)
Set the sequence of an item obtained through RecordSupply#getToCompress(uint32_t).
Definition: RecordRingItem.cpp:184
uint64_t getId() const
Get item&#39;s id.
Definition: RecordRingItem.cpp:272
bool forceToDisk()
Get whether a file writer forces this record to be physically written to disk.
Definition: RecordRingItem.cpp:209
bool isLastItem()
Get whether this is the last item in the supply to be used.
Definition: RecordRingItem.cpp:242
bool splitFileAfterWrite()
Get whether a file writer splits the file after writing this record.
Definition: RecordRingItem.cpp:194
void setId(uint64_t idVal)
Set this item&#39;s id number.
Definition: RecordRingItem.cpp:279
This class provides the items which are supplied by the RecordSupply class.
Definition: RecordRingItem.h:34
ByteOrder & getOrder()
Get the byte order used to build record.
Definition: RecordRingItem.cpp:155
~RecordRingItem()=default
RecordRingItem & operator=(const RecordRingItem &other)=delete
bool isCheckDisk()
Get whether there is not enough free space on the disk partition for the next, complete file to be wr...
Definition: RecordRingItem.cpp:226
bool isAlreadyReleased() const
Has this item already been released by the RecordSupply?
Definition: RecordRingItem.cpp:257
void setCheckDisk(bool check)
Set whether there is not enough free space on the disk partition for the next, complete file to be wr...
Definition: RecordRingItem.cpp:235
void setAlreadyReleased(bool released)
Set whether this item has already been released by the RecordSupply.
Definition: RecordRingItem.cpp:265
void fromProducer(int64_t seq)
Set the sequence of an item obtained through RecordSupply#get().
Definition: RecordRingItem.cpp:176
static void setEventFactorySettings(ByteOrder &order, uint32_t maxEventCount, uint32_t maxBufferSize, Compressor::CompressionType &compressionType)
Method to set RecordRingItem parameters for objects created by eventFactory.
Definition: RecordRingItem.cpp:52
int64_t getSequence() const
Get the sequence at which this object was taken from ring by one of the &quot;get&quot; calls.
Definition: RecordRingItem.cpp:162
RecordRingItem()
Default constructor.
Definition: RecordRingItem.cpp:64
static const ByteOrder ENDIAN_LOCAL
Local host&#39;s byte order.
Definition: ByteOrder.h:61