Recent Changes - Search:

edit SideBar

Monitoring

Monitoring

In order to check the behavior of the accessors in a running swarmlet, monitoring routines are added. For this, an object monitor is added as a property of an accessor during the construction.

        this.monitor = {};

The monitor object is composed of a number of objects having the following structure:

{      
    'eventName': {
        'count' : number,
        'firstOccurrenceDate' : date,
        'latestOccurrenceDate' : date  
     }
}

Therefore, for a given event, we record the number of occurrences, as well as the date and time of the first and last calls. If the accessor is top level, composite, extended or implemented, the possible events are: initialize, reactStart, reactEnd and wrapup. If the accessor is mutable, then an additional event can be recorded which is reify.

Implementation

Two functions are added for this purpose. The first one is the prototype function that updates the monitoring information (count, date/time of the first event and date/time of the last event). The event name is passed as a parameter.

Accessor.prototype.updateMonitoringInformation = function(info)

For visualization and analysis purpose, the function getMonitoringInformation() is exported by commonHost. This function return an object of objects. Each object (referenced by the accessor name) contains:

  • the accessor type (mutable, top level, extended, implemented),
  • and all the monitoring information.
function getMonitoringInformation()

Web Service on Node for monitoring information retrieval

A web service running on Node returns the monitoring information of all accessors in JSON format. In order to test this service, you need first to un-comment the code in the bottom of nodeHost.js file. After running the swarmlet on a node host, it is possible to open, from the browser, the following URL: http://127.0.0.1:8082/monitor/. A JSON object is displayed. It shows for each accessor: the name, the 'type'and all the monitoring information that are stored.

Below is the code for the web service creation:

var http = require('http');
var url = require('url');

// Create a server
http.createServer(function (request, response) {

        var reqParts = request.url.split("/");

        console.log(reqParts);

        if (reqParts[1] == "monitor") {
                // HTTP Status: 200 : OK
                // Content Type: text/plain
                response.writeHead(200, {'Content-Type': 'text/html'});
                // Write the content of the file to response body

                //console.log(commonHost.getMonitoringInformation());

                // Retrieve all monitoring information
                var allMonitoringInformation = commonHost.getMonitoringInformation();

                // Parse the elements and send them one by one
                Object.keys(allMonitoringInformation).forEach(function (accName) {
                        var accMonitoringInformation = {};
                        accMonitoringInformation[accName] = allMonitoringInformation[accName];
                        console.log(JSON.stringify(accMonitoringInformation));
                        response.write(JSON.stringify(accMonitoringInformation));
                });
        } else {
                response.writeHead(404, {'Content-Type': 'text/html'});
                response.write("Hello, nothing received!");
        }
        // Send the response body
        response.end();

}).listen(8082);

See Also

Edit - History - Print - Recent Changes - Search
Page last modified on April 14, 2017, at 05:16 am