Saturday, June 11, 2016

Some Grails Tricks

Set log level in running instance by console

import org.apache.log4j.*
Logger.getLogger("mt.omid.rira.DataService").level = Level.DEBUG

Set grails environment in app server (using same war file for test/release), great for testing in JBoss

Environment variable grails.env can be set to proper environment like development or production.
or

CATALINA_OPTS=-Dgrails.env=development

In JBoss System properties part in Configuration section accept key/value pair that is used for the same purpose.

Grails (Hibernate) Batch Insert/Update

To prevent memory issue and increase the performance of batch insert or update it can be divided into the smaller bunch data, e.g. 1000 records, and flush and clear the transaction after saving each bunch.

def batch = []  // temp batch list
dataList.each { d ->
    d.value = 'blah blah blah'
    batch.add(d)
    if(batch.size() > 1000)
       runBatch(batch)
}


And the runBatch can be a piece of code like this:
        log.debug("Start Data batch saving")
        Data.withTransaction {
            for(Data d in batch){
                log.debug "Saving datum: ${d} ${d.isDirty('value')}"
                // d.save(flush: true) // not required to flush here, since session will flush before clear
                d.save()
            }
        }
        batch.clear()
        def session = sessionFactory.getCurrentSession()
        session.flush()
        session.clear()
        log.debug("Batch saving transaction & clearing hbn session finished")

The hibernate details can be found here.


Friday, May 13, 2016

JBoss JNDI SQLServer and Integrated Windows Authentication

Copy the sqljdbc_auth.dll (32 or 64 according to your jre) to bin folder of your jre (in jdk also copy to jre/bin).

In JBoss data source url set integratedSecurity=true .

Wednesday, January 13, 2016

Relay All Postfix Mails to Another SMTP Server

Edit /etc/postfix/main.cf

Add the relayhost parameter to proper smtp server like

relayhost=[smtp2.myserver.com]

Restart postfix service

Flush Redhat Mail Queue

postsuper -d ALL

postsuper -d ALL deferred


Saturday, January 2, 2016

Calling Taglib Methods in Grails Console

Loading Taglib Class (e.g. here ApplicationTaglib ):

def g = ctx.getBean(org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib.class.getName())

Calling Taglib Method:

g.createLink(controller: 'invitation', action: 'accept', params:[id: 'adasdasdas'])
g.link(action: 'create')

Saturday, October 10, 2015

First Flexbox Taste

The main feature of my CAMP project for monitoring performance of charging system, I should show multiple charts of different data sources and statistics in a a page view-port (it supposed to be used in NOC center on TV). So I decided to  try flexbox to learn something new and use new technology in my project. Dashboards can be defined to have different rows and columns, but my default dashboard is 3x3, so don't want to waste time more, it is the final

See the Pen epRoQw by Omid Mehdizadeh (@omidmt) on CodePen.

The first level of flex(1 column of 3 rows) is applied by second-content class and next level 3 columns inside each row is applied by frow class.

Challenges:

  • Heights as visible part, not more:
    • It is fixed by height: 97vh to body and max-height: 100% and min-height: 100% to main content div.

  • IE support of flex-basis:
    • It is solved by browser specific flex attribute as -ms-flex: 1 1 30vh and -ms-flex: 1 1 30%