Java version of three phase commit