On this page

BangDB NotificationManager

BangDB Notification Manager Type

Client API for building apps

BangDB Notification Manager provides ways to create necessary constructs to deal with streams in time-series manner. It allows users to create stream, ingest data, define processing logic so that continuous ingestion and analysis can go on in automated manner.

C++

Java

To get instance of notification manager

BangDB Notification Manager (BangDBEnv *env, int nthreads = 4); 
This returns an instance of notification manager given reference to BangDBEnv and number of threads that should be given to the manager to manage the notifications.
See BangDBEnv for more details on the db environment

To create or register a notification
int registerNotification(const char *notif_meta); 
It takes notification metadata as input. Example of notification metadata
{
   "notifid":12345,
   "name":"notif1",
   "msg":"users msg",
   "pri":1,
   "mailto":[],
   "endpoints":[
      "http://192.168.1.3:10101/account"
   ],
   "schemaid":1234,
   "freq":1
}
It returns -1 for error else 0

To drop or deregister a notification
void deregisterNotification(long notifid, short state);
state = 0 means pause, 1 means activate, -1 means delete completely.
notifid is the unique id which the user has provided while registering the notification
This api puts the notification in the queue for processing
int put(long notifid, long pkts, long orig_streamid, const char *notif); 
pkts is the pk (timestamp) of the data which is in stream
This checks if notification is needed or not and if needed, then it queues the notifid for further work.
It return 0 for success
To get a list for notification generated based on given condition and filter query. This is exactly similar to scanDoc on BangDBTable. Please see DataQuery for more details on effective and right way of scan
ResultSet *scanDoc(
   ResultSet *prev_rs,
   FDT *pk_skey = NULL, 
   FDT *pk_ekey = NULL, 
   const char *idx_filter_json = NULL, 
   ScanFilter *sf = NULL
);
It returns ResultSet if successful else NULL

To get a list of registered notifications, call this function. This takes filter query and can do recursive scans. See DataQuery for more details
ResultSet *scanRegisteredNotif(
   ResultSet *prev_rs,
   FDT *pk_skey = NULL,
   FDT *pk_ekey = NULL,
   const char *idx_filter_json = NULL,
   ScanFilter *sf = NULL
);
It returns NULL for error

To close Notification Manager
void close Notification Manager (CloseType ctype = DEFAULT_AT_CLIENT); 
ClosedType is enum with following values;

DEFAULT_AT_CLIENT,
CONSERVATIVE_AT_SERVER,
OPTIMISTIC_AT_SERVER,
CLEANCLOSE_AT_SERVER,
SIMPLECLOSE_AT_SERVER,
DEFAULT_AT_SERVER;

Please see more on this at bangdb common

 

To create NotificationManager object

public BangDBNotificationManager(BangDBEnv bdbenv) 
This returns an instance of notification manager given reference to BangDBEnv and number of threads that should be given to the manager to manage the notifications.
See BangDBEnv for more details on the db environment

To register a notification
public int registerNotification(String notif_meta) 
Notif_meta is a json string which looks like:
{
   "notifid":12345,
   "name":"notif1",
   "msg":"users msg",
   "rule":"notification rule/condition",
   "pri":1,
   "mailto":[],
   "endpoints":[],
   "schemaid":1234,
   "freq":1
}
It returns -1 for error else 0

To de-register or delete a registered notification
public int deregisterNotification(long notifid, short state) 
The notifid is unique id provided by user when the notification was registered and state = 0 means pause, 1 means activate, -1 means delete completely.

This api puts the notification in the queue for processing.
public int put(long notifid, long pks, long orig_strmid, String notif) 
pkts is the pk (timestamp) of the data which is in stream. This checks if notification is needed or not and if needed, then it queues the notifid for further work. Queued item must be sent to the respective destination.
If it doesn’t need to send the notification then it calls send_notification with op = 0 to update the cnt, lts etc. and returns – it doesn’t queue

To get the list for notification generated based on given condition and filter query. This is exactly similar to scanDoc on BangDBTable. Please see DataQuery for more details on effective and right way of scan
public ResultSet scanRegisteredNotif(
  ResultSet prev_rs,
  long k1,
  long k2,
  String idx_filter_json,
  ScanFilter sf
)
To close the notification manager
public int closeNotificationManager(CloseType closetype) 
Here, CloseType is an enum with values

DEFAULT_AT_CLIENT,
CONSERVATIVE_AT_SERVER,
OPTIMISTIC_AT_SERVER,
CLEANCLOSE_AT_SERVER,
SIMPLECLOSE_AT_SERVER,
DEFAULT_AT_SERVER

 

Was this article helpful to you? Yes No