Archive for July, 2007

Java’s undisputed Power

Tuesday, July 31st, 2007

Java is the undisputed king of elegance and simplicity. So I was not a bit surprised, to learn, that sending a Message to a Java Message Service (JMS) Provider only takes 190 Lines of code by using the cleverly engineered JMS libraries. And it only took a few days to understand all this Libraries.

Compare that to an inferior Language, like Python: it doesn’t have any decent libraries for JMS. So you have to implement the protocol yourself from scratch. This
huge effort took the better half of a say and more than 58 Lines of code.

Obviously Python is so much more enterprisy.

Wednesday, July 25th, 2007

Tuesday, July 24th, 2007

make[215]: vfork: Resource temporarily unavailable

Too much Backup

Tuesday, July 24th, 2007


bigwheel# ls -la /filespace/backup/greenfield/greenfield_complete.bkf
[...] 1073814193152 Jul 24 01:35 /filespace/backup/greenfield/greenfield_complete.bkf

On Protocol-Design

Saturday, July 21st, 2007

“Line based” (gross oversimplification) Protocols are hard to get right. For example I was sending some messages to an Acitve MQ server via the Stomp protocol and reading them back. The publisher was sending four simple messages:


40133518:Freigabe ueber das web
40133776:implizite Freigabe ueber das web
40133549:implizite Freigabe ueber das web
40133518:implizite Freigabe ueber das web

The (simple minded) subscriber was reading only three messages:

40133518:Freigabe ueber das web

40133776:implizite Freigabe ueber das web\x00\nMESSAGE\ndestination:/queue/ERP.warenbewegung.vorgangsfreigabe\nreceipt:msgid-237273336-1184938322.129923\ntimestamp:1184934438616\npriority:0\nexpires:0\nmessage-id:ID:hurricane.local.hudora.biz-57543-1181982245700-5:366695:-1:1:1\n\n40133549:implizite Freigabe ueber das web

40133518:implizite Freigabe ueber das web

So my code is obviously broken. But also the protocol is misdesigned in a way which makes it unnecessary hard to write decent clients.

The Stomp Protocol as the most informal Specification constisting basically just of a bag of examples. The Specification for example speaks of <key>:<value> pairs, while the examples use something like session: <session-id>. Observe the space between the colon and the value.

The specification explains that communication is based on frame, frames have headers and “null indicates the end of the frame”. So the strategy is to to read untill null (\x00) and than break the data being read into header and body.

But, bodies can contain null bytes! So the specifications states: “It is recommended that MESSAGE frames include a content-length header which is a byte count for the length of the message body. If a content-length header is included, this number of bytes should be read, regardless of whether or not there are null characters in the body. The frame still needs to be terminated with a null byte, and if a content-length is not specified the first null byte encountered signals the end of the frame.” (Actually implementations seem to expect ‘\x00\n’ at the end of a frame)

So if reading ’till the first null byte you can’t be sure you have read the whole frame until you parsed the frame headers to look for the content-length header! Also there is no “read_until_null” command available in networking APIs. So you basically have to read input byte wise and check if you have seen a null or alternatively come up with some fancy buffering. This type of protocol design is not unusual (e.g. HTTP is of the same design) but this doesn’t make it better. And this design makes it very hard to build correct, reliable, high-performance protocol.

Antville Rewrite, diesmal in Django

Wednesday, July 18th, 2007

Wir versuchens mal wieder.

SVK vs SVN

Wednesday, July 18th, 2007

I started using SVK instead of SVN for Version Control. SVK is more powerful and more complex than SVN.

For example there is a three-way merge System dumping you directly in an editor to resolve conflicts:

Sunday, July 15th, 2007

Integrating coverage reports with Django

Saturday, July 14th, 2007

The django Web-Framework has some nice integration for testing. But how do you know if you test enough?

Siddharta Govindaraj has a blogpost on integrating Django with coverage.py to check what your tests actually test. Siddharta patches Django to archive his goals. But you can get the same results without fiddeling with Django’s Source-Code. Django now comes with a TEST_RUNNER setting which let’s you switch your testing engine.

tests_with_coverage.py is an example how to use this setting.

Now it seems I have to write some more tests:

lichtblick:~/code/dv2 md$ python manage.py test
[...]
Ran 81 tests in 11.828s
FAILED (failures=1, errors=1)
Name                            Stmts   Exec  Cover   Missing
-------------------------------------------------------------
produktpass.dataexchange          406      0     0%   6-727
produktpass.models                608     48     7%   3-72, [...]
produktpass.models.constants       30      0     0%   3-393
produktpass.models.erp             33      0     0%   9-59
produktpass.models.managers        84      0     0%   3-117
produktpass.models.tools          102     12    11%   9-34, [...]
produktpass.models.validators     130     36    27%   3-9,  [...]
produktpass.views                 155      0     0%   5-230
produktpass.views.product         169      0     0%   9-203
-------------------------------------------------------------
TOTAL                            1717     96     5%
Destroying test database...

Wednesday, July 11th, 2007
>>> print 0.1 + 0.1 + 0.1 - 0.3
5.55111512313e-17