Hi,
I wanted ideas on how to achieve this efficiently using C++ concept:-
I have a DB table that contains rows of endpoints (say IDs vs names). There is process say "A" that calls another process B's API to increment counters if an operation is performed by an endpoint.
DB table:-
Once this increment happens, (say that endpoint[a2] with ID=2 is using process A to execute an increment counter) the endpoint entry is made in B's shared memory.
So at this point here's the state of DB and shared memory maintained by B:-
DB table:-
B's shared mem:-
/*format*/
/*ID,endpoint_name,counter_value*/
2,a2,1
Now there is another third-party application that reads and displays the no. of endpoints (using SNMP 'get') that have involved in the increment operation, which it'd get from the B's shared mem directly.
For this it does the follwing:-
1) Get the row count (say x)
2) In a loop it keeps fetching data 'x times'
So the display in third-party application would be (ID is NOT displayed):-
EndPoint Name Counter Value |
-------------- ------------- |
a2__________1 |
Now if row with ID=2 (a2) in DB table is deleted and created again it is represented in DB as ID=4 (B's shared mem would be unaware of these events). So at this point here's the state of DB table:-
B's shared mem:-
/*format*/
/*ID,endpoint_name,counter_value*/
2,a2,1
Now say that endpoint[a2] with ID=4 is using process A to executes an increment counter the endpoint entry is again made in B's shared memory.
Now B's shared mem:-
/*format*/
/*ID,endpoint_name,counter_value*/
2,a2,1
4,a2,1
Also in third-party app:-
EndPoint Name Counter Value |
-------------- ------------- |
a2 __________ 1 |
a2 __________ 1 |
This creates multiple entries with same endpoint name!!
[Note:- Fetching is done with ID as index but in display it is not included]
For process B to update its shared mem from DB when an increment is executed will hit performance as DB dip is a costly operation.
Any suggestions buddies?