Deleting all rows in MibTable

Alex Finogenov afinogenov____malibunet.com
Thu Mar 21 20:12:46 CET 2002


Kjersti,
 
A good question. This code should be called after the completion of each request, or before the start of processing of the next request. Since I am not aware of any public or protected MibTable method except MibTable::update() that can help me to accomplish this, I take care of the cleanup in the overloaded MibTable::update().
 
Since MibTable::update() may be invoked more than once during processing of a request, I implemented a state object that keeps track of a few things, including whether the table is being processed in the same request or in a new one. This is determined using Request::get_request_id(). If it's a new request, the cleanup of the table is called.
 
This is a rather "lazy" approach (i.e. a table is not cleaned up until the next request), so it is important to ensure a proper destruction when the agent is shut down. Your requirements may demand a more proactive approach. If anybody knows of a better way to handle this, I'd like to learn about it.
 
I guess your "main loop" approach could work if you cleanup ALL tables. This could be somewhat wasteful, unless you optimize this by keeping tables' states and trashing only those ones that have been touched in a previous request.
 
Alex
 
 

-----Original Message-----
From: Kjersti Grønnevik [mailto:kgr____morecom.no]
Sent: Thursday, March 21, 2002 12:27 AM
To: Alex Finogenov
Cc: agentpp-dl____agentpp.com
Subject: RE: Deleting all rows in MibTable


Hi Alex,
 
Where do I put this code?
I wrote it in the main function after a request has been processed, but it's called before the request process has finished.
 
........
while (run) {
 
  req = reqList->receive(2);
 
  if (req) {    
    mib->process_request(req);
    lvAptEntry *ae = lvAptEntry::instance;
    ae->removeAllAPTEntries();
    //char buffer[200];
    //sprintf( buffer, "main.removeRows..(.)" );
    Log::addEvent( Log::INFO, "main.removeRows ...", LOC ); //only used for debugging...
  }
  else {
      mib->cleanup();
  }
 }
 delete mib;
 return 0;
}
 
void lvAptEntry::removeAllAPTEntries()
{
   //remove old rows from MibTable, the aptEntry class inheritates from MibTable
  clear();
  delete_rows.clearAll();
  notready_rows.clearAll();
}

Hope this is understandable and thanks so much for great help so far!
 
Regards,
Kjersti

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.agentpp.org/pipermail/agentpp/attachments/20020321/bddad45e/attachment.htm 


More information about the AGENTPP mailing list