The aggregation method redefinition

The aggregate function has the following prototype:
int MyScheduler::aggregate(corba_response_t* aggrResp, size_t max_srv,
                            const size_t nb_responses,
                            const corba_response_t* responses)

The aggregate method takes 4 arguments:

Two functions are defined to simplify the aggregation of the results:

typedef list<corba_server_estimation_t> ServerList;
ServerList CORBA_to_STL(const corba_response_t* responses, int nb_responses);
void STL_to_CORBA(ServerList &servers, corba_response_t* &aggrResp);
The first function converts the received CORBA sequence into a STL list. This function make the first aggregation of the results by marshaling all the sequences into one.

The second function converts a STL list into a CORBA sequence that can be transfer ed by DIET.

Then, an aggregate function should start by a call to the CORBA_to_STL function. The obtained list can then be sorted/filtered using all the STL list facilities. And to finish, the result list is computed by the STL_to_CORBA function.

Several macros are defined to simplify the sort of a STL list:

SORTFUN(name, metric)
SORTFUN_NB(name, metric, nb)
REV_SORTFUN(name, metric)
REV_SORTFUN_NB(name, metric, nb)
These macros allow the developer to automatically define a sort function using a metric value. For example, to define a sort function using the number of CPUs, the developer just has to declare:
The SORTFUN_NB macro is used for the multi-values metrics (for example the CPU cache for each CPU). The nb value designates which value has to be used to sort the list. The REV_* functions are used to sort in ascending order.

To see all the metrics available for the SORTFUN macro, see Section 9.5.4.

When a sort function has been defined, the developer can use the SORT macro to sort the STL list. For example with our compfun function:

SORT(serverList, compfun);
This call sorts the server STL list in decreasing order of the number of CPU.

The DIET Team - Mer 29 nov 2017 15:13:36 EST