Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse SmartHome » Persistence: store with timestamp
Persistence: store with timestamp [message #1738185] Sun, 17 July 2016 18:46 Go to next message
Markus Rathgeb is currently offline Markus RathgebFriend
Messages: 105
Registered: August 2014
Senior Member

If I understand the current persistence interface correctly, there exist a method to store the state of an item.
This method is called with the item as the only argument.

The only timestamp that could be used to stored the state is the current time.
So, shouldn't we add add a timestamp argument there?

Should we add a timestamp to every event -- the timestamp the event has been generated? Is it a good idea or a bad one?
Re: Persistence: store with timestamp [message #1738200 is a reply to message #1738185] Mon, 18 July 2016 06:07 Go to previous messageGo to next message
Chris Jackson is currently offline Chris JacksonFriend
Messages: 256
Registered: December 2013
Senior Member
Quote:

So, shouldn't we add add a timestamp argument there?


We could - that's effectively what I'm suggesting, only that I was proposing to use the existing HistoricItem interface. It might be easier to just add the time as a separate parameter.

Quote:

Should we add a timestamp to every event -- the timestamp the event has been generated? Is it a good idea or a bad one?


I would suggest it would be a good idea - not just to support this use case of adding historic data, but simply to ensure that you know the time an event is generated. With distributed systems, delays can mount and timing is often important... However, I guess that is a separate topic Wink
Re: Persistence: store with timestamp [message #1738251 is a reply to message #1738200] Mon, 18 July 2016 12:53 Go to previous messageGo to next message
Chris Jackson is currently offline Chris JacksonFriend
Messages: 256
Registered: December 2013
Senior Member
Hey Markus,
Sorry - I've just realised that I replied to you thinking that your message was in response to my earlier message on the same topic -:

https://www.eclipse.org/forums/index.php/t/1076925/

I also submitted a PR on this last night which defines such an interface -:

https://github.com/eclipse/smarthome/pull/1872

Chris
Re: Persistence: store with timestamp [message #1738257 is a reply to message #1738251] Mon, 18 July 2016 13:49 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Quote:
Should we add a timestamp to every event -- the timestamp the event has been generated? Is it a good idea or a bad one?


I think it is a very bad idea as it will fully break most existing code, which currently relies on the fact that the order of receiving IS the chronological order.
What should a rule do with an even that is older than the one it just has processed, but noticing that taking this event into account means that it should never ever have executed some action?
Not being able to rely on the order anymore means that any client logic will have to take the timestamp into account (and probably most clients will come up with different solutions on how to deal with it).
Imho, such a technically very small addition would massively complicate (and break) the current architecture.
Re: Persistence: store with timestamp [message #1738259 is a reply to message #1738257] Mon, 18 July 2016 13:53 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
For the persistence service (such as in https://github.com/eclipse/smarthome/pull/1872), I am fine with introducing a new method with a timestamp as this will only store data in the database and have no further direct impact on any other clients - and it is an option that not all persistence services have to support (as Chris introduces a new dedicated interface).
Re: Persistence: store with timestamp [message #1738263 is a reply to message #1738257] Mon, 18 July 2016 14:06 Go to previous messageGo to next message
Markus Rathgeb is currently offline Markus RathgebFriend
Messages: 105
Registered: August 2014
Senior Member

Kai Kreuzer wrote on Mon, 18 July 2016 13:49
as it will fully break most existing code, which currently relies on the fact that the order of receiving IS the chronological order.


Could you please explain me why adding the creation timestamp to an event will break the chronological order?

Kai Kreuzer wrote on Mon, 18 July 2016 13:53
For the persistence service (such as in https://github.com/eclipse/smarthome/pull/1872), I am fine with introducing a new method with a timestamp as this will only store data in the database and have no further direct impact on any other clients - and it is an option that not all persistence services have to support (as Chris introduces a new dedicated interface).


I need to have a look at to Chris PR, but reading the description I assume he wants to add already collected historic data to the persistence service.

That is not my intention.

If I ran two different persistence service (that could be up and down) and I want to merge the persistent data, the same data added could has been added to the two persistence services with different timestamps.

If a state should be persist in separate persistence services we can (IMHO) rely on the fact that the most persistence service will persist the data with a timestamp.
I don't see any reason, why this timestamp should be generated by every persistence service on its own. It would be nice if the framework could call the store with the same timestamp for all persistence services.
Re: Persistence: store with timestamp [message #1738266 is a reply to message #1738263] Mon, 18 July 2016 14:11 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Quote:
Could you please explain me why adding the creation timestamp to an event will break the chronological order?


Simply because event1(today), event2(yesterday) means that they are not in chronological order anymore?

Quote:
we can (IMHO) rely on the fact that the most persistence service will persist the data with a timestamp.


Not so the logging persistence service, the rrd4j persistence service and possibly others. That's why I think the additional interface makes sense (and we already have a distinction between queryable and non-queryable services, so this imho fits in here).
Re: Persistence: store with timestamp [message #1738267 is a reply to message #1738266] Mon, 18 July 2016 14:18 Go to previous messageGo to next message
Markus Rathgeb is currently offline Markus RathgebFriend
Messages: 105
Registered: August 2014
Senior Member

Kai Kreuzer wrote on Mon, 18 July 2016 14:11
Quote:
Could you please explain me why adding the creation timestamp to an event will break the chronological order?


Simply because event1(today), event2(yesterday) means that they are not in chronological order anymore?


1. Adding information will not change a order. If this is wrong, we should never add a member to a class
2. If the order has been "1. event1" and "2. event2" and event2 is older then event1, then the order has been already non-chronological.

I assume you interpret (as Chris before) I would like to mix the PR of Chris and a timestamp information to store.

But this is not that I have written. Have I?

I never talked about a relationship between Chris PR and my suggestion.
Re: Persistence: store with timestamp [message #1738306 is a reply to message #1738267] Mon, 18 July 2016 20:46 Go to previous messageGo to next message
Markus Rathgeb is currently offline Markus RathgebFriend
Messages: 105
Registered: August 2014
Senior Member

Kai Kreuzer wrote on Mon, 18 July 2016 14:11
Not so the logging persistence service, the rrd4j persistence service and possibly others. That's why I think the additional interface makes sense (and we already have a distinction between queryable and non-queryable services, so this imho fits in here).


I am not against the additional interface.
I am fine with that.



My intention has been that I can store to all PersistenceSerivce implementations using the same timestamp e.g. iterate over all persistence service and store the item on change. Currently this results in different timestamps on every storage.

It is not about filling "old" values in the database, still the "current" one.
Re: Persistence: store with timestamp [message #1738328 is a reply to message #1738306] Tue, 19 July 2016 06:46 Go to previous messageGo to next message
Markus Rathgeb is currently offline Markus RathgebFriend
Messages: 105
Registered: August 2014
Senior Member

Related to: https://github.com/eclipse/smarthome/pull/1872/files/12c7c317a8b4eb8f69672ccb9717b132626cbbb7#r71277850

If the new interface extends the QueryablePersistenceService it also extends the PersistenceService.
With this change, my forum thread is obsolete.
Then I can iterate over all PersistenceService and if it is an instance of HistoricalPersistenceService I can use `store(HistoricItem historicItem)` otherwise `store(Item Item)`.


Lets interpret this thread as finished / closed.
If there is still something open I will retry after Chris PR is merged.
Re: Persistence: store with timestamp [message #1738329 is a reply to message #1738328] Tue, 19 July 2016 06:49 Go to previous message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Sounds good Smile
Previous Topic:Persistence method to store historical data
Next Topic:The maximum number of concurrent running devices
Goto Forum:
  


Current Time: Fri Mar 29 15:19:46 GMT 2024

Powered by FUDForum. Page generated in 0.02880 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top