How does a cache handler work? - SNMP

This is a discussion on How does a cache handler work? - SNMP ; Hi! I'm trying to implement a cache for some scalars. Therefore I'm trying to understand how a cache handler works and interacts with the other handlers. I'm especially interested in understanding how the data from the cache is propagated to ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: How does a cache handler work?

  1. How does a cache handler work?

    Hi!

    I'm trying to implement a cache for some scalars. Therefore I'm trying
    to understand how a cache handler works and interacts with the other
    handlers. I'm especially interested in understanding how the data from
    the cache is propagated to the other handlers

    Can someone please explain this or give me some pointers?

    Jörg



    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    Net-snmp-users mailing list
    Net-snmp-users@lists.sourceforge.net
    Please see the following page to unsubscribe or change other options:
    https://lists.sourceforge.net/lists/...net-snmp-users


  2. Re: How does a cache handler work?

    >>>>> On Thu, 02 Oct 2008 21:21:04 +0000, Jörg Westheide said:

    JW> I'm trying to implement a cache for some scalars. Therefore I'm trying
    JW> to understand how a cache handler works and interacts with the other
    JW> handlers. I'm especially interested in understanding how the data from
    JW> the cache is propagated to the other handlers

    JW> Can someone please explain this or give me some pointers?

    I'd look at an example. Say the mibII/udpTable.c file is a good
    example.

    Also, the API documentation is at:

    http://www.net-snmp.org/dev/agent/gr...__handler.html

    --
    Wes Hardaker
    Sparta, Inc.

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    Net-snmp-users mailing list
    Net-snmp-users@lists.sourceforge.net
    Please see the following page to unsubscribe or change other options:
    https://lists.sourceforge.net/lists/...net-snmp-users


  3. Re: How does a cache handler work?

    Hi Wes!

    > I'd look at an example. Say the mibII/udpTable.c file is a good
    > example.


    As far as I understood this example uses a global variable to store the
    cache's data. Is this the usual way? I'd expect a reference to the
    cache's data to be passed to the (scalar) handler. Where can I find
    such a reference from inside the handler?

    > Also, the API documentation is at:
    >
    > http://www.net-snmp.org/dev/agent/gr...__handler.html


    I know that one and IMO it leaves many questions open. Especially how
    the cache works and should/can be used.

    Jörg


    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    Net-snmp-users mailing list
    Net-snmp-users@lists.sourceforge.net
    Please see the following page to unsubscribe or change other options:
    https://lists.sourceforge.net/lists/...net-snmp-users


  4. Re: How does a cache handler work?

    2008/10/2 Jörg Westheide :
    > I'm trying to implement a cache for some scalars. Therefore I'm trying
    > to understand how a cache handler works and interacts with the other
    > handlers. I'm especially interested in understanding how the data from
    > the cache is propagated to the other handlers
    >
    > Can someone please explain this or give me some pointers?


    The basic idea of the cache helper is to separate out the
    loading of MIB data (typically from some underlying system)
    from the task of using that data to process an SNMP request.

    So the data is loaded by a "cache_load" routine (which is invoked
    by the cache helper handler), and then used in the normal end-user
    handler routine.

    The cache helper itself is only really concerned with deciding when
    the data should be loaded (or re-loaded). It doesn't care what
    this data is (a single scalar, a group of scalars, one or more
    tables, or some combination of these). Neither does it dictate
    how the data should be passed from the cache_load routine
    to the end-handler.

    One possibility is to use the 'vmagic' parameter of the cache_load
    routine. This is an opaque pointer, which is made available to
    the handler routine.

    Another possibility is to use the 'magic' field of the 'cache' parameter.
    This is also an opaque pointer, which is again made available to
    the handler routine. (In fact, 'vmagic' is exactly the same as
    'cache->magic', so the end-handler would use the same approach
    in either case)

    This is the approach used in 'mibgroup/agent/extend.c'
    It works best when the data is only used by the end-handler
    routine, so would be suitable for implementing scalar objects
    (individually, or as a group).


    Another possibility is for the cache_load routine to use suitable
    APIs calls to populate the data structures used by the MIB module.

    The advantage of this approach is that the data is then available
    to the *whole* of the handler chain, including table helpers, which
    might need to use this information for intermediate processing.
    There are examples of this style in the current development trunk,
    in some of the recent HostRes rewrites.


    Another possibility is to use a private data structure, shared
    between the cache_load routine and the end handler. This is
    perhaps not the cleanest approach from a coding purist's point
    of view, but it's simple and it works.


    Fundamentally, as long as the two user-provided routines
    (cache_load and the final handler) agree how to communicate
    the data between them, then the cache helper doesn't care
    how this is done.

    Dave

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    Net-snmp-users mailing list
    Net-snmp-users@lists.sourceforge.net
    Please see the following page to unsubscribe or change other options:
    https://lists.sourceforge.net/lists/...net-snmp-users


  5. Re: How does a cache handler work?

    Hi Dave!

    Thank you for this overview. It really should be made a part of the
    documentation

    > Another possibility is to use the 'magic' field of the 'cache'
    > parameter. This is also an opaque pointer, which is again made
    > available to the handler routine.


    Can you please tell me where this pointer is made available to the
    handler routine?
    While setting the pointer is easy to spot in the extend.c you mentioned
    I wasn't able to locate the access to the cache in a handler routine

    > Another possibility is to use a private data structure, shared
    > between the cache_load routine and the end handler. This is
    > perhaps not the cleanest approach from a coding purist's point
    > of view, but it's simple and it works.


    Well, it works at least as long as there are no multi threading issues
    (second thread updating the cache before the first one finished getting
    the data from the cache).
    Are such multi threading issues somehow prevented?

    Jörg


    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    Net-snmp-users mailing list
    Net-snmp-users@lists.sourceforge.net
    Please see the following page to unsubscribe or change other options:
    https://lists.sourceforge.net/lists/...net-snmp-users


+ Reply to Thread