Saturday, May 26, 2012

Week 2 / Day 1: Riak

The Riak chapter is great! Riak seems to be a wonderful database - exactly what every web developer is looking for. But it is the first database which is a NoSQL database and hence I have my doubts that it will work nicely with Grails.

So if first searched for a Grails plugin and found one! http://grails.org/plugin/riak

The documentation is fine and you get a really quick start with Riak. Even building Riak from source is no paint with the finde documentation available.

So I've installed Erland, Riak and the Riak-Plugin, started 3 Riak servers and tryed to run a simple application. That's where the problems started. I didn't know how to tell Grails that it should use Riak instead of the normal Gorm mapping via Hibernate. The answer was simple: just remove the hibernate plugin!

This works finde for Grails 1.3.8, but not for Grails 2.0.8 - it seems that Grails 2.0.8 automatically reinstalls the Hibernate plugin. So let's try to go on with Grails 1.3.8...

Now I get at least an error message saying I can't connect... I have the riak servers up and running and can connect through a browser, but not through the application.

After debugging a while, I notice that my riak config is not visible to the application... strange... after a while I have to reboot my virtual machine. After rebooting, my dev-riak servers are down and the app sees the riak configuration... but: the app connects to riak and runs! But it still seems to ignore my configuration...

Doesn't matter this time. At least, it connects and I can do some tests. I create an Object and it is somehow funny to see a riak hash code as ID:






Since Grails can connect to the Riak database, but it isn't running on the configured port, I redirect my browser to the standard Riak port 8098 et voilá! There it is.

Grails creates buckets as
projectname.Domain
and keys as hashes. So my just created object is accessible as
http://127.0.0.1:8098/riak/riak4.Book/-9011180415092426943
in my browser.


No comments:

Post a Comment