You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
« Previous
Version 10
Next »
Introduction
The container for the OpenRAP 2.0 has been developed on top of ext-framework. The additions on top of ext-framework are:
- SDK's like Global, Settings & Download Manager
- While the ext-framework has been designed to add plugins within a single application, the use case of OpenRAP 2.0 is that each application is a plugin within OpenRAP. Therefore OpenRAP container has been built on top of ext-framework to support this capability
Following is the high level component diagram of OpenRAP 2.0
SDK
Following are SDK's built into the container.
Global
register = function (String pluginId, Object pluginConfig){};
get = function (String pluginId): pluginConfig {}
|
Telemetry SDK
register = function (String pluginId, String syncURL, Object config){};
getInstance = function (String pluginId) : TelemetrySDK {};
send = function (String event) : Promise {};
send = function (String[] events) : Promise {};
sendBatch = function (String batchEvent) : Promise {};
sendBatch = function (byte[] events) : Promise {};
list = function (String status?) : TelemetryPacket[] {};
get = function (String packetId): TelemetryPacket {};
sync = function () : Promise {};
getStatus = function () : Promise {};
|
Usage example
telemetrySDK = TelemetrySDK.getInstance( this .manifest.id);
telemetrySDK.send({...});
telemetrySDK.send([{...}]);
telemetrySDK.sync();
|
File SDK
getInstance = function (String pluginId) : FileSDK {};
mkdir = function (String path) : Promise {};
copy = function (String source, String dest) : Promise {};
mv = function (String from, String to) : Promise {};
rm = function (String file) : Promise {};
rmdir = function (String path) : Promise {};
zip = function (String path, String fileName) : Promise {};
unzip = function (String fileName, String path) : Promise {};
getAbsPath = function (String path) : String {};
watch = function (String[] paths, callback){};
|
Network SDK
isNetworkAvailable = function () : boolean {};
network:available
network:disconnected
|
Usage
EventManager.on( 'network:available' , function () {
});
|
Http SDK
getInstance = function (String pluginId) : HttpSDK {};
get = function (String url, Object options) : Promise {};
post = function (String url, Object data, Object options) : Promise {};
patch = function (String url, Object data, Object options) : Promise {};
delete = function (String url, Object options) : Promise {};
head = function (String url, Object options) : Promise {};
|
Download Manager
Following are the APIs for the download manager. The workflow of download manager is detailed out in the next few sections.
getInstance = function (String pluginId) : DownloadManager {};
download = function (String file, String path) : String {};
download = function (String[] files, String folder) : String {};
get = function (String downloadId) : DownloadObject {};
list = function (String status): DownloadObject[] {};
DownloadObject = {
id: String,
status: String,
createdOn: Date,
updatedOn: Date,
stats: {
totalFiles: Number,
downloadedFiles: Number,
totalSize: Number,
downloadedSize: Number,
},
files: [{
file: String,
source: String,
path: String,
size: Integer,
downloaded: Integer
}]
}
"download:complete"
EventManager.dispatch( "download:complete" , {
id: String,
files: [{
file: String,
source: String,
path: String,
size: Integer
}]
});
|
Settings SDK
getInstance = function (String pluginId) : SettingsSDK {};
put: function (String key, Object value) : Promise {};
get: function (String key) : Promise {};
|
Open Questions:
- Does encryption needs to be part of container or plugin
Database Schema
Registry
{
document: {
"_id" : String,
"config" : {}
},
index: []
}
|
Settings
{
document: {
"_id" : String,
"value" : Object
},
index: []
}
|
Telemetry
A document database is created for each plugin telemetry storage - <plugin_id>_telemetry
{
document: {
"_id" : String,
"event" : {}
},
index: []
}
|
TelemetryPackets
{
document: {
"_id" : String,
"pluginId" : String,
"status" : String,
"createdOn" : Date,
"updatedOn" : Date,
"size" : Number,
"events" : []
},
index: [pluginId, status, updatedOn]
}
|
DownloadQueue
{
document: {
"_id" : String,
"pluginId" : String,
status: String,
createdOn: Date,
updatedOn: Date,
stats: {
totalFiles: Number,
downloadedFiles: Number,
totalSize: Number,
downloadedSize: Number,
},
files: [{
file: String,
source: String,
path: String,
size: Integer,
downloaded: Integer
}]
},
index: [pluginId, status, updatedOn]
}
|
Folder Structure
Following is the folder structure of the container when it is installed on a dekstop/raspberrypi device/server
<app_base_dir>
/logs
|----/container.log
|----/crash.log
/<plugin_id>/
|----/files/
|--------/file1.ar
|----/ecars/
|--------/do_1234.ecar
|----/logs/
|--------/application.log
|--------/crash.log
|----/content/
|--------/<do_xxxxxx>/
|----/telemetry_archived/
|--------/<packet_id>.json
|
Download Manager
Below explains the process of downloading content when a user request for it, the steps are
- Download Manager is initialised with config and will be ready to take the request
- When a user request for the download Sunbird Ed Plugin forward request to download Queue
- If download manager is available it will download the content and once it is download
- It will raise an event and plugin will listen to that event
- With event data it will extract the ECAR and index the content in content database
At low level the download manager works as
- When it starts downloading it creates <filename>.sud and <filename>.<n>.partial(s) files, <filename>.sud file contains the meta data about file.
- If internet is disconnected or system got shut down then it will pause the download
- When the internet is connected again or system restarted it will read the file .sud and continue the download from where it left
- When the file is download completed then it combines all the partials and creates final ECAR file.
For more details you can refer su-downloader3
Telemetry Sync
Telemetry Events
<To be done>
Logging
<To be done>