@@ -203,43 +203,50 @@ private InsertResponse insertBatch(List<InsertRecordData> batch, String tableNam
203203 }
204204
205205 private void configureConcurrencyAndBatchSize (int totalRequests ) {
206- Dotenv dotenv = Dotenv .load ();
207- String userProvidedBatchSize = dotenv .get ("BATCH_SIZE" );
208- String userProvidedConcurrencyLimit = dotenv .get ("CONCURRENCY_LIMIT" );
209-
210- if (userProvidedBatchSize != null ) {
211- try {
212- int batchSize = Integer .parseInt (userProvidedBatchSize );
213- if (batchSize > 0 ) {
214- this .batchSize = batchSize ;
215- } else {
206+ try {
207+ Dotenv dotenv = Dotenv .load ();
208+ String userProvidedBatchSize = dotenv .get ("BATCH_SIZE" );
209+ String userProvidedConcurrencyLimit = dotenv .get ("CONCURRENCY_LIMIT" );
210+
211+ if (userProvidedBatchSize != null ) {
212+ try {
213+ int batchSize = Integer .parseInt (userProvidedBatchSize );
214+ if (batchSize > 0 ) {
215+ this .batchSize = batchSize ;
216+ } else {
217+ LogUtil .printWarningLog (WarningLogs .INVALID_BATCH_SIZE_PROVIDED .getLog ());
218+ this .batchSize = Constants .BATCH_SIZE ;
219+ }
220+ } catch (NumberFormatException e ) {
216221 LogUtil .printWarningLog (WarningLogs .INVALID_BATCH_SIZE_PROVIDED .getLog ());
217222 this .batchSize = Constants .BATCH_SIZE ;
218223 }
219- } catch (NumberFormatException e ) {
220- LogUtil .printWarningLog (WarningLogs .INVALID_BATCH_SIZE_PROVIDED .getLog ());
221- this .batchSize = Constants .BATCH_SIZE ;
222224 }
223- }
224225
225- // Max no of threads required to run all batches concurrently at once
226- int maxConcurrencyNeeded = (totalRequests + this .batchSize - 1 ) / this .batchSize ;
227-
228- if (userProvidedConcurrencyLimit != null ) {
229- try {
230- int concurrencyLimit = Integer .parseInt (userProvidedConcurrencyLimit );
231- if (concurrencyLimit > 0 ) {
232- this .concurrencyLimit = Math .min (concurrencyLimit , maxConcurrencyNeeded );
233- } else {
226+ // Max no of threads required to run all batches concurrently at once
227+ int maxConcurrencyNeeded = (totalRequests + this .batchSize - 1 ) / this .batchSize ;
228+
229+ if (userProvidedConcurrencyLimit != null ) {
230+ try {
231+ int concurrencyLimit = Integer .parseInt (userProvidedConcurrencyLimit );
232+ if (concurrencyLimit > 0 ) {
233+ this .concurrencyLimit = Math .min (concurrencyLimit , maxConcurrencyNeeded );
234+ } else {
235+ LogUtil .printWarningLog (WarningLogs .INVALID_CONCURRENCY_LIMIT_PROVIDED .getLog ());
236+ this .concurrencyLimit = Math .min (Constants .CONCURRENCY_LIMIT , maxConcurrencyNeeded );
237+ }
238+ } catch (NumberFormatException e ) {
234239 LogUtil .printWarningLog (WarningLogs .INVALID_CONCURRENCY_LIMIT_PROVIDED .getLog ());
235240 this .concurrencyLimit = Math .min (Constants .CONCURRENCY_LIMIT , maxConcurrencyNeeded );
236241 }
237- } catch (NumberFormatException e ) {
238- LogUtil .printWarningLog (WarningLogs .INVALID_CONCURRENCY_LIMIT_PROVIDED .getLog ());
242+ } else {
239243 this .concurrencyLimit = Math .min (Constants .CONCURRENCY_LIMIT , maxConcurrencyNeeded );
240244 }
241- } else {
245+ } catch (Exception e ) {
246+ this .batchSize = Constants .BATCH_SIZE ;
247+ int maxConcurrencyNeeded = (totalRequests + this .batchSize - 1 ) / this .batchSize ;
242248 this .concurrencyLimit = Math .min (Constants .CONCURRENCY_LIMIT , maxConcurrencyNeeded );
243249 }
244250 }
251+
245252}
0 commit comments