Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

MapDb persistence #2264

Merged
merged 1 commit into from
Apr 7, 2015
Merged

MapDb persistence #2264

merged 1 commit into from
Apr 7, 2015

Conversation

JSurf
Copy link
Contributor

@JSurf JSurf commented Mar 9, 2015

A simple persistence provider that only saves the last value. Intention is to use this for "reloadOnStartup" items because all other presistence options have their drawbacks if values are only needed for reload

They:
a) grow in time
b) require complex installs (mysql, influxdb, ...)
c) rrd4j can't store all item types

See:
https://groups.google.com/forum/#!category-topic/openhab/umfFKg5uAM4

@buildhive
Copy link

openhab » openhab #2475 SUCCESS
This pull request looks good
(what's this?)

@paulianttila
Copy link
Contributor

Great work Jens!

Few additions which would make me happy (at least). Many of us is running OH in flash based systems, so to minimize unnecessary writes to flash based systems.

  1. Commit db to file only if item value is changed. Maybe this should be configurable.
  2. Introduce commit interval, which define how often db is saved to the file. So updated items are normally just stored to memory map and after commit interval is exceeded, map is saved to file (if any items are updated).

-Pali

@JSurf
Copy link
Contributor Author

JSurf commented Mar 9, 2015

  1. should be easy, will implement this

i have to think a bit more about 2) Calling commit in an extra thread sounds a little arkward.

You could workaround this requirement with the persistence configuration and define a time based strategy, so i'm not sure if code in the persistence module is required.

// persistence strategies have a name and a definition and are referred to in the "Items" section
Strategies {
    everyFiveMinutes : "*/5 * * * * ?"

    // if no strategy is specified for an item entry below, the default list will be used
    default = everyChange
}

/* 
 * Each line in this section defines for which item(s) which strategy(ies) should be applied.
 * You can list single items, use "*" for all items or "groupitem*" for all members of a group
 * item (excl. the group item itself).
 */
Items {
    * : strategy = everyFiveMinutes, restoreOnStartup   
}

@paulianttila
Copy link
Contributor

  1. Timer should be enough, I think? When item (any one) is updated, start timer if it's not already running. And when persistence service is shutdown, store to file if map is "dirty".

@teichsta teichsta added this to the 1.7.0 milestone Mar 12, 2015
@teichsta
Copy link
Member

  1. please keep in mind that you'd have to a) retain the old state as member variable or b) query the old State from the Service before committing the old c) implement a mixture of both … i would not consider that too easy
  2. using a timer seems to me an appropriate approach. See Db4oPersistenceService where i've implemented such a time already.

@JSurf please keep us posted when you'd consider this PR "mergeable".

Thanks, Thomas E.-E.

@JSurf
Copy link
Contributor Author

JSurf commented Mar 12, 2015

Thanks for the feedback, will keep you updated about the progress

@buildhive
Copy link

openhab » openhab #2525 SUCCESS
This pull request looks good
(what's this?)

@JSurf
Copy link
Contributor Author

JSurf commented Mar 17, 2015

Current version seems to work fine on fast systems, but hung openhab on my raspberry while starting up. Maybe i have hit another "startup timing"-bug on slow hardware

@JSurf
Copy link
Contributor Author

JSurf commented Mar 19, 2015

Wanted to dive deeper in this, and tried again on my raspberry pi. This time it worked flawlessly. Don't know what happened last time. so i would be happy if you could review/comment my latest changes @teichsta @paulianttila

@AcidReptile
Copy link

Works fine as far as I can judge. Thanks, useful binding.

Bundle-ManifestVersion: 2
Bundle-Name: openHAB MapDB Persistence Bundle
Bundle-SymbolicName: org.openhab.persistence.mapdb
Bundle-Version: 1.6.2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change version to 1.7.0.qualifier

@buildhive
Copy link

openhab » openhab #2605 SUCCESS
This pull request looks good
(what's this?)

@JSurf
Copy link
Contributor Author

JSurf commented Mar 23, 2015

@AcidReptile
Copy link

Do not forget that user need to create folder %openhabdir%/etc/mapdb manually. Otherwise service is not working.

@theoweiss
Copy link
Member

Meanwhile there was a decision to rename openhab.userdata to smarthome.userdata for openHAB2 compatibility reasons. Therefore you should adapt the plugin accordingly.

@teichsta
Copy link
Member

teichsta commented Apr 1, 2015

… and please squash all commits into one. Thanks, Thomas E.-E.

@JSurf
Copy link
Contributor Author

JSurf commented Apr 6, 2015

Will have a look soon

@JSurf
Copy link
Contributor Author

JSurf commented Apr 7, 2015

Changed openhab.userdata to smarthome.userdata, added code to automatically create mapdb folder when not available and squashed to one commit

@buildhive
Copy link

openhab » openhab #2700 SUCCESS
This pull request looks good
(what's this?)

@buildhive
Copy link

openhab » openhab #2701 SUCCESS
This pull request looks good
(what's this?)

teichsta added a commit that referenced this pull request Apr 7, 2015
Initial contribution of the MapDb queryable Persistence Service
@teichsta teichsta merged commit f17a2ae into openhab:master Apr 7, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants