How to Add Resources Dynamically

Use this procedure when your application detects that a new resource has come online.

  1. Store an SSID for the resource in an array.

    This resource SSID has the following form:

    //:class.class//:res.resource

    For example, store the following SSID in an array named res_ids.

    //:class.app/util3//:res.inst/Customers

    This array of resource SSIDs is an argument to sstore_resource_add().

  2. Call sstore_resource_add() to add the resource metadata to the statistics repository.

    For example, if you had added Customers, Products, and Orders resources to the res_ids array, you could make the following call:

    sstore_resource_add(hdl, (const char **)res_ids, 3)

    An optional fourth argument enables you to include additional metadata for the resource. See the sstore_resource_add(3SSTORE) man page for details.

  3. Build the statistics array.

    Use the res_ids resource SSID array and the stats structure to dynamically create the ids statistics array. As in previous versions of this example, the ids statistics array is the array that you pass to sstore_data_attach() and use for updating the values of the statistics.