API structure and algorithm for generating Device Arrangement hierarchy

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

API structure and algorithm for generating Device Arrangement hierarchy

Nuwan Jayawardene
Hi all,

As a component of my project (discussed in the mail thread "Metadata model for supporting edge nodes in an IoT deployment") it is required to create an API that would return the structure of a Device Organization connected to the IoT Server.

When being enrolled, the agents of each device informs the server who their parent is. Both the deviceID and the parentID of the device being enrolled are saved into a table at the time of enrollment. The structure of which is as follows;

deviceIDdeviceNameparentIDlastContactstateisGateway













As shown the table structure is such that the parentID is saved against the deviceID.
When generating the JSON hierarchy it was decided to take a layer-by-layer approach rather a depth-first approach. 

As such, the system will maintain 3 arrays;
1) An array that creates the hierarchy and returns it at program completion
2) An array to hold a list of an upper/parent device layer temporarily
3) An array to hold a list of a lower/child device layer temporarily.

The algorithm for the hierarchy generation is as follows depicted in a flowchart;

Inline image 2

The compromise of this algorithm would be increased complexity due to having 3 arrays. Furthermore, another downside is that DB calls will be going out each time an iteration happens.
Currently working on reducing the complexity and possibly DB calls as well.

Suggestions and feedback are appreciated.

--
Nuwan Jayawardene
Software Engineering Intern
WSO2, Inc.:http://wso2.com
lean.enterprise.middleware
Mobile  :- <a href="tel:+94%2071%20181%203299" value="+94711813299" target="_blank">+94 71 1813299


_______________________________________________
Architecture mailing list
[hidden email]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
Reply | Threaded
Open this post in threaded view
|

Re: API structure and algorithm for generating Device Arrangement hierarchy

Nuwan Jayawardene
UPDATE: On the suggestion of @Charitha would be trying out a single array based implementation using a TreeMap

On Mon, Dec 18, 2017 at 11:37 AM, Nuwan Jayawardene <[hidden email]> wrote:
Hi all,

As a component of my project (discussed in the mail thread "Metadata model for supporting edge nodes in an IoT deployment") it is required to create an API that would return the structure of a Device Organization connected to the IoT Server.

When being enrolled, the agents of each device informs the server who their parent is. Both the deviceID and the parentID of the device being enrolled are saved into a table at the time of enrollment. The structure of which is as follows;

deviceIDdeviceNameparentIDlastContactstateisGateway













As shown the table structure is such that the parentID is saved against the deviceID.
When generating the JSON hierarchy it was decided to take a layer-by-layer approach rather a depth-first approach. 

As such, the system will maintain 3 arrays;
1) An array that creates the hierarchy and returns it at program completion
2) An array to hold a list of an upper/parent device layer temporarily
3) An array to hold a list of a lower/child device layer temporarily.

The algorithm for the hierarchy generation is as follows depicted in a flowchart;

Inline image 2

The compromise of this algorithm would be increased complexity due to having 3 arrays. Furthermore, another downside is that DB calls will be going out each time an iteration happens.
Currently working on reducing the complexity and possibly DB calls as well.

Suggestions and feedback are appreciated.

--
Nuwan Jayawardene
Software Engineering Intern
WSO2, Inc.:http://wso2.com
lean.enterprise.middleware
Mobile  :- <a href="tel:+94%2071%20181%203299" value="+94711813299" target="_blank">+94 71 1813299




--
Nuwan Jayawardene
Software Engineering intern
WSO2, Inc.:http://wso2.com
lean.enterprise.middleware
Mobile  :- +94 71 1813299


_______________________________________________
Architecture mailing list
[hidden email]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture