Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E5E57200C5A for ; Tue, 18 Apr 2017 08:38:46 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E44FF160BA1; Tue, 18 Apr 2017 06:38:46 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 10DD2160B90 for ; Tue, 18 Apr 2017 08:38:45 +0200 (CEST) Received: (qmail 55178 invoked by uid 500); 18 Apr 2017 06:38:45 -0000 Mailing-List: contact dev-help@fineract.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@fineract.incubator.apache.org Delivered-To: mailing list dev@fineract.incubator.apache.org Received: (qmail 55167 invoked by uid 99); 18 Apr 2017 06:38:45 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Apr 2017 06:38:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id D2E34C06D5 for ; Tue, 18 Apr 2017 06:38:44 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id OmRADRjFidtc for ; Tue, 18 Apr 2017 06:38:43 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 8EF475F5FD for ; Tue, 18 Apr 2017 06:38:42 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id D1CDFE0272 for ; Tue, 18 Apr 2017 06:38:41 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 8DDED21B45 for ; Tue, 18 Apr 2017 06:38:41 +0000 (UTC) Date: Tue, 18 Apr 2017 06:38:41 +0000 (UTC) From: "Avik Ganguly (JIRA)" To: dev@fineract.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (FINERACT-428) Parallelization of Jobs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 18 Apr 2017 06:38:47 -0000 [ https://issues.apache.org/jira/browse/FINERACT-428?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Avik Ganguly updated FINERACT-428: ---------------------------------- Description: For starters, it will be useful to have some technical configuration added as job parameter for each of the below jobs, that is batch size and thread pool size for executor service so this has a dependency on FINERACT-425. Add migration script to add those 2 configurations to each of the following jobs with the value of batch size being 500 and thread pool size being 16 :- Add Accrual Transactions Add Periodic Accrual Transactions Add Accrual Transactions For Loans With Income Posted As Transactions Generate Loan Loss Provisioning Post Interest for Savings Update Loan Summary This would require separation of core functionality to a separate class. Simplified example :- ``` final ExecutorService executor = Executors.newFixedThreadPool(threadPoolSize); final LocalDate dueDate = DateUtils.getLocalDateOfTenant(); final Collection loansToBeRepaidData = this.loanReadPlatformService .retrieveLoansToBeRepaidFromAdvancePayment(dueDate); Iterable> loansToBeRepaid = Iterables.partition(loansToBeRepaidData, batchSize); final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); List> advancePaymentPosters = new ArrayList>(); for (List subList : loansToBeRepaid) { AdvancePaymentPoster poster = (AdvancePaymentPoster) this.applicationContext.getBean("advancePaymentPoster"); poster.setLoans(subList); poster.setTenant(ThreadLocalContextUtil.getTenant()); poster.setAuthentication(authentication); poster.setCommandService(commandService); advancePaymentPosters.add(Executors.callable(poster)); } try { List> responses = executor.invokeAll(advancePaymentPosters); for(Future f : responses) { f.get(); } } catch (InterruptedException e1) { e1.printStackTrace(); } executor.shutdown(); ``` was: For starters, it will be useful to have some technical configuration added as job parameter for each of the below jobs, that is batch size and thread pool size for executor service so this has a dependency on FINERACT-425. Add migration script to add those 2 configurations to each of the following jobs with the value of batch size being 500 and thread pool size being 16 :- Add Accrual Transactions Add Periodic Accrual Transactions Add Accrual Transactions For Loans With Income Posted As Transactions Generate Loan Loss Provisioning Post Interest for Savings Update Loan Summary This would require separation of core functionality to a separate class. Simplified example :- final ExecutorService executor = Executors.newFixedThreadPool(threadPoolSize); final LocalDate dueDate = DateUtils.getLocalDateOfTenant(); final Collection loansToBeRepaidData = this.loanReadPlatformService .retrieveLoansToBeRepaidFromAdvancePayment(dueDate); Iterable> loansToBeRepaid = Iterables.partition(loansToBeRepaidData, batchSize); final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); List> advancePaymentPosters = new ArrayList>(); for (List subList : loansToBeRepaid) { AdvancePaymentPoster poster = (AdvancePaymentPoster) this.applicationContext.getBean("advancePaymentPoster"); poster.setLoans(subList); poster.setTenant(ThreadLocalContextUtil.getTenant()); poster.setAuthentication(authentication); poster.setCommandService(commandService); advancePaymentPosters.add(Executors.callable(poster)); } try { List> responses = executor.invokeAll(advancePaymentPosters); for(Future f : responses) { f.get(); } } catch (InterruptedException e1) { e1.printStackTrace(); } executor.shutdown(); > Parallelization of Jobs > ----------------------- > > Key: FINERACT-428 > URL: https://issues.apache.org/jira/browse/FINERACT-428 > Project: Apache Fineract > Issue Type: Improvement > Components: Loan, Savings > Reporter: Avik Ganguly > Assignee: Markus Geiss > Labels: performance > > For starters, it will be useful to have some technical configuration added as job parameter for each of the below jobs, that is batch size and thread pool size for executor service so this has a dependency on FINERACT-425. > Add migration script to add those 2 configurations to each of the following jobs with the value of batch size being 500 and thread pool size being 16 :- > Add Accrual Transactions > Add Periodic Accrual Transactions > Add Accrual Transactions For Loans With Income Posted As Transactions > Generate Loan Loss Provisioning > Post Interest for Savings > Update Loan Summary > This would require separation of core functionality to a separate class. > Simplified example :- > ``` > final ExecutorService executor = Executors.newFixedThreadPool(threadPoolSize); > > final LocalDate dueDate = DateUtils.getLocalDateOfTenant(); > final Collection loansToBeRepaidData = this.loanReadPlatformService > .retrieveLoansToBeRepaidFromAdvancePayment(dueDate); > Iterable> loansToBeRepaid = Iterables.partition(loansToBeRepaidData, batchSize); > final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); > List> advancePaymentPosters = new ArrayList>(); > > for (List subList : loansToBeRepaid) { > AdvancePaymentPoster poster = (AdvancePaymentPoster) this.applicationContext.getBean("advancePaymentPoster"); > poster.setLoans(subList); > poster.setTenant(ThreadLocalContextUtil.getTenant()); > poster.setAuthentication(authentication); > poster.setCommandService(commandService); > advancePaymentPosters.add(Executors.callable(poster)); > } > try { > List> responses = executor.invokeAll(advancePaymentPosters); > for(Future f : responses) { > f.get(); > } > } catch (InterruptedException e1) { > e1.printStackTrace(); > } > > executor.shutdown(); > ``` -- This message was sent by Atlassian JIRA (v6.3.15#6346)