Robert,
I noticed a log message on the CVS list yesterday,
about documenting how to implement a non-caching version
of a container-based MfD module.
(I was a bit surprised to see that you'd applied this
to the 5-2-patches line as well, since I thought that was
currently in pre-release freeze, but that's by-the-by).
Anyway, I've also been looking at this issue recently, and
had come up with a slightly different approach, which I
thought I'd run past you to see what you think.
I presume that the effect of clearing the 'cache->enabled'
flag is simply to bypass all of the cache-related code.
It will still be there, but will never actually be called.
Is that correct?
I'm appending a new "mfd-access" file, that could be used
to generate code which omits all of the cache-related
processing altogether - generating a purely internal data
MfD-based MIB module, with consequentially simpler code.
(There's also a corresponding tweak to the interactive module).
I'm not sure whether this is the best way to handle
such a requirement, since the initialisation code is still
duplicated between the two. But there's not actually a
great deal of that, so it might not matter.
Anyway, have a look at this, and let me know what you think.
Dave
############################################################ -*- c -*-
###generic include for XXX. Do not use directly.
###
### $Id: mfd-access-container-defines.m2i,v 1.16 2004/10/18 02:56:55 rstory Exp
$
########################################################################
@if $m2c_mark_boundary == 1@
/** START code generated by $RCSfile: mfd-access-container-defines.m2i,v $
$Revision: 1.16 $ */
@end@
##//####################################################################
##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@if $m2c_processing_type eq 'h'@
void ${context}_container_init(netsnmp_container **container_ptr_ptr);
@end@ // m2c_processing_type eq 'h'
##//####################################################################
##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@if $m2c_processing_type eq 'c'@
/**
* (uncached) container overview
*
*/
/**
* container initialization
*
* @param container_ptr_ptr A pointer to a container pointer. If you
* create a custom container, use this parameter to return it
* to the MFD helper. If set to NULL, the MFD helper will
* allocate a container for you.
*
* This function is called at startup to allow you to customize certain
* aspects of the access method. For the most part, it is for advanced
* users. The default code should suffice for most cases. If no custom
* container is allocated, the MFD code will create one for your.
*
* @remark
* This would also be a good place to do any initialization needed
* for you data source. For example, opening a connection to another
* process that will supply the data, opening a database, etc.
*/
void
${context}_container_init(netsnmp_container **container_ptr_ptr)
{
DEBUGMSGTL(("verbose:${context}:${context}_container_init","called\n"));
if((NULL == cache) || (NULL == container_ptr_ptr)) {
snmp_log(LOG_ERR,"bad params to ${context}_container_init\n");
return;
}
/*
* If you're not using the container-cache approach, it's likely
* that you'll want to set up the initial contents here, so
* create a suitable custom container.
* If you do not need to do this, you can delete this line,
* and a container will be created automatically for you.
*/
*container_ptr_ptr = netsnmp_container_find("table_container");
/*
* TODO:345:A: Set up initial table contents.
*/
} /* ${context}_container_init */
@end@ // m2c_processing_type eq 'c'
########################################################################
##//####################################################################
##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@if $m2c_processing_type eq 'i'@
/**
* @internal
* initialize the iterator container with functions or wrappers
*/
void
_${context}_container_init(${context}_interface_ctx *if_ctx)
{
DEBUGMSGTL(("internal:${context}:_${context}_container_init","called\n"));
${context}_container_init(&if_ctx->container);
if(NULL == if_ctx->container)
if_ctx->container =
netsnmp_container_find("${context}:table_container");
if(NULL == if_ctx->container) {
snmp_log(LOG_ERR,"error creating container in "
"${context}_container_init\n");
return;
}
} /* _${context}_container_init */
@end@ // m2c_processing_type eq 'i'
########################################################################
##//####################################################################
##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@if $m2c_processing_type eq 'r'@
##
containersummary
------------------------
The (uncached) container data access code is for cases when you
want to hold your data purely within the agent/sub-agent.
... to be continued...
########################################################################
Updating the Index
------------------
TODO : update index for the raw data
FUNC : ${context}_indexes_set
WHERE: ${context}_data_access.c
This is a convenience function for setting the index context from
the native C data. Where necessary, value mapping should be done.
@if $mfd_readme_verbose == 1@
This function should update the table index values (found in
tbl_idx) for the given raw data.
@end@
@end@ // m2c_processing_type eq 'r'
########################################################################
##//####################################################################
@if $m2c_mark_boundary == 1@
/** END code generated by $RCSfile: mfd-access-container-defines.m2i,v $
$Revision: 1.16 $ */
@end@
Index: mfd-interactive-setup.m2c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/local/mib2c-conf.d/mfd-interactive-setup.m2c,v
retrieving revision 1.7
diff -u -r1.7 mfd-interactive-setup.m2c
--- mfd-interactive-setup.m2c 24 Dec 2004 14:05:09 -0000 1.7
+++ mfd-interactive-setup.m2c 7 Jan 2005 13:29:07 -0000
@@ -164,19 +164,29 @@
1) container-cached : [DEFAULT] This access method uses a
netsnmp_container to keep track of the indexes (and data, usually)
- for each row. Thi method is best for:
- - Internal data (maintained by the agent)
+ for each row, and will refresh the contents as required.
+ This method is best for:
- External data (maintained by another process)
- Access speed is important
- Sufficient memory exists to cache all indexes
- 2) unsorted-external : This access method iterates over all of your data
+ 2) container: (uncached) This access method also uses a
+ netsnmp_container to keep track of the indexes and data
+ for each row, but maintains the contents throughout the
+ life of the agent. This method is best for:
+ - Internal data (maintained by the agent)
+ - Access speed is important
+ - Sufficient memory exists to cache all indexes
+
+ 3) unsorted-external : This access method iterates over all of your data
to find the row with the appropriate index. This method is best for
- External data (maintained by another process)
- Using less memory is more important than access speed
@ prompt $ans Select your choice : @
@ if $ans == 2@
+@ eval $m2c_temp_table_access = "container"@
+@ elseif $ans == 3@
@ eval $m2c_temp_table_access = "unsorted-external"@
@ else@
@ eval $m2c_temp_table_access = "container-cached"@