Skip to content

Commit e2bea86

Browse files
committed
#203 adding a log info regarding GuardRails during parsing
1 parent b0b35f5 commit e2bea86

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/main/java/com/adobe/campaign/tests/logparser/core/StringParseFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ protected static Map<String, String> parseString(String in_logString,
251251
Map<String, String> lr_stringParseResult = new HashMap<>();
252252
String l_currentStringState = in_logString;
253253

254+
ParseGuardRails.checkGuardRailsStatus();
255+
254256
for (ParseDefinitionEntry lt_parseRule : in_parsRuleList) {
255257

256258
lr_stringParseResult.put(lt_parseRule.getTitle(), fetchValue(l_currentStringState, lt_parseRule));

src/main/java/com/adobe/campaign/tests/logparser/utils/ParseGuardRails.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,28 @@ public class ParseGuardRails {
4343
.parseLong(System.getProperty("LOGPARSER_FILESIZE_LIMIT", "-1"));
4444
protected static int MEASUREMENT_SCALE = 1024 * 1024;
4545

46+
/**
47+
* Checks if any guard rails have been set
48+
*
49+
* @return true if any guard rail is set, false otherwise
50+
*/
51+
public static boolean areGuardRailsSet() {
52+
return FILE_ENTRY_LIMIT > -1 ||
53+
HEAP_LIMIT > -1 ||
54+
MEMORY_LIMIT_PERCENTAGE > -1 ||
55+
FILE_SIZE_LIMIT > -1;
56+
}
57+
58+
/**
59+
* Logs an info message if no guard rails are set
60+
*/
61+
public static void checkGuardRailsStatus() {
62+
if (!areGuardRailsSet()) {
63+
log.info(
64+
"No Memory Guard Rails detected. You can add them if you are dealing with large files or if you want to limit the memory usage.");
65+
}
66+
}
67+
4668
public static void reset() {
4769
fileSizeLimitations.clear();
4870
entryLimitations.clear();

0 commit comments

Comments
 (0)