User Tools

Site Tools


content:activity:naf4

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
content:activity:naf4 [13/07/2014 20:11]
Andrew Bettison [PROGRESS REPORT] complete R13 Java API (add R3 and R11)
content:activity:naf4 [14/07/2014 19:17]
Andrew Bettison [COMPLETION REPORT] add test code coverage information to R14
Line 141: Line 141:
     * ''POST /restful/meshms/<SID>/<SID>/recv/<offset>/read'' advances the read-offset in a single conversation, to mark a single message (and all its predecessors) as read     * ''POST /restful/meshms/<SID>/<SID>/recv/<offset>/read'' advances the read-offset in a single conversation, to mark a single message (and all its predecessors) as read
  
-===== PROGRESS REPORT =====+===== COMPLETION REPORT ===== 
 + 
 +The work was completed on 14 July 2014, having been performed concurrently with three other contracts: 
 +  * [[naf5]] 
 +  * [[naf6]] 
 +  * [[openitp2]]
  
 ==== Preliminary work ==== ==== Preliminary work ====
 +
 +This contract drove several significant architectural improvements to [[:content:servaldna:]] and [[:content:servalmesh:]].
  
 == Security: SQL injections == == Security: SQL injections ==
Line 168: Line 175:
 == Re-organisation around RESTful API == == Re-organisation around RESTful API ==
 Henceforward the RESTful API will be the preferred (and eventually only) method for applications to use Rhizome and MeshMS. Henceforward the RESTful API will be the preferred (and eventually only) method for applications to use Rhizome and MeshMS.
-  * The existing Rhizome and MeshMS JNI API provided function-call entry points into the Serval DNA shared library +  * The existing JNI API for Rhizome and MeshMS was inferior: 
-  That meant that application processes opened and accessed the Rhizome database themselves, not via requests to the daemon +    * the JNI API provided function-call entry points into the Serval DNA shared library 
-  This sometimes caused database locking to block the daemon, which severely degraded responsiveness when starting a freshly-installed Batphone app in the presence of other devices holding lots of Rhizome content -- see [[https://github.com/servalproject/serval-dna/issues/1|Serval DNA issue #1]] +    * application processes opened and accessed the Rhizome database themselves, not via requests to the daemon 
-  The JNI API also required applications to be part of the same Android APK file, so that Android would run them all with the same User ID, so they could all access and modify the Rhizome database files+    this sometimes caused database locking to block the daemon, which severely degraded responsiveness when starting a freshly-installed Batphone app in the presence of other devices holding lots of Rhizome content -- see [[https://github.com/servalproject/serval-dna/issues/1|Serval DNA issue #1]] 
 +    all Android applications using MeshMS and Rhizome had to be bundled together in a single APK, so that Android would run them all with the same User ID, so they could all access and modify the Rhizome database files
   * Commit [[https://github.com/servalproject/serval-dna/commit/68dbaef38d03535271eed14a6da35323a0dd7a4f|68dbaef]] refactored the Java API to add a stateful object that holds an open connection to the daemon, and keep the Serval DNA RESTful interface independent from the JNI command interface   * Commit [[https://github.com/servalproject/serval-dna/commit/68dbaef38d03535271eed14a6da35323a0dd7a4f|68dbaef]] refactored the Java API to add a stateful object that holds an open connection to the daemon, and keep the Serval DNA RESTful interface independent from the JNI command interface
   * Commit [[https://github.com/servalproject/serval-dna/commit/82b13caac4c2386a096acc5c72ebde2b4871c245|82b13ca]] deprecated the existing MeshMS JNI API   * Commit [[https://github.com/servalproject/serval-dna/commit/82b13caac4c2386a096acc5c72ebde2b4871c245|82b13ca]] deprecated the existing MeshMS JNI API
Line 178: Line 186:
 == Serval DNA power consumption == == Serval DNA power consumption ==
 The final issue to be addressed was the CPU activity of the [[:content:servaldna:]] daemon whilst idle. The final issue to be addressed was the CPU activity of the [[:content:servaldna:]] daemon whilst idle.
-  * The Rhizome and MeshMS screens must function even when Serval Mesh services are not enabled +  * The previous implementation of the [[:content:servalmesh:|Serval Mesh app for Android]] did not have a continuously running daemon: 
-  * The previous implementation of the [[:content:servalmesh:|Serval Mesh app for Android]] did not require a continuously running daemon: +    * the daemon only ran while the "Enable Services" checkbox was ticked on the "Connect" menu 
-    * the daemon was only run while the "Enable Services" checkbox was ticked on the "Connect" menu +    * the daemon awoke periodically on *alarm* events (once per second) while running, even while the network was idle or no network interfaces were up 
-    * the daemon used timed *alarm* events to wake it at short intervals (once per second) while running, even while the network was idle or no network interfaces were up +    * this caused rapid battery drain while Serval Mesh networking was active, which was advised in the [[https://github.com/servalproject/batphone/blob/0.91/doc/RELEASE-0.91.md|Release Notes for 0.91]] 
-  * The new implementation implements all MeshMS operations using the RESTful HTTP interface (**[[#R15]]**), which requires a continuously running daemon +    * the JNI API (see above) accessed the Rhizome database directly in-process; it did not use the daemon, so the Rhizome and MeshMS screens functioned at all times 
-  This would mean that the new implementation would quickly drain the battery unless the [[:content:servaldna:]] CPU usage were close to zero while idle+  * The new implementation (**[[#R15]]**) implements MeshMS operations using the RESTful HTTP interface: 
 +    * this requires a continuously running daemon, or at least a daemon running while any Rhizome or MeshMS screen are active 
 +    this could quickly drain the battery simply by opening the app 
 +  * This necessitated improvements to the event scheduling sub-system within [[:content:servaldna:]]
 +    * only use CPU in response to real external events (user and network) 
 +    * only schedule timed wake-ups for externally imposed timing requirements such as network protocol time-outs
   * Commit [[https://github.com/servalproject/serval-dna/commit/6d4ad0e1505d8826cda024159892b82699e392c7|6d4ad0e]] improved the event alarm scheduler [[https://github.com/servalproject/serval-dna/blob/development/fdqueue.c|fdqueue.c]]:   * Commit [[https://github.com/servalproject/serval-dna/commit/6d4ad0e1505d8826cda024159892b82699e392c7|6d4ad0e]] improved the event alarm scheduler [[https://github.com/servalproject/serval-dna/blob/development/fdqueue.c|fdqueue.c]]:
     * a new kind of "lazy" alarm does not force the daemon process to wake     * a new kind of "lazy" alarm does not force the daemon process to wake
Line 192: Line 205:
     * starts the daemon as needed and keeps it running     * starts the daemon as needed and keeps it running
     * changing the "Enable Services" checkbox simply toggles a Serval DNA configuration option     * changing the "Enable Services" checkbox simply toggles a Serval DNA configuration option
 +  * This improvement has significant positive repercussions for other Serval products like [[:content:meshextender:]], by extending battery life towards the maximum practical limit
  
 ==== Implementation ==== ==== Implementation ====
Line 406: Line 420:
     * commit [[https://github.com/servalproject/serval-dna/commit/db8ee79a4ee11bc0ddf48e9c451fa813b9844851#diff-7|db8ee79]] added the new Rhizome Java API test script     * commit [[https://github.com/servalproject/serval-dna/commit/db8ee79a4ee11bc0ddf48e9c451fa813b9844851#diff-7|db8ee79]] added the new Rhizome Java API test script
     * commit [[https://github.com/servalproject/serval-dna/commit/c5d3069d823f52494ed5095529ab60fbdab0a8fd|c5d3069]] ensured that the JNI API library is always built by the ''make all'' command     * commit [[https://github.com/servalproject/serval-dna/commit/c5d3069d823f52494ed5095529ab60fbdab0a8fd|c5d3069]] ensured that the JNI API library is always built by the ''make all'' command
 +
 +The test code coverage for the new C source code created by this contract exceeds the average:
 +
 +^                        ^ Lines                ^^ Functions          ^^
 +| ''http_server.c''      |    70% |     927/1325 |  95.5% |      64/67 |
 +| ''meshms_restful.c''      89% |      316/355 |   100% |      21/21 |
 +| ''rhizome_restful.c''  |    82% |      410/500 |   100% |      24/24 |
 +^ Average for all Serval DNA source code                           ^^^^^
 +| ''*.c *.h''            |  72.2% |  17904/24796 |  81.9% |  1516/1851 |
 +
 +There are no code coverage statistics for the Java source code.
  
 **[[#R15]]** -- upgrade Serval Mesh app for Android (completed 25 June 2014) **[[#R15]]** -- upgrade Serval Mesh app for Android (completed 25 June 2014)
content/activity/naf4.txt · Last modified: 21/02/2016 22:40 by Andrew Bettison