Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node decoding + Threading + Bulk upload #33

Closed
wants to merge 25 commits into from
Closed

Node decoding + Threading + Bulk upload #33

wants to merge 25 commits into from

Conversation

TrystanLea
Copy link

A start on adding threading to emonhub. This works with one dispatcher at the moment as I think it needs either a queue for each dispatcher or a pub/sub queue that handles this for us. At the moment I think the queue will share the data between dispatchers rather than duplicate the data which is the behaviour we want.

This pull request contains the node_decoder pull request too.

TrystanLea added 18 commits May 2, 2014 18:40
…ut for me

2014-05-02 18:37:38,343 INFO Serial RX:  10 49 0 47 0 203 0 183 12
was giving:
2014-05-02 18:37:38,345 DEBUG Data string: [[0,10,0,0,0,37662610412320084583014736539245998496614132666784207011840]]
Conflicts:
	src/emonhub_listener.py
…aking out at the point this is detected + addition of byte and correct handling of signed long
…ss dispatchers properly, tested uploading to two servers, turning off internet connection to remote, independent buffering, all seems to work
@TrystanLea
Copy link
Author

Ok, Im quite happy with this now, from brief testing its a working solution for:

  • Flexible decoding (probably best to discuss separately as part of the other pull request)
  • Threading so that data gaps are not created when a remote server is timing out, dispatching happens in its own thread separate from the listeners with a queue that links them.
  • Buffering and bulk sending: when a server cannot be reached the data is buffered as existing implementation but when the connection resumes a full bulk upload happens of all the data in one request rather than many individual requests. The bulk data is also sent in the body of a post request.

Im quite new to Python so interested to hear your more experienced thoughts on it.

- Allow for posting to different emoncms interfaces ie: input/bulk or node/multiple
- These minimal changes give full compatibility with remote based emoncms node interface if application needs this approach without bulking out emonhub with code duplication
@TrystanLea
Copy link
Author

Latest commit which I've bundled in here:

  • Allows for different default decoding types
  • Allows for posting to different emoncms interfaces ie: input/bulk or node/multiple with a simple settings property.
  • These relatively small changes give full compatibility with remote based emoncms node interface if application needs this approach without bulking out emonhub with code duplication

@Dave-McCraw
Copy link
Contributor

This is tricky for me to review. It would be helpful if we could break it down into separate pull requests:

  • refactor without adding node support
  • addition of node support
  • addition of multithreading

(I guess the last one could come in any order, whatever is most convenient. I'm slightly nervous about multithreading it "just like that" because I have plenty of experience of multithreading agony, maybe I'm being overly pessimistic!)

@Dave-McCraw
Copy link
Contributor

In fact, is there even a fourth thing in here? Just forwarding on the bytes?

I'll pick this up in #22 too

@Dave-McCraw Dave-McCraw added this to the v [future] milestone May 20, 2014
@Dave-McCraw Dave-McCraw mentioned this pull request May 20, 2014
@TrystanLea
Copy link
Author

I've separated out the node decoding and bulk upload leaving the changes for threading only https://github.com/emonhub/emonhub/pull/34/files

@TrystanLea TrystanLea changed the title Threading Node decoding + Threading + Bulk upload May 24, 2014
TrystanLea added 2 commits May 28, 2014 15:08
…osted to a server at once, designed to limit strain on remote server
@TrystanLea
Copy link
Author

Added the ability to set the max number of items that can be posted in one bulk upload, so that under conditions where the internet has been down for an extended time it doesnt try and send too much at once, if say emoncms.org is down for a day and hundreds of connected rpi's try and upload at once it might be too much, so this makes it possible to stage the upload.

@TrystanLea
Copy link
Author

Glyn and I are now testing this in our own homes on test systems to test its long term reliability. Will also try some tests with unplugging the ethernet for a few hours to see how well it posts the buffered data.

@pb66
Copy link
Contributor

pb66 commented May 30, 2014

(just for ref) http://openenergymonitor.org/emon/node/5239

@TrystanLea
Copy link
Author

Closing as node decoding and bulk upload is now done very nicely by @pb66's emonhub developments and I've opened another pull request with threading additions only.

@TrystanLea TrystanLea closed this Jul 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants