-
Notifications
You must be signed in to change notification settings - Fork 2
Agent_Modes
What are the various modes that the agent goes through when answering requests.
TBD
All the various modes used during set processing can be confusing. Let's start with a simple state diagram: http://www.net-snmp.org/tutorial/tutorial-5/toolkit/mib_module/set-actions.jpg
Here is a brief overview of the reserve, free, action, undo and commit modes.
The purpose of SET_RESERVE1 is to try and detect invalid SET requests as soon as possible. If any of the columns are assigned an impossible value (wrong type, or out-of-range, etc), then the request fails.
The purpose of SET_RESERVE2 is to set up/allocate the data structure for a new row or perform any resource allocation needed for further processing (e.g. allocate memory or lock a database).
The purpose of SET_FREE is to undo anything done in the two SET_RESERVE passes, if some aspect of the request proves unacceptable. This means possibly releasing the data structure for a new row, if one was just been created. No action was performed, so no undo is needed.
SET_ACTION assigns the appropriate column values to the data structure for this row (either the new structure created in the SET_RESERVE2 step, or an existing row structure).
SET_UNDO reverses anything done in the two SET_RESERVE steps or SET_ACTION - called if some part of the SET_ACTION processing fails. This is similar to the SET_FREE processing, but also needs to reverse any newly assigned values.
The purpose of SET_COMMIT is to confirm that the processing of the SET request has completed successfully, and perform any "irreversible" actions. For example, committing database changes.
Note that there is no common final "I'm done" mode. You must keep track of what needs to be for the 3 final states (free, undo, commit). For example, all three of those modes may require you to release some resource, like a database lock.
see agent/helpers/baby_steps.c
/*
* Baby Steps Flow Chart (2004.06.05) *
* *
* +--------------+ +================+ U = unconditional path *
* |optional state| ||required state|| S = path for success *
* +--------------+ +================+ E = path for error *
***********************************************************************
*
* +--------------+
* | pre |
* | request |
* +--------------+
* | U
* +-------------+ +==============+
* | row |f|<-------|| object ||
* | create |1| E || lookup ||
* +-------------+ +==============+
* E | | S | S
* | +------------------>|
* | +==============+
* | E || check ||
* |<---------------|| values ||
* | +==============+
* | | S
* | +==============+
* | +<-------|| undo ||
* | | E || setup ||
* | | +==============+
* | | | S
* | | +==============+
* | | || set ||-------------------------->+
* | | || value || E |
* | | +==============+ |
* | | | S |
* | | +--------------+ |
* | | | check |-------------------------->|
* | | | consistency | E |
* | | +--------------+ |
* | | | S |
* | | +==============+ +==============+ |
* | | || commit ||-------->|| undo || |
* | | || || E || commit || |
* | | +==============+ +==============+ |
* | | | S U |<--------+
* | | +--------------+ +==============+
* | | | irreversible | || undo ||
* | | | commit | || set ||
* | | +--------------+ +==============+
* | | | U U |
* | +-------------->|<------------------------+
* | +==============+
* | || undo ||
* | || cleanup ||
* | +==============+
* +---------------------->| U
* |
* (err && f1)------------------->+
* | |
* +--------------+ +--------------+
* | post |<--------| row |
* | request | U | release |
* +--------------+ +--------------+
*
*/
Category:Agent