RFC: Basic pattern for timestamps

Joseph Marques jmarques at redhat.com
Fri Mar 19 21:47:15 UTC 2010


On 03/19/2010 04:25 PM, Bryan Kearney wrote:
> Looking for comments. Basic created/updatd pattern (only implemented 
> on Consumer for this patch). It has the weakness of calculating the 
> values in the Vm.. which could raise issues with Clock Skew. However.. 
> i think that could be changed with minimla impact on the subclasses.
>
> -- bk
If you want the greatest database independence, all time related DB 
columns should be simple numerics that map to 'long' fields in hibernate 
entities representing epoch millis.

When we were adding the high availability stuff to RHQ (which allows N 
servers to distribute the incoming load from the agents) we found 
inconsistent handling between date/time columns between the databases we 
supported.  You could mitigate this by using **timestamp-aware** 
date/time columns, but then you have the problem of having a single 
column of data holding data in different timestamps (depending on the 
timezone of VM that is persisting the data into the DB).

In preparation for HA just prior to the JON 2.1.0 (RHQ 1.1.0) release, 
we had to perform major surgery on the code base to make date/time 
handling consistent:

1) changed all entities to use long fields representing epoch millis
2) changed all DB columns to BIGINT type (or NUMBER(19,0) on Oracle)
3) had to write dbupgrade code which a) added new columns of the 
appropriate numeric type, b) converted the old timestamp data into the 
new epoch millis format, c) blew away the old column, and d) renamed the 
new column to the old column name...see schemaSpec 2.19->2.23 for how 
this was done)
4) changed all SLSB code to use the new 'long' setters/getters
5) changed all instances of timestamp display within the UI to leverage 
a consistent formatter (this formatter, a reusable JSF component, 
dictated how the user saw all of their dates, times, date/times, and 
scheduler-related date/times...the formatter's pattern was actually made 
configurable in the code such that users could change they way they saw 
date/time fields, but we never had time to expose the ability to enter a 
different pattern in the user preferences page)

-joseph



More information about the candlepin mailing list