Friday, April 27, 2012

JGroups IPv6 Broadcast Problem

Here is a quick tip: Do you regularly observe below harmless JGroups message send failures?

As Bela Ban says,

Your message are sent to an IPv6 multicast address; is this what you want? If not, and you want to force use of IPv4, use -Djava.net.preferIPv4Stack=true. If you want to use IPv6, make sure your routing table is set up correctly.

Sunday, April 8, 2012

RPC (Remote Procedure Call) with JGroups

JGroups forms a perfect medium for RPC between nodes in a cluster. Here, I share a very basic JGroups RPC example.

I think (at least, hope) the code is self-explanatory. A minor important point here is the RPC channel. Per see, I use ChannelFactory.getInstance().create() method to create the channel. ChannelFactory is a shortcut class to create multiple channels sharing the same transport. (See my Shared Transport in JGroups post for details.) That is, you need to have a separate JGroups channel reserved for RPC communication. All other messages sent/received using this channel will be consumed and ignored by the RpcDispatcher.

Build Scripts for LaTeX-BibTeX-XFig-GnuPlot Combo

Over the past 8 years, I needed to compile LaTeX documents for this or that reason. As time passed, I enhanced them with BibTeX, XFig, and Gnuplot. Further, I generally needed to produce PDF files validated by IEEE PDF eXpress. Here, I share some scripts I developed during the road to ease the pain.

First, note that there is a certain directory structure I stick to.

  • / -- LaTeX (.tex) and BibTeX (.bib) files are placed here.
  • /constants.tex -- LaTeX file for constants (variables, definitions, commands, etc.) shared between LaTeX and XFig files.
  • /make.sh -- Compiles the whole project.
  • /figs -- XFig (.fig), Gnuplot (.gnu), and EPS (.eps) files go here.
  • /figs/fig2eps.sh
  • /figs/make.sh -- Compiles the XFig and Gnuplot into EPS format.

Below is the entry point, /make.sh. (Make sure you have latex, bibtex, dvips, and pspdf commands available.)

In /make.sh, I follow LaTeX->DVI->PostScript->PDF path. The main reason for the preference of this path over LaTeX->PDF is to properly process scalable EPS figures produced by XFig. (Personally, I hate to see broken figures in published articles.)

Next, here goes /figs/make.sh script. (Per see, gnuplot is required during execution.)

Nothing fancy in /figs/make.sh. First, we process .fig files; second, we process .gnu files.

Finally, below goes /figs/fig2eps.sh script. (Make fig2dev, pdflatex, pdf2ps commands ready. Note that /figs/fig2eps.sh requires /constants.tex for shared LaTeX variables.)

After all these fuss, the whole project boils down to

$ ./make.sh paper bibtex
$ ./make.sh paper latex

and you are ready to go.

Scripts need a little bit more cleaning and they are probably the not most correct ones. Anyway, they served well until now, and I hope they would for you as well.