@@ -42,6 +42,8 @@ import java.time.LocalDateTime
4242import java.time.format.DateTimeFormatter
4343import java.util.concurrent.Executors
4444import java.util.concurrent.TimeUnit
45+ import java.util.concurrent.atomic.LongAdder
46+ import kotlin.Long.Companion.MAX_VALUE
4547import kotlin.system.exitProcess
4648
4749/* * Main application. */
@@ -103,12 +105,12 @@ class Application(
103105 jobs.forEach { it.schedule(executorService) }
104106
105107 try {
106- Thread .sleep(java.lang. Long . MAX_VALUE )
108+ Thread .sleep(MAX_VALUE )
107109 } catch (e: InterruptedException ) {
108110 logger.info(" Interrupted, shutting down..." )
109111 executorService.shutdownNow()
110112 try {
111- executorService.awaitTermination(java.lang. Long . MAX_VALUE , TimeUnit .SECONDS )
113+ executorService.awaitTermination(MAX_VALUE , TimeUnit .SECONDS )
112114 Thread .currentThread().interrupt()
113115 } catch (ex: InterruptedException ) {
114116 logger.info(" Interrupted again..." )
@@ -117,20 +119,17 @@ class Application(
117119 }
118120
119121 private fun runCleaner () {
120- val numberFormat = NumberFormat .getNumberInstance()
121122 SourceDataCleaner (this ).use { cleaner ->
122123 for (input in config.paths.inputs) {
123124 logger.info(" Cleaning {}" , input)
124125 cleaner.process(input.toString())
125126 }
126127 logger.info(" Cleaned up {} files" ,
127- numberFormat.format( cleaner.deletedFileCount.sum() ))
128+ cleaner.deletedFileCount.format( ))
128129 }
129130 }
130131
131132 private fun runRestructure () {
132- val numberFormat = NumberFormat .getNumberInstance()
133-
134133 RadarKafkaRestructure (this ).use { restructure ->
135134 for (input in config.paths.inputs) {
136135 logger.info(" In: {}" , input)
@@ -139,15 +138,18 @@ class Application(
139138 }
140139
141140 logger.info(" Processed {} files and {} records" ,
142- numberFormat.format( restructure.processedFileCount.sum() ),
143- numberFormat.format( restructure.processedRecordsCount.sum() ))
141+ restructure.processedFileCount.format( ),
142+ restructure.processedRecordsCount.format( ))
144143 }
145144 }
146145
147146 companion object {
148147 private val logger = LoggerFactory .getLogger(Application ::class .java)
149148 const val CACHE_SIZE_DEFAULT = 100
150149
150+ private fun LongAdder.format (): String =
151+ NumberFormat .getNumberInstance().format(sum())
152+
151153 private fun parseArgs (args : Array <String >): CommandLineArgs {
152154 val commandLineArgs = CommandLineArgs ()
153155 JCommander .newBuilder()
0 commit comments