Posts

Showing posts from 2017

Quartz Cron Expressions

The documentation can be found here - http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/crontrigger.html

Ignite Running in Static IP multicast mode

Apache Ignite throws multicast exception in local machine when multicast is on and internet is connect. The following is an example of multicast IP discovery  <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->         <property name="discoverySpi">             <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">                 <property name="ipFinder">                      <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder. multicast . TcpDiscoveryMulticastIpFinder ">                         <property name="addresses">                             <list>               ...

NSSM service eats 100% CPU

Image
NSSM logstash service can cause a fatal CPU hungry outage in your clients unless you override the AppExit default value. By default it comes as default 'Restart' To change it to ' Stop service ' you need to run the following command nssm set logstash AppExit Default Exit It will change the service definition as follow Other v alid exit actions are: Restart Ignore Exit Suicide  

Reading a resource file in Spring boot

Some applications store XML files in src/main/resources folder and want to access it from a java class, using the following syntax   InputStream ioStream = Application . class . getResourceAsStream (" template.xml "); But it returns a null object. The problem with spring boot webapp is the file is actually a classpath resource. To access it use the following syntax InputStream ioStream = Application . class . getClassLoader() . getResourceAsStream (" template.xml ");

Hibernate/JPA is not a silver bullet

I have been working with different data access frameworks since 2005. I started with simple JDBC and learnt various pros and cons of it. then moved to connection pooling and advanced topics. explored Open JPA , Hibernate , Spring data , Spring JDBC , serialization using thrift and protocol buffer etc. Hibernate or JPA is not built for batch operations or anything where you need to fetch an object from database and perform some business logic in a loop. When you loop through the entities and each entity holds a huge payload such as big XMLs/Strings or binary data, they pollute the 1st level cache of hibernate. It results in repeated and frequent GCs and slow down your application, sometimes causes out of memory . So never ever use hibernate or JPA for batch or loop-> process uses cases. Spring jdbc performs better compare to JPA when you need to perform a batching/looping.

When LogStash 5.X windows service STOP, doesn't close Orphan Java processes

In windows LogStash service is created using NSSM.  NSSM takes IO redirection inputs and a flag value which determines how to signal Windows kernel and what to do when the windows service is stopped. when we set  nssm set logstash AppStopMethodSkip 6 It just sends the signal ^C (ctrl +c ) or stop to the Windows kernel, just like we stop a java process in command prompt using a Ctrl+c. But if the parent process spawns threads then only ^C  cannot stop the child processes. Just like windows task manager's kill process tree option, in this case we need to send the WM_CLOSE signal to Windows. For  a NSSM windows service it is done when you set  nssm set logstash AppStopMethodSkip 5 Along, with that you need to pass an additional flag to the logstash arg param. the shutdown_watcher.rb in logstash is a listener to the shutdown event. when logstash spawns many worker processes to send different logs, then the shutdown gets stalled if ay of...

LogStash 5.X Windows service creation

Elastic has changed the command line arguments of logstash. To create a new logstash 5 windows service you have to follow these steps - $logstash_install_location represents the location of Logstash folder. logstash is the service name browse the  $logstash_install_location folder and create two folders conf and logs conf contains all configuration files of logstash. you dont have to change a single file, you can keep as many files you want. such as one for windows logs conf , one for java logs Open command prompt and locate the folder where NSSM exe file is put. then issue the following commands one after another. nssm install logstash $logstash_install_location \bin\logstash.bat nssm set logstash AppParameters --path.config $logstash_install_location\ conf nssm set logstash AppDirectory $logstash_install_location\ nssm set logstash AppStdout $logstash_install_location \logs\sysout.log nssm set logstash AppStderr $logstash_install_location \...

Monitoring and alerting Microservices

Microservices exist for rapid development and deployment. Time to market a product is reduced significantly. But to monitor the container and API performance one needs tools. If we build a client and from java code call the API or from AOP, it will send update to a time series database using JMS or REST call. Maybe a server component to get the data and update One can configure Rules and actions - if CPU > 100 raise alert -> action send SMS or email or call a HTTP URL with json data. For visualization one can use grafana or custom tools.