-
Notifications
You must be signed in to change notification settings - Fork 782
allow non-model based persistence configuration #2094
allow non-model based persistence configuration #2094
Conversation
org.eclipse.smarthome.core.items, | ||
org.eclipse.smarthome.core.library.types, | ||
org.eclipse.smarthome.core.persistence, | ||
org.eclipse.smarthome.core.types, | ||
org.quartz, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a problem. You might remember that we tried to get rid off Quartz in the core bundles (see #658), since it is not compatible with compact2 profile and also is pretty fat. So when overhauling the persistence APIs, I would definitely refrain from using this library.
I would hope that you can use @kgoderis' new scheduler implementation instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know 😉
I used quartz just temporary to not change to much code.
I will use the new scheduler implementation (the automation should move its timer trigger, too) after the concept of the split is okay.
Thanks @maggu2810, making the persistence stuff independent from Xtext+EMF is definitely an important step (which was far too low on my personal todo list ;-)). So apart from the Quartz-refactoring, I would like to start the discussion what other refactorings we might want to do in order to adapt the persistence API / configuration possibilities to the needs. |
Done, no Quartz for persistence anymore 😉 |
Cool. Did you also test that it is working? I never tried the new scheduler with cron stuff myself yet... So what remains is my question in #2094 (comment). |
I tried this strategy |
@maggu2810 @kaikreuzer Damn... 8hours to late ;-) I have this piece of code in the pipe : kgoderis@826fc78 I had already the de-quartzifying on my to do list - the url here above could serve as an example. |
@maggu2810 btw, forget about cron, use RFC 5545 ;-) |
@kgoderis I removed Quartz from the persistence service only. |
Yeah Yeah - the todo list is growing every day .... |
I'd be fine to go ahead with this PR. @maggu2810 Do you still consider it WIP? Or shall we merge it as a working replacement for the current code and discuss further evolution in future? |
I think I need to revert the change to use the ESH scheduler instead of Quartz because cron does not work with the current ESH scheduler implementation as expected (see #2105) |
I don't know if it is such easily. But I assume @kgoderis knows.
That is the reason why I kept the [WIP] in front of the title.
I assume it is simple to merge the split of model.persistence now (without the Quartz scheduler removal) and merge the Quartz scheduler removal (the commits could be simple split out of this PR) after the ESH scheduler has been fixed. |
Not really, because this step moves the usage of Quartz from model to core. As the model bundles are optional, not everyone has this dependency, but if we move it to core, it will force people to add (the fat) Quartz to their stack. I'd therefore rather would want to wait for a solution of #2105. |
Okay 😉, missed that point |
Yoda says: Easy it is not I have not revisted #2105 since the discussion we had on the subject, as we need to decide on a strategy (see that thread) before moving forward. @kaikreuzer maybe you can voice your thoughts on the matter if you happen to find some time? |
I won't for the next days, but WHEN I find time, I will try to thing about it and share my thoughts... |
@maggu2810 Pls see PR #2270 |
Signed-off-by: Markus Rathgeb <maggu2810@gmail.com>
Signed-off-by: Markus Rathgeb <maggu2810@gmail.com>
Signed-off-by: Markus Rathgeb <maggu2810@gmail.com>
Signed-off-by: Markus Rathgeb <maggu2810@gmail.com>
return; | ||
} | ||
for (final Runnable job : persistenceJobs.get(persistModelName)) { | ||
boolean success = scheduler.remove(job); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just started testing this PR, but in this line success is always false and I get:
2016-11-02 15:25:55.180 [WARN ] [o.e.s.c.p.PersistenceManager :317 ] - Failed to delete cron job for dbId 'rrd4j
in my log (when updating the file rrd4j.persist).
This is probably an issue in the ESH scheduler implementation, but I'd like to know if this has worked for you? In my tests, the scheduler keeps creating new jobs and never removes them again...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have created https://github.com/eclipse/smarthome/pull/2391/files#diff-6ab8869df39e4b2f961a094a0437b037R34 for further investigation and fixing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this should be fixed by #2435, now. Correct?
private final Map<String, Set<Runnable>> persistenceJobs = new HashMap<>(); | ||
|
||
public PersistenceManagerImpl() { | ||
scheduler = ExpressionThreadPoolManager.getExpressionScheduledPool("persist"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't it be better to do this in activate() and de-reference and dispose it again in deactivate()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think so.
Will change it.
Signed-off-by: Markus Rathgeb <maggu2810@gmail.com>
Hm, what are we missing here? |
Trust in the new CRON scheduler implementation... |
The PR to "allow non-model based persistence configuration" also use the ESH scheduler instead of the Quartz one. |
Correct. What should be checked is whether there is any change in average system load and in the memory footprint. My plan was to test it with the openHAB demo setup, which has a couple of cron persistence configurations. Didn't yet find the time, tough. |
Ok, I finally did some testing. I couldn't make out any unusual CPU or memory consumption, even under high (persistence) load, so it lgtm. The problem is that the initial job does not seem to be correctly scheduled. After a startup, no items are persisted. Once I touch the rrd4j.perist file, I see a
in my log and afterwards it starts working. Not sure whether this is an issue of this PR or of the new scheduler service. Will need to investigate, before this can be merged. |
Ok, I tracked it down to a bug in the scheduler: #2746 |
Thanks for tracking that down @kaikreuzer |
#2746 is fixed, so we are good to merge! |
* allow non-model based persistence configuration Signed-off-by: Markus Rathgeb <maggu2810@gmail.com>
Currently a persistence service could be only configured using the DSL / models files (.persist).
This PR moves the persistence manager logic (the non-model based one) to persistence core and allows a programmatically configuration of persistence services, too. So we could add a REST interface some time.
It is far from complete, but it should at least work.
I used some "stupid" names, starting with "Simple". This has been done to prevent collisions between the names used in the model at development but will be changed later.
Can you have a look at?
@cdjackson As you seems to be a professional developer of the ESH persistence interfaces, could you have a look at, too?
@kaikreuzer The most files are touched has been written by you. Your comments are very welcome.
There is a service for
org.eclipse.smarthome.core.persistence.PersistenceManager
now.This service provides functions to: