Skip to content

Commit d0ba1c1

Browse files
committed
Small simplifications
1 parent 1d47599 commit d0ba1c1

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/main/java/org/radarbase/output/worker/RadarKafkaRestructure.kt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ class RadarKafkaRestructure(
8686
logger.info("{} topics found", paths.size)
8787

8888
coroutineScope {
89-
paths.map { p ->
89+
paths.forEach { p ->
9090
launch {
9191
try {
9292
val (fileCount, recordCount) = fileStoreFactory.workerSemaphore.withPermit {
93-
mapTopic(this@coroutineScope, p)
93+
mapTopic(p)
9494
}
9595
processedFileCount.add(fileCount)
9696
processedRecordsCount.add(recordCount)
@@ -102,8 +102,7 @@ class RadarKafkaRestructure(
102102
}
103103
}
104104

105-
private suspend fun mapTopic(scope: CoroutineScope, topicPath: Path): ProcessingStatistics {
106-
logger.info("Mapping topic {}", topicPath)
105+
private suspend fun mapTopic(topicPath: Path): ProcessingStatistics {
107106
if (isClosed.get()) {
108107
return ProcessingStatistics(0L, 0L)
109108
}
@@ -112,9 +111,11 @@ class RadarKafkaRestructure(
112111

113112
return try {
114113
val statistics = lockManager.tryWithLock(topic) {
115-
AccountantImpl(fileStoreFactory, topic).useSuspended { accountant ->
116-
accountant.initialize(scope)
117-
startWorker(topic, topicPath, accountant, accountant.offsets)
114+
coroutineScope {
115+
AccountantImpl(fileStoreFactory, topic).useSuspended { accountant ->
116+
accountant.initialize(this@coroutineScope)
117+
startWorker(topic, topicPath, accountant, accountant.offsets)
118+
}
118119
}
119120
}
120121
if (statistics == null) {
@@ -134,16 +135,13 @@ class RadarKafkaRestructure(
134135
seenFiles: OffsetRangeSet): ProcessingStatistics {
135136
return RestructureWorker(sourceStorage, accountant, fileStoreFactory, isClosed).useSuspended { worker ->
136137
try {
137-
logger.info("Collecting paths for topic {}", topic)
138138
val topicPaths = TopicFileList(topic, sourceStorage.walker.walkRecords(topic, topicPath)
139139
.consumeAsFlow()
140140
.filter { f -> !seenFiles.contains(f.range)
141141
&& f.lastModified.durationSince() >= minimumFileAge }
142142
.take(maxFilesPerTopic)
143143
.toList())
144144

145-
logger.info("Collected {} paths for topic {}", topicPaths.numberOfFiles, topic)
146-
147145
if (topicPaths.numberOfFiles > 0) {
148146
worker.processPaths(topicPaths)
149147
}

0 commit comments

Comments
 (0)