[Hawkular-dev] UTC Timezone - Default for Services

Thomas Segismont tsegismo at redhat.com
Wed May 13 15:44:53 EDT 2015


Le 13/05/2015 21:11, Stefan Negrea a écrit :
> Hello Everybody,
>
> With the metrics aggregation work well under way, we have encountered the first case where timezones are important. The task queue [1] that John wrote to be used in the aggregation process is time sensitive. The tasks ran according to a schedule that is predefined; the time relationship also applies to failures, retries, and cancellation. Based on the experience we had with RHQ, not using an UTC timezone can lead to errors and loss of data (for more details visit [2])
>
> I propose to set the default time zone for all the services to UTC. Only allow the concept of a timezone in the UI. This will avoid any problems due to automatic transitions between DST and non-DST times. For example, if the user wants to schedule something 2 weeks from now, let the UI handle the user selection. But when the user action is sent to the backend, it should be expressed in an timezone agnostic manner (eg. milliseconds since Unix Epoch).
>
> The PR [1] sets the default timezone for the JODA library to be UTC for the classloader that contains the metrics service. With the recent discussions about creating a combined Kettle EAR or using a single classloader, that means this setting will extend to all the services in the same classloader that use JODA. And this is just the default, if a service really needs to set another timezone for a date object, it can be done by just specifying the timezone.
>
> We tried to make the change more local in the metrics code, but the approach was error prone. Anybody could make a mistake and instantiate a date object in the current server timezone rather than UTC. This global approach drastically limits inadvertent mistakes.
>
>
> Two questions for the group:
> 1) Does anybody see any issues with using the UTC timezone as default at the services layer?

I think it is error prone to have any joda.Date you create set in the 
UTC timezone, and any util.Date you create in the server timezone.

Also I can't see where the problem to create the joda.Instant objects 
properly in the scheduler utility class. Maybe I'm missing something?

> 2) Should we expand this setting to the JVM (not just JODA)?

-1

To make this properly the JVM must be started with user.timezone 
property set to UTC. Otherwise we don't control what happens at the 
server level or in libraries, because the setting is effective only when 
the class is loaded.
In the end, the system would rely on external config.

Also if we do this, it means than most users will have to configure all 
the loggers template, because you usually want your logs printed in the 
timezone of your hosts, but the default templates will print the logs 
for the JVM timezone.

I fear it's not the only annoyance which would show up.

>
>
> [1] Task queue PR  - https://github.com/hawkular/hawkular-metrics/pull/205
> [2] Old RHQ thread - https://lists.fedorahosted.org/pipermail/rhq-devel/2014-November/003709.html
>
>
>
> Thank you,
> Stefan Negrea
>
> Software Engineer
>
> _______________________________________________
> hawkular-dev mailing list
> hawkular-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hawkular-dev
>



More information about the hawkular-dev mailing list