An example is present in the DIET distribution to illustrate the usage of the plugin scheduler functionality; this code is available in the directory

A DIET server and client corresponding to a simulation of a database research application are provided. If the construction of examples was enabled during DIET configuration, two binaries server and client will be built in this directory. Having deployed a DIET agent hierarchy, the server may be instantiated: where <DB> are string(s) that represent the existence of a particular database at the SeD 's site. A client would pose a query against a set of databases: The application uses the plugin scheduling facility to prioritize the existence of databases in selecting a server, and thus, the expected result is that one of the SeD s with the fewest number of database mismatches will be selected.

In the main function of the server.c file, the following block of code (a) specifies the use of the priority aggregator for this service, (b) declares a performance estimation function to supply the necessary data at request-time, and (c) defines the order of precedence of the performance values (i.e., minimizing the number of database mismatches, and then maximizing the elapsed execution time).

    /* new section of the profile: aggregator */
    diet_aggregator_desc_t *agg;
    agg = diet_profile_desc_aggregator(profile);

    /* for this service, use a priority scheduler */
    diet_aggregator_set_type(agg, DIET_AGG_PRIORITY);          /* (a) */

    /* install our custom performance function */
    diet_service_use_perfmetric(performanceFn);                /* (b) */

    /* define the precedence order */
    diet_aggregator_priority_minuser(agg, 0);                  /* (c) */
    diet_aggregator_priority_max(agg, EST_TIMESINCELASTSOLVE); /* (c) */
The performance function performanceFn is defined as follows:
static void performanceFn(diet_profile_t* pb, estVector_t perfValues);


** performanceFn: the performance function to use in the DIET
**   plugin scheduling facility
static void
performanceFn(diet_profile_t* pb, estVector_t perfValues)
  const char *target;
  int numMismatch;

  /* string value must be fetched from description; value is NULL */
  target = (diet_paramstring_get_desc(diet_parameter(pb, 0)))->param;
  numMismatch = computeMismatches(target);

  ** store the mismatch value in the user estimate space,
  ** using tag value 0
  diet_est_set(perfValues, 0, numMismatch);

  /* also store the timestamp since last execution */
  diet_estimate_lastexec(perfValues, pb);
The function computeMismatches (defined earlier in server.c) calculates the number of requested databases that are not present on the SeD making the evaluation. Together, these two code segments serve to customize the generation of performance information and the treatment of these data in the context of the simulated database search. Finally, it should be noted that the existence of a plugin scheduler is completely transparent to the client, and thus client code need not be changed.

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