Home | May 2007 >>

A past life, back up in

I got a nice surprise today. Turns out a research project/paper I worked on while in grad school was finally published!

``Security in wireless sensor networks", published in Wireless Communications and Mobile Computing.

Funny thing is, my research focus in grad school was artificial intelligence. :)

FTP using Groovy and Ant

Lately, I've been writing a lot of scripts in Groovy. Frankly, I love it. It's easy to augment the functionality of your Java classes -- implement interfaces, extend classes etc. Another nice feature is that Groovy allows you to leverage the power of Ant in your scripts using the AntBuilder object. I find this incredibly useful when doing off-liney, scripty things I'd normally do using bash combined with other Unix tools.

One common scripting task is to transfer a bunch of files to an FTP server. Here's how I would accomplish FTP'ing *.gz files in the current directory using bash and curl:

for f in *.gz ; do
    curl -s -S -P - -T $f ftp.foo.com
done
Hard to beat for compactness. But, if you're already working in Groovy, you can use Ant's FTP task to accomplish the same thing. Here's the Groovy code:
ant = new AntBuilder()
ant.ftp( server:"ftp.foo.com",
    userid:"user",
    password:"passwd",
    passive:"yes",
    verbose:"yes",
    remotedir:"/pub/incoming",
    binary:"yes" ) {
        fileset( dir:"." ) {
            include( name:"**/*.gz" )
        }
    }
The verbose setting is helpful because otherwise the command's operation is silent. With verbose enabled, output will be sent to stdout. All options supported by Ant's FTP task can be used in the Groovy context. Furthermore, nested XML elements in Ant become closures in Groovy. (The fileset and include statements above.)

FTP is an optional Ant task so if you want to use it in your scripts, you'll need the following dependencies on your classpath:

  • ant.jar
  • ant-nodeps.jar
  • ant-apache-oro.jar
  • ant-commons-net.jar
  • jakarta-oro.jar (at least version 2.0.8)
  • commons-net.jar (at least version 1.4)
I've tested this with Ant 1.6.5 only.

All your READ_UNCOMMITTED and REPEATABLE_READ transactions are belong to us

I spent an hour this evening trying to figure out why my application was throwing this exception:

java.sql.SQLException: READ_COMMITTED and SERIALIZABLE are the only valid transaction levels

Perhaps you've seen it? Perhaps you've already figured out the ``solution"? This post is for those looking for a solution; at least an answer.

I'll cut to the chase: if you are using Oracle then only READ_COMMITTED and SERIALIZABLE transactions are supported. The SQLException isn't lying. Oracle supports these two isolation levels explicitly and others implicitly. That is,

From Ask Tom: On Transaction Isolation Levels:

...in Oracle Database, READ COMMITTED has all of the attributes required to achieve read-consistent queries. In other databases, READ COMMITTED queries can and will return answers that never existed in the database. Moreover, Oracle Database also supports the spirit of READ UNCOMMITTED. The goal of providing a dirty read is to supply a nonblocking read, whereby queries are not blocked by, and do not block, updates of the same data. However, Oracle Database doesn't need dirty reads to achieve this goal, nor does it support them. Dirty reads are an implementation other databases must use to provide nonblocking reads.

So, simply put, Oracle has no need to explicitly support READ_UNCOMMITTED or REPEATABLE_READ as the locking semantics (normally) required to implement these isolation levels are not necessary (in Oracle.) The above article has details on why these semantics are not necessary in Oracle. For more general information, check out the Wikipedia article on multiversion concurrency control (MVCC).

It's like that

Here's something I wanna remember.

...it's like learning to walk or swim or ride the bicycle, you just go after it: it is a matter of learning how to move with balance among forces greater than your own, gravity, water's buoyance, psychic tides: you lean in or with or against the ongoing so as not to be drowned but to be swept effortlessly up upon the universal possibilities -- Archie Ammons, Sphere: The Form of a Motion
Yeah, it's like that. Welcome to the blog.

Tags :