Showing posts from December, 2011

Installing and configuring Cband for Apache2 on Ubuntu

If you need to manage bandwidth usage on Apache web server (particularly on a per virtualhost basis) CBand could be that hero you were hoping for. Below are the steps I followed to get up and running with a basic CBand setup.


Install additional apache libraries. Only one of these two maybe required.
apt-get install apache2-prefork-dev
apt-get install apache2-threaded-dev

Download the module
Untar the file
tar -xzf mod-cband-
Enter newly created directory
cd mod-cband-
Add -lm to the APXS OPTS in like so:
Configure and install
make install

Restart Apache

Hopefully you should now have successfully installed Cband on your Ubuntu server.
Now let's configure it.


In order to improve performance of Cband, add the following to /etc/apache2/mods-available/cband.conf
CBandScoreFlushPeriod 1

Groovy safe navigation gotcha

I just came across this Groovy gotcha today while accessing a list within a chain of attributes. I had a statement like this in a gsp:
This is the (erroneous) recommended style when data binding many ended associations in Grails, but it could easily arise in other scenarios. If I try this "safe" statement where invoiceItems is null, I'll see a null pointer exception. In fact I'll even see it when invoice is null. The reason for the exception is a combination of how lists and the safe navigation work in Groovy.

Lists are much more elegant in Groovy than Java, as they share the square brackets that primitive arrays use. Creating a list is as easy as writing:
def x = [1,2,3]
Just like an array you can access the first element of this list like so:
println x[0]
However, unlike a primitive array the [] operator on a list is mapped (by some Groovy magic) behind the scenes to the getAt method of the particular List object. We can expand our exampl…