Sage-Bionetworks/Synapse-Repository-Services — pull request #63 by eric-wu (2012-08-14 00:58:38+00:00)
Title: PLFM-1405 Etags need to be unique across stacks

Basically rewriting the e-tag generation code to use collision-resistant, random numbers as e-tags. More specifically I am creating an new interface ETagGenerator that takes a TaggableEntity as input and returns a String as the e-tag. I am adding one implementation of ETagGenerator based on UUID.

I am changing the data type from Long to String as, to be collision-resistant, the tag number requires at least 128-bit. Both Java Long and MySql BigInt do not support that width directly.

Note that UUID only supports uniqueness. It is not deterministic and cannot validate content. Deterministic hashing can be used to achieve both. I am not adopting hashing yet as quite amount of design and coding will be needed. I will defer in the future what fields to compute hash from (e.g. name + id + timestamp).

Besides being almost unique, UUID can be computed locally (in a distributed manner) and fast. The static method initializes a SecureRandom instance and the initialization takes 50 - 100 ms. Once initialized, computing is fast around 0.05 ms. The number being random is opaque to users.

The only thing I am not sure about is the URL encoding/decoding for the e-tag in the dto's. I don't think it is needed. But to be safe, I am leaving them there.