diff --git a/src/main/environment/bengen_docker.properties b/src/main/environment/bengen_docker.properties index bb6fe16..06e8fe8 100644 --- a/src/main/environment/bengen_docker.properties +++ b/src/main/environment/bengen_docker.properties @@ -10,7 +10,11 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver start-bengen-scheduler=true # To Run scheduler Every MON,WED,FRI -cron-scheduler-bengen=0 1 0 ? * MON,WED,FRI,SUN * +# cron-scheduler-bengen=0 1 0 ? * MON,WED,FRI,SUN * + + +# To Run scheduler Every Day +cron-scheduler-bengen=0 1 0 * * ? * # To Run scheduler Every Minute #cron-scheduler-bengen=0 0/1 * * * ? * @@ -19,7 +23,16 @@ cron-scheduler-bengen=0 1 0 ? * MON,WED,FRI,SUN * no-of-benID-to-be-generate=25000 ### Total available Ben should not be less than this -lower-limit-of-beneficiary=20000 +lower-limit-of-beneficiary=10000 + +### Rows inserted per batch (each batch commits on its own) +benID-batch-size=500 + +### Low-water-mark watcher: tops the pool up as soon as it drops below +### lower-limit-of-beneficiary, instead of only at the cron fire times. +bengen.pool-watcher-enabled=true +bengen.pool-watcher-interval-ms=300000 +bengen.pool-watcher-initial-delay-ms=60000 ### Health API warns (status DEGRADED) when available Ben IDs fall below this health.min-available-beneficiary-ids=5000 @@ -31,3 +44,4 @@ spring.redis.host=${REDIS_HOST} logging.path=logs/ logging.file.name=${BENEFICIARYID_GENERATION_API_LOGGING_FILE_NAME} jwt.secret=${JWT_SECRET_KEY} + diff --git a/src/main/environment/bengen_example.properties b/src/main/environment/bengen_example.properties index bd3742c..e3d7027 100644 --- a/src/main/environment/bengen_example.properties +++ b/src/main/environment/bengen_example.properties @@ -11,10 +11,10 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver start-bengen-scheduler=true # To Run scheduler Every MON,WED,FRI -cron-scheduler-bengen=0 1 0 ? * MON,WED,FRI,SUN * +# cron-scheduler-bengen=0 1 0 ? * MON,WED,FRI,SUN * # To Run scheduler Every Day -# cron-scheduler-bengen=0 1 0 * * ? * +cron-scheduler-bengen=0 1 0 * * ? * # To Run scheduler Every Minute #cron-scheduler-bengen=0 0/1 * * * ? * @@ -23,7 +23,16 @@ cron-scheduler-bengen=0 1 0 ? * MON,WED,FRI,SUN * no-of-benID-to-be-generate=25000 ### Total available Ben should not be less than this -lower-limit-of-beneficiary=20000 +lower-limit-of-beneficiary=10000 + +### Rows inserted per batch (each batch commits on its own) +benID-batch-size=500 + +### Low-water-mark watcher: tops the pool up as soon as it drops below +### lower-limit-of-beneficiary, instead of only at the cron fire times. +bengen.pool-watcher-enabled=true +bengen.pool-watcher-interval-ms=300000 +bengen.pool-watcher-initial-delay-ms=60000 ### Health API warns (status DEGRADED) when available Ben IDs fall below this health.min-available-beneficiary-ids=5000 @@ -38,3 +47,4 @@ logging.path=logs/ logging.file.name=logs/beneficiaryid-generation-api.log cors.allowed-origins=http://localhost:* + diff --git a/src/main/java/com/iemr/common/bengen/config/quartz/ScheduleJobServiceForBenGen.java b/src/main/java/com/iemr/common/bengen/config/quartz/ScheduleJobServiceForBenGen.java index 9f85953..986f366 100644 --- a/src/main/java/com/iemr/common/bengen/config/quartz/ScheduleJobServiceForBenGen.java +++ b/src/main/java/com/iemr/common/bengen/config/quartz/ScheduleJobServiceForBenGen.java @@ -21,6 +21,7 @@ */ package com.iemr.common.bengen.config.quartz; +import org.quartz.DisallowConcurrentExecution; import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; @@ -28,42 +29,26 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import com.iemr.common.bengen.repo.BeneficiaryIdRepo; import com.iemr.common.bengen.service.GenerateBeneficiaryService; -import com.iemr.common.bengen.utils.config.ConfigProperties; @Service -@Transactional -public class ScheduleJobServiceForBenGen implements Job -{ +@DisallowConcurrentExecution +public class ScheduleJobServiceForBenGen implements Job { private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - @Autowired - BeneficiaryIdRepo beneficiaryIdRepo; - @Autowired GenerateBeneficiaryService generateBeneficiaryService; - @Override - public void execute(JobExecutionContext arg0) throws JobExecutionException - { - logger.info("Started job " + arg0.getClass().getName()); - try - { - Long totalBenID= beneficiaryIdRepo.countBenID(); - logger.info("Total Beneficiary ID available -> " + totalBenID); - Integer lowerLimitOfBen = ConfigProperties.getInteger("lower-limit-of-beneficiary"); - if(totalBenID list, private static final long serialVersionUID = 1L; }.getType(); String data = OutputMapper.getInstance().gson().toJson(list, typeOfSrc); - logger.info("data: " + data); - logger.info("data.toStr: " + data.toString()); OutputResponse response = new OutputResponse.Builder().setDataJsonType("JsonObject.class") .setStatusCode(statusCode).setStatusMessage(statusMsg) .setDataObjectType(this.getClass().getSimpleName()) diff --git a/src/main/java/com/iemr/common/bengen/repo/BeneficiaryIdRepo.java b/src/main/java/com/iemr/common/bengen/repo/BeneficiaryIdRepo.java index aa5bc98..f910507 100644 --- a/src/main/java/com/iemr/common/bengen/repo/BeneficiaryIdRepo.java +++ b/src/main/java/com/iemr/common/bengen/repo/BeneficiaryIdRepo.java @@ -114,10 +114,14 @@ Long countByReservedForPSMapIdAndProvisionedAndReserved( + " WHERE benregMap.provisioned =false and benregMap.reserved =false") Long countBenID(); - @Query(nativeQuery = true, value = "Select benregMap.benRegId, benregMap.beneficiaryId, " + - "benregMap.CreatedDate " - + "from m_beneficiaryregidmapping benregMap " - + "where benregMap.provisioned =false and benregMap.reserved =true " + - "and benregMap.vanID=:vanID order by benregMap.benRegId desc limit :num ") - List getBenIDGenerated(@Param("vanID") Integer vanID, @Param("num") Long num); + @Query(nativeQuery = true, value = "Select benregMap.benRegId, benregMap.beneficiaryId, " + + "benregMap.CreatedDate " + + "from m_beneficiaryregidmapping benregMap " + + "where benregMap.provisioned =false and benregMap.reserved =true " + + "and benregMap.vanID=:vanID and benregMap.CreatedDate >= :createdFrom " + + "and benregMap.beneficiaryId in (:beneficiaryIds) " + + "order by benregMap.benRegId") + List getBenIDGeneratedForRequest(@Param("vanID") Integer vanID, + @Param("createdFrom") Timestamp createdFrom, + @Param("beneficiaryIds") List beneficiaryIds); } diff --git a/src/main/java/com/iemr/common/bengen/service/BeneficiaryPoolWatcher.java b/src/main/java/com/iemr/common/bengen/service/BeneficiaryPoolWatcher.java new file mode 100644 index 0000000..0911afc --- /dev/null +++ b/src/main/java/com/iemr/common/bengen/service/BeneficiaryPoolWatcher.java @@ -0,0 +1,52 @@ +/* +* AMRIT - Accessible Medical Records via Integrated Technologies +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +*/ +package com.iemr.common.bengen.service; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + + +@Component +@ConditionalOnProperty(name = "bengen.pool-watcher-enabled", havingValue = "true", matchIfMissing = true) +public class BeneficiaryPoolWatcher { + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + @Autowired + GenerateBeneficiaryService generateBeneficiaryService; + + @Scheduled(initialDelayString = "${bengen.pool-watcher-initial-delay-ms:60000}", + fixedDelayString = "${bengen.pool-watcher-interval-ms:300000}") + public void watchPool() { + try { + int inserted = generateBeneficiaryService.topUpPoolIfBelowLimit(); + if (inserted > 0) { + logger.info("Pool watcher topped up {} beneficiary IDs", inserted); + } + } catch (Exception e) { + logger.error("Pool watcher top-up failed", e); + } + } +} diff --git a/src/main/java/com/iemr/common/bengen/service/GenerateBeneficiaryService.java b/src/main/java/com/iemr/common/bengen/service/GenerateBeneficiaryService.java index 28bc8b2..85bb83c 100644 --- a/src/main/java/com/iemr/common/bengen/service/GenerateBeneficiaryService.java +++ b/src/main/java/com/iemr/common/bengen/service/GenerateBeneficiaryService.java @@ -21,20 +21,21 @@ */ package com.iemr.common.bengen.service; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Statement; import java.sql.Timestamp; import java.time.Instant; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicBoolean; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.BatchPreparedStatementSetter; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; @@ -46,7 +47,26 @@ @Service public class GenerateBeneficiaryService { private static final Logger logger = LoggerFactory.getLogger(GenerateBeneficiaryService.class); - private ExecutorService executor = Executors.newCachedThreadPool(); + + static final String POOL_INSERT_SQL = "INSERT IGNORE INTO `m_beneficiaryregidmapping` " + + "(`BeneficiaryID`,`Provisioned`,`Deleted`,`Reserved`,`CreatedDate`,`CreatedBy`) " + + "VALUES (?, b'0', b'0', b'0', ?, 'admin-batch')"; + + static final String RESERVED_INSERT_SQL = "INSERT IGNORE INTO `m_beneficiaryregidmapping` " + + "(`BeneficiaryID`,`Provisioned`,`Deleted`,`Reserved`,`CreatedDate`,`CreatedBy`,`VanID`) " + + "VALUES (?, b'0', b'0', b'1', ?, 'admin-batch', ?)"; + + static final int DEFAULT_BATCH_SIZE = 500; + static final int DEFAULT_TOTAL_TO_GENERATE = 25000; + static final int DEFAULT_LOWER_LIMIT = 10000; + + static final int MAX_SHORTFALL_PASSES = 5; + + static final int READ_BACK_CHUNK_SIZE = 1000; + + static final int READ_BACK_CLOCK_SLACK_SECONDS = 2; + + private final AtomicBoolean generationInProgress = new AtomicBoolean(false); @Autowired JdbcTemplate jdbcTemplate; @@ -54,161 +74,176 @@ public class GenerateBeneficiaryService { @Autowired BeneficiaryIdRepo beneficiaryIdRepo; - public void generateBeneficiaryIDs() throws Exception { - logger.info("BengenApplication.run start"); - long strt = System.currentTimeMillis(); + public int topUpPoolIfBelowLimit() { + if (!generationInProgress.compareAndSet(false, true)) { + logger.info("Beneficiary ID generation already running, skipping this check"); + return 0; + } + try { + Long available = beneficiaryIdRepo.countBenID(); + long currentPool = available == null ? 0L : available; + int lowerLimit = configValue("lower-limit-of-beneficiary", DEFAULT_LOWER_LIMIT); + logger.info("Beneficiary ID pool check: available={}, lowerLimit={}", currentPool, lowerLimit); - // for (int i = 0; i < 10; i++) { - executor.submit(() -> { - logger.info("Running: " + Thread.currentThread().getName()); - createFile(); - }); + if (currentPool >= lowerLimit) { + return 0; + } + int configured = configValue("no-of-benID-to-be-generate", DEFAULT_TOTAL_TO_GENERATE); + long deficit = lowerLimit - currentPool; + int toGenerate = (int) Math.max(configured, deficit); + logger.warn("Beneficiary ID pool {} is below lower limit {} - generating {}", currentPool, lowerLimit, + toGenerate); + return generateBeneficiaryIDs(toGenerate); + } finally { + generationInProgress.set(false); + } + } - /* - * executor.submit(() -> { logger.info("Running: " + - * Thread.currentThread().getName()); createFile(); }); - * - * executor.submit(() -> { logger.info("Running: " + - * Thread.currentThread().getName()); createFile(); }); - */ - // } - - long fin = System.currentTimeMillis() - strt; - logger.info("BengenApplication.run finish. time = " + fin + " ms."); + public int generateBeneficiaryIDs() { + return generateBeneficiaryIDs(configValue("no-of-benID-to-be-generate", DEFAULT_TOTAL_TO_GENERATE)); } - public void createFile() { - logger.info("BengenApplication.createFile start"); - long strt = System.currentTimeMillis(); + public int generateBeneficiaryIDs(int total) { + long start = System.currentTimeMillis(); + logger.info("Beneficiary ID generation start: total={}", total); - try { - File file = File.createTempFile("" + System.currentTimeMillis(), ".csv"); - logger.info("File: " + file.getAbsolutePath()); - FileWriter fw = new FileWriter(file); - BufferedWriter bw = new BufferedWriter(fw); - Integer bentobeGenerate = ConfigProperties.getInteger("no-of-benID-to-be-generate"); - bw.write(createQuery(bentobeGenerate).toString()); - bw.flush(); - bw.close(); - } catch (IOException ioe) { - ioe.printStackTrace(); + int inserted = insertInBatches(POOL_INSERT_SQL, total, null); + + logger.info("Beneficiary ID generation finished: requested={}, inserted={}, time={} ms", total, inserted, + System.currentTimeMillis() - start); + if (inserted < total) { + logger.warn("Generated {} of {} requested beneficiary IDs", inserted, total); } - long fin = System.currentTimeMillis() - strt; - logger.info("BengenApplication.createFile finish. time = " + fin + " ms."); + return inserted; } - public StringBuffer createQuery(Integer num) { - logger.info("BengenApplication.createQuery start"); - long strt = System.currentTimeMillis(); - - Generator g = new Generator(); - StringBuffer sb = new StringBuffer( - "INSERT INTO `m_beneficiaryregidmapping` " + - "(`BeneficiaryID`,`Provisioned`,`Deleted`," + - "`CreatedDate`,`CreatedBy`) VALUES "); - - // INSERT INTO `m_beneficiaryregidmapping` - // (`BeneficiaryID`,`Provisioned`,`Deleted`,`CreatedDate`,`CreatedBy`) VALUES - // (<{BeneficiaryID: }>, <{Provisioned: b'0'}>, <{Deleted: b'0'}>, - // <{CreatedDate: CURRENT_TIMESTAMP}>, <{CreatedBy: }>); - - Timestamp ts = Timestamp.from(Instant.now()); - - for (int i = 0; i < num; i++) { - sb.append("( "); - sb.append(g.generateBeneficiaryId()) - .append(",") - .append("b'0'") - .append(",") - .append("b'0'") - .append(",") - .append("'") - .append(ts) - .append("',") - .append("'admin-batch'") - .append(""); - sb.append(" ), "); + int insertInBatches(String sql, int total, Integer vanID) { + return insertInBatches(sql, total, vanID, null); + } + + int insertInBatches(String sql, int total, Integer vanID, List generatedIds) { + if (total <= 0) { + logger.warn("Nothing to generate, requested count was {}", total); + return 0; + } + int batchSize = configValue("benID-batch-size", DEFAULT_BATCH_SIZE); + int totalBatches = (total + batchSize - 1) / batchSize; + Generator generator = new Generator(); + int inserted = 0; + int batchNo = 0; + + for (int pass = 0; pass < MAX_SHORTFALL_PASSES && inserted < total; pass++) { + if (pass > 0) { + logger.warn("Duplicate IDs skipped, retry pass {} for remaining {} rows", pass, total - inserted); + } + int remaining = total - inserted; + while (remaining > 0) { + int size = Math.min(batchSize, remaining); + int rows = insertOneBatch(sql, size, generator, vanID, generatedIds); + inserted += rows; + remaining -= size; + logger.info("Batch {}/{}: generated {}, inserted {} (total {}/{})", ++batchNo, totalBatches, size, + rows, inserted, total); + } } + return inserted; + } - sb.deleteCharAt(sb.lastIndexOf(",")); + private int insertOneBatch(String sql, int size, Generator generator, Integer vanID, + List generatedIds) { + final Timestamp createdDate = Timestamp.from(Instant.now()); + final List ids = new ArrayList<>(size); + for (int i = 0; i < size; i++) { + ids.add(generator.generateBeneficiaryId()); + } - jdbcTemplate.execute(sb.toString()); + int[] updateCounts = jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() { + @Override + public void setValues(PreparedStatement ps, int i) throws SQLException { + ps.setBigDecimal(1, new BigDecimal(ids.get(i))); + ps.setTimestamp(2, createdDate); + if (vanID != null) { + ps.setInt(3, vanID); + } + } - long fin = System.currentTimeMillis() - strt; - logger.info("BengenApplication.createQuery finish. time = " + fin + " ms."); + @Override + public int getBatchSize() { + return size; + } + }); - return sb; + if (generatedIds != null) { + generatedIds.addAll(ids); + } + return countInserted(updateCounts); } - public void testLoopGenr() { - List strList = new ArrayList(); - StringBuffer sb = new StringBuffer( - "INSERT INTO `m_beneficiaryregidmapping` " + - "(`BeneficiaryID`,`Provisioned`,`Deleted`,`CreatedDate`," + - "`CreatedBy`) VALUES "); - Timestamp ts = Timestamp.from(Instant.now()); - Generator g = new Generator(); - sb.append("( ") - .append(g.generateBeneficiaryId()) - .append(",").append("N").append(",") - .append("0").append(",") - .append(ts).append(",") - .append("admin-batch").append(") "); - - strList.add(sb.toString()); + static int countInserted(int[] updateCounts) { + int rows = 0; + for (int count : updateCounts) { + if (count == Statement.SUCCESS_NO_INFO || count > 0) { + rows++; + } + } + return rows; } - public void testPMDAvoidGenr() { - + private static int configValue(String key, int fallback) { + Integer configured = ConfigProperties.getInteger(key); + if (configured == null || configured <= 0) { + logger.warn("Property {} missing or not positive, falling back to {}", key, fallback); + return fallback; + } + return configured; } public List getBeneficiaryIDs(Long num, Integer vanID) { - logger.info("getBeneficiaryIDs start"); - long strt = System.currentTimeMillis(); - Generator g = new Generator(); - StringBuffer sb = new StringBuffer( - "INSERT INTO `m_beneficiaryregidmapping` " + - "(`BeneficiaryID`,`Provisioned`,`Deleted`,`Reserved`," + - "`CreatedDate`,`CreatedBy`,`VanID`) VALUES "); - Timestamp ts = Timestamp.from(Instant.now()); - List list = new ArrayList(); - - for (int i = 0; i < num; i++) { - sb.append("( "); - sb.append(g.generateBeneficiaryId()).append(",").append("b'0'") - .append(",").append("b'0'").append(",") - .append("b'1'").append(",").append("'") - .append(ts).append("',").append("'admin-batch'").append(",") - .append(vanID).append(""); - sb.append(" ), "); + logger.info("getBeneficiaryIDs start: num={}, vanID={}", num, vanID); + long start = System.currentTimeMillis(); - } - - sb.deleteCharAt(sb.lastIndexOf(",")); - - jdbcTemplate.execute(sb.toString()); + int requested = num == null ? 0 : num.intValue(); + Timestamp createdFrom = Timestamp + .from(Instant.now().minusSeconds(READ_BACK_CLOCK_SLACK_SECONDS)); - List result = null; - - logger.info("ts result1 = " + ts); - - result = beneficiaryIdRepo.getBenIDGenerated(vanID, num); + List generatedIds = new ArrayList<>(Math.max(requested, 0)); + int inserted = insertInBatches(RESERVED_INSERT_SQL, requested, vanID, generatedIds); + if (inserted < requested) { + logger.warn("Reserved only {} of {} requested IDs for vanID {}", inserted, requested, vanID); + } - for (Object[] objects : result) { - if (objects != null && objects.length > 0) { + List list = readBackOwnRows(vanID, createdFrom, generatedIds); + if (list.size() < inserted) { + logger.warn("Read back {} of {} reserved IDs for vanID {}", list.size(), inserted, vanID); + } - list.add(new M_BeneficiaryRegidMapping(((Number) objects[0]).longValue(), - ((Number) objects[1]).longValue(), - (Timestamp) objects[2], "admin-batch")); + logger.info("getBeneficiaryIDs finish. time = {} ms.", System.currentTimeMillis() - start); + return list; + } + private List readBackOwnRows(Integer vanID, Timestamp createdFrom, + List generatedIds) { + List list = new ArrayList<>(generatedIds.size()); + for (int from = 0; from < generatedIds.size(); from += READ_BACK_CHUNK_SIZE) { + int to = Math.min(from + READ_BACK_CHUNK_SIZE, generatedIds.size()); + List chunk = new ArrayList<>(to - from); + for (BigInteger id : generatedIds.subList(from, to)) { + chunk.add(id.longValueExact()); } - + mapRows(beneficiaryIdRepo.getBenIDGeneratedForRequest(vanID, createdFrom, chunk), list); } - long fin = System.currentTimeMillis() - strt; - logger.info("getBeneficiaryIDs finish. time = " + fin + " ms."); - return list; - } + private static void mapRows(List rows, List target) { + if (rows == null) { + return; + } + for (Object[] objects : rows) { + if (objects != null && objects.length > 0) { + target.add(new M_BeneficiaryRegidMapping(((Number) objects[0]).longValue(), + ((Number) objects[1]).longValue(), (Timestamp) objects[2], "admin-batch")); + } + } + } } diff --git a/src/main/java/com/iemr/common/bengen/utils/Generator.java b/src/main/java/com/iemr/common/bengen/utils/Generator.java index 88d9c41..709a976 100644 --- a/src/main/java/com/iemr/common/bengen/utils/Generator.java +++ b/src/main/java/com/iemr/common/bengen/utils/Generator.java @@ -22,8 +22,6 @@ package com.iemr.common.bengen.utils; import java.math.BigInteger; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * @@ -32,26 +30,14 @@ */ public class Generator { - private static final Logger log = LoggerFactory.getLogger(Generator.class); - public BigInteger generateBeneficiaryId(){ BigInteger bid1 = generateFirst(); BigInteger bid2 = generateNumN(10); - if (log.isDebugEnabled()){ - log.debug("bid1: "+bid1+" length: "+getDigitCount(bid1)); - log.debug("bid2: "+bid2+" length: "+getDigitCount(bid2)); - } BigInteger bid = bid1.add(bid2).multiply(new BigInteger("10")); String chsum = Verhoeff.generateVerhoeff(bid.toString()); - if (log.isDebugEnabled()){ - log.debug("bid: "+bid+" length: "+getDigitCount(bid)+" chsum: " + chsum); - } bid = bid.add(new BigInteger(chsum)); - if (log.isDebugEnabled()){ - log.debug("BENEFICIARY ID: " + bid /*+ ": Length: " + getDigitCount(bid)*/); - } return bid; } @@ -106,18 +92,12 @@ public int getDigitCount(BigInteger number) { public int getRandomNum(){ int num = (int) (Math.random() * 100 % 10); - if (log.isDebugEnabled()){ - log.debug("Rand generated: " + num); - } return num; } public int getRandomNumRad(int rad){ int num = getRandomNum(); num = num % rad; - if (log.isDebugEnabled()){ - log.debug("Rand generated ("+ rad + "): " + num); - } return num; } @@ -129,27 +109,7 @@ public int getRandomNumRadRange(int rad1, int rad2){ num = getRandomNumRadRange(rad1, rad2); } - if (log.isDebugEnabled()){ - log.debug("Rand range generated: " + num); - } return num; } - public void displayArrays(int[] myArr, int[] myArr2){ - StringBuilder str = new StringBuilder(); - for(int i=0;i ${LOG_FILE}.json - - ${LOG_FILE}.json.%d{yyyy-MM-dd}.gz + + + ${LOG_FILE}.json.%d{yyyy-MM-dd}.%i.gz 100MB - 0 + 7 + 2GB true