pradeepagrawal8184 commented on code in PR #495: URL: https://github.com/apache/ranger/pull/495#discussion_r1903940492
########## security-admin/src/main/java/org/apache/ranger/patch/BaseLoader.java: ########## @@ -32,176 +30,164 @@ import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import java.text.DecimalFormat; + /** - * * */ public abstract class BaseLoader { - private static final Logger logger = LoggerFactory.getLogger(BaseLoader.class); - - long startTime = DateUtil.getUTCDate().getTime(); - long lastTime = startTime; - int countSoFar = 0; - int countFromLastTime = 0; - boolean moreToProcess = true; - boolean firstCall = true; - int batchSize = -1; - DecimalFormat twoDForm = new DecimalFormat("#.00"); + private static final Logger logger = LoggerFactory.getLogger(BaseLoader.class); protected final RangerAdminConfig config; + long startTime = DateUtil.getUTCDate().getTime(); + long lastTime = startTime; + int countSoFar; + int countFromLastTime; + boolean moreToProcess = true; + boolean firstCall = true; + int batchSize = -1; + DecimalFormat twoDForm = new DecimalFormat("#.00"); public BaseLoader() { this.config = RangerAdminConfig.getInstance(); } public void init(int batchSize) throws Exception { - this.batchSize = batchSize; - CLIUtil cliUtil = (CLIUtil) CLIUtil.getBean(CLIUtil.class); - cliUtil.authenticate(); + this.batchSize = batchSize; + CLIUtil cliUtil = (CLIUtil) CLIUtil.getBean(CLIUtil.class); + cliUtil.authenticate(); } public void init() throws Exception { - init(-1); + init(-1); } - abstract public void printStats(); + public abstract void printStats(); public abstract void execLoad(); public void onExit() { - logger.info("onExit()"); + logger.info("onExit()"); } /** * @return the moreToProcess */ public boolean isMoreToProcess() { - return moreToProcess; + return moreToProcess; } /** - * @param moreToProcess - * the moreToProcess to set + * @param moreToProcess the moreToProcess to set */ public void setMoreToProcess(boolean moreToProcess) { - this.moreToProcess = moreToProcess; + this.moreToProcess = moreToProcess; } @Transactional(readOnly = false, propagation = Propagation.REQUIRED) public void load() { - if (firstCall) { - startTime = DateUtil.getUTCDate().getTime(); - startProgressMonitor(); - firstCall = false; - } - try { - execLoad(); - if (batchSize < 0) { - moreToProcess = false; - } - } catch (Throwable t) { - logger.error("Error while loading data.", t); - moreToProcess = false; - } - if (!moreToProcess) { - long endTime = DateUtil.getUTCDate().getTime(); - - logger.info("###############################################"); - printStats(); - logger.info("Loading completed!!!. Time taken=" - + formatTimeTaken(endTime - startTime) + " for " - + countSoFar); - logger.info("###############################################"); - synchronized (twoDForm) { - twoDForm.notifyAll(); - } - - } + if (firstCall) { + startTime = DateUtil.getUTCDate().getTime(); + startProgressMonitor(); + firstCall = false; + } + try { + execLoad(); + if (batchSize < 0) { + moreToProcess = false; + } + } catch (Throwable t) { + logger.error("Error while loading data.", t); + moreToProcess = false; + } + if (!moreToProcess) { + long endTime = DateUtil.getUTCDate().getTime(); + + logger.info("###############################################"); + printStats(); + logger.info("Loading completed!!!. Time taken=" + formatTimeTaken(endTime - startTime) + " for " + countSoFar); Review Comment: Done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@ranger.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org