13
13
// limitations under the License.
14
14
15
15
#include " CheckPointManager.h"
16
- #include < string>
16
+
17
+ #include < fcntl.h>
18
+
17
19
#include < fstream>
20
+ #include < string>
18
21
#include < thread>
19
- #include < fcntl.h>
20
- #include " monitor/LogtailAlarm.h"
22
+
21
23
#include " app_config/AppConfig.h"
22
- #include " config_manager/ConfigManager .h"
24
+ #include " common/FileSystemUtil .h"
23
25
#include " common/Flags.h"
24
26
#include " common/HashUtil.h"
25
27
#include " common/StringTools.h"
26
- #include " common/FileSystemUtil.h"
27
- #include " logger/Logger.h"
28
+ #include " config_manager/ConfigManager.h"
28
29
#include " file_server/FileDiscoveryOptions.h"
30
+ #include " logger/Logger.h"
31
+ #include " monitor/LogtailAlarm.h"
29
32
30
33
using namespace std ;
31
34
#if defined(__linux__)
@@ -200,6 +203,7 @@ void CheckPointManager::LoadFileCheckPoint(const Json::Value& root) {
200
203
int32_t fileOpenFlag = 0 ; // default, we close file ptr
201
204
int32_t containerStopped = 0 ;
202
205
int32_t lastForceRead = 0 ;
206
+ int32_t idxInReaderArray = LogFileReader::CHECKPOINT_IDX_OF_NEW_READER_IN_ARRAY;
203
207
if (meta.isMember (" real_file_name" )) {
204
208
realFilePath = meta[" real_file_name" ].asString ();
205
209
}
@@ -237,6 +241,9 @@ void CheckPointManager::LoadFileCheckPoint(const Json::Value& root) {
237
241
if (meta.isMember (" last_force_read" )) {
238
242
lastForceRead = meta[" last_force_read" ].asInt ();
239
243
}
244
+ if (meta.isMember (" idx_in_reader_array" )) {
245
+ idxInReaderArray = meta[" idx_in_reader_array" ].asInt ();
246
+ }
240
247
// can not get file's dev inode
241
248
if (!devInode.IsValid ()) {
242
249
LOG_WARNING (sLogger , (" can not find check point dev inode, discard it" , filePath));
@@ -258,6 +265,7 @@ void CheckPointManager::LoadFileCheckPoint(const Json::Value& root) {
258
265
containerStopped != 0 ,
259
266
lastForceRead != 0 );
260
267
ptr->mLastUpdateTime = update_time;
268
+ ptr->mIdxInReaderArray = idxInReaderArray;
261
269
AddCheckPoint (ptr);
262
270
} else {
263
271
// find config
@@ -290,6 +298,7 @@ void CheckPointManager::LoadFileCheckPoint(const Json::Value& root) {
290
298
containerStopped != 0 ,
291
299
lastForceRead != 0 );
292
300
ptr->mLastUpdateTime = update_time;
301
+ ptr->mIdxInReaderArray = idxInReaderArray;
293
302
AddCheckPoint (ptr);
294
303
}
295
304
}
@@ -336,6 +345,7 @@ bool CheckPointManager::DumpCheckPointToLocal() {
336
345
leaf[" config_name" ] = Json::Value (checkPointPtr->mConfigName );
337
346
// forward compatible
338
347
leaf[" sig" ] = Json::Value (string (" " ));
348
+ leaf[" idx_in_reader_array" ] = Json::Value (checkPointPtr->mIdxInReaderArray );
339
349
// use filename + dev + inode + configName to prevent same filename conflict
340
350
root[checkPointPtr->mFileName + " *" + ToString (checkPointPtr->mDevInode .dev ) + " *"
341
351
+ ToString (checkPointPtr->mDevInode .inode ) + " *" + checkPointPtr->mConfigName ]
@@ -365,6 +375,7 @@ bool CheckPointManager::DumpCheckPointToLocal() {
365
375
leaf[" config_name" ] = Json::Value (checkPointPtr->mConfigName );
366
376
// forward compatible
367
377
leaf[" sig" ] = Json::Value (string (" " ));
378
+ leaf[" idx_in_reader_array" ] = Json::Value (checkPointPtr->mIdxInReaderArray );
368
379
// use filename + dev + inode + configName to prevent same filename conflict
369
380
root[checkPointPtr->mFileName + " *" + ToString (checkPointPtr->mDevInode .dev ) + " *"
370
381
+ ToString (checkPointPtr->mDevInode .inode ) + " *" + checkPointPtr->mConfigName ]
0 commit comments