Skip to content

Commit f7e0ed2

Browse files
848 AWS CloudWatch log clean‑up and standardisation for improved traceability (#409)
1 parent 818b6c4 commit f7e0ed2

4 files changed

Lines changed: 12 additions & 11 deletions

File tree

src/main/java/uk/ac/cam/cl/dtg/segue/dao/schools/SchoolListReader.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,21 @@ public class SchoolListReader {
6868
*/
6969
@Inject
7070
public SchoolListReader(final ISearchProvider searchProvider) {
71-
log.info("Initializing SchoolListReader");
71+
log.debug("Initializing SchoolListReader");
7272
this.searchProvider = searchProvider;
7373

7474
String modificationDate;
7575
try {
7676
modificationDate = searchProvider.getById(
7777
SCHOOLS_INDEX_BASE, SchoolsIndexType.METADATA.toString(), "sourceFile").getSource().get("lastModified")
7878
.toString();
79-
log.info("School list data source modification date: {}", modificationDate);
79+
log.debug("School list data source modification date: {}", modificationDate);
8080
} catch (SegueSearchException | ElasticsearchStatusException e) {
8181
log.error("Failed to retrieve school list modification date", e);
8282
modificationDate = "unknown";
8383
}
8484
dataSourceModificationDate = modificationDate;
85-
log.info("SchoolListReader initialized successfully");
85+
log.debug("SchoolListReader initialized successfully");
8686
}
8787

8888
/**

src/main/java/uk/ac/cam/cl/dtg/segue/etl/ContentIndexer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void loadAndIndexContent(final String version) throws Exception, VersionLockedEx
121121
throw new VersionLockedException(version);
122122
}
123123

124-
log.info("Acquired lock for version " + sanitiseInternalLogValue(version) + ". Indexing.");
124+
log.debug("Acquired lock for version " + sanitiseInternalLogValue(version) + ". Indexing.");
125125

126126
try {
127127

@@ -131,7 +131,7 @@ void loadAndIndexContent(final String version) throws Exception, VersionLockedEx
131131
// The case where only some of the content types have been successfully indexed for this version, should
132132
// never happen but is covered by an expunge at the start of #buildElasticSearchIndex(...).
133133
if (allContentTypesAreIndexedForVersion(version)) {
134-
log.info("Content already indexed: " + sanitiseInternalLogValue(version));
134+
log.debug("Content already indexed: " + sanitiseInternalLogValue(version));
135135
return;
136136
}
137137

src/main/java/uk/ac/cam/cl/dtg/segue/etl/ETLManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ class ETLManager {
5555
}
5656

5757
void setNamedVersion(final String alias, final String version) throws Exception {
58-
log.info("Requested aliased version: {} - {}", alias, version);
58+
log.debug("Requested aliased version: {} - {}", alias, version);
5959
indexer.loadAndIndexContent(version);
6060
indexer.setNamedVersion(alias, version);
61-
log.info("Version {} with alias '{}' is successfully indexed.", version, alias);
61+
log.debug("Version {} with alias '{}' is successfully indexed.", version, alias);
6262
}
6363

6464
// Indexes all content in idempotent fashion. If the content is already indexed no action is taken.
@@ -95,13 +95,13 @@ private class ContentIndexerTask implements Runnable {
9595

9696
@Override
9797
public void run() {
98-
log.info("Starting content indexer thread.");
98+
log.debug("Starting content indexer thread.");
9999
try {
100100
indexContent();
101101
} catch (Exception e) {
102102
log.error("ContentIndexerTask failed.", e);
103103
}
104-
log.info("Content indexer thread complete, waiting for next scheduled run.");
104+
log.debug("Content indexer thread complete, waiting for next scheduled run.");
105105
}
106106
}
107107
}

src/main/java/uk/ac/cam/cl/dtg/segue/etl/ElasticSearchIndexer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ boolean addOrMoveIndexAlias(final String aliasBase, final String indexBaseTarget
191191
final List<String> indexTypeTargets) {
192192
String indexWithPrevious = null; // This is the index that has the <alias>_previous alias
193193
String indexWithCurrent = null; // This is the index that has the <alias> alias.
194+
int alreadyCorrectCount = 0; // Count of aliases that don't need moving (reduces log noise)
194195

195196
for (String indexTypeTarget : indexTypeTargets) {
196197
String typedAlias = ElasticSearchProvider.produceTypedIndexName(aliasBase, indexTypeTarget);
@@ -242,8 +243,7 @@ boolean addOrMoveIndexAlias(final String aliasBase, final String indexBaseTarget
242243
}
243244

244245
if (indexWithCurrent != null && indexWithCurrent.equals(typedIndexTarget)) {
245-
log.info("Not moving alias '" + sanitiseInternalLogValue(typedAlias)
246-
+ "' - it already points to the right index.");
246+
alreadyCorrectCount++;
247247
} else {
248248
IndicesAliasesRequest request = new IndicesAliasesRequest();
249249

@@ -284,6 +284,7 @@ boolean addOrMoveIndexAlias(final String aliasBase, final String indexBaseTarget
284284
}
285285

286286
}
287+
log.debug("{}/{} aliases already correct, no moves needed.", alreadyCorrectCount, indexTypeTargets.size());
287288
this.expungeOldIndices();
288289
return true;
289290
}

0 commit comments

Comments
 (0)