Functions
The following functions may be used in the aggregation APL code. All functions described in the Analysis Agent section in the Desktop user's guide are also available.
The following functions for aggregation APL code described here are:
sessionMirror - Couchbase Storage Only
This function retrieves a list of sessions from the storage specified by the Mirror Profile.
list<session> sessionMirrors ( session)
Parameter | Description |
---|---|
| This is a built-in variable. For information about |
Returns | A list of mirror sessions. Note! The return value always contains one element. The use of the |
Example - Using sessionMirror
sessionInit { session.anum = input.anum; session.bnum = input.bnum; session.total_duration = 0; } consume { session.total_duration = session.total_duration + input.duration; sessionTimeout(session, 3600); //Get mirror sessions list<any> allMirrorSessions = sessionMirrors(session); // Do not use sessionMirrorLastErrorCode // in asynchronous mode. if (0 == sessionMirrorLastErrorCode()) { Default.session.session aggregateTotal = udrClone(session); aggregateTotal.total_duration = session.total_duration + getTotalDuration(allMirrorSessions); debug(aggregateTotal.total_duration); } else { logError("sessionMirrorLastErrorCode:" + sessionMirrorLastErrorCode() + "sessionMirrorLastErrorMessage:" +sessionMirrorLastErrorMessage()); } } timeout{ list<any> allMirrorSessions = sessionMirrors(session); // Do not use sessionMirrorLastErrorCode // in asynchronous mode. if (0 == sessionMirrorLastErrorCode()) { Default.session.session aggregateTotal = udrClone(session); aggregateTotal.total_duration = session.total_duration + getTotalDuration(allMirrorSessions); debug(aggregateTotal); } else { logError("sessionMirrorLastErrorCode:" + sessionMirrorLastErrorCode() + "sessionMirrorLastErrorMessage:" +sessionMirrorLastErrorMessage()); } } int getTotalDuration( list<any> allSessions) { int total_duration = 0; if (1 == listSize(allSessions)) { Default.session.session s = (Default.session.session)listGet(allSessions, 0); total_duration = s.total_duration; } return total_duration;
sessionMirrorLastErrorCode - Couchbase Storage Only
This function returns the error code from the last call to sessionMirrors
function.
Note!
You should only use sessionMirrorLastErrorCode
when asynchronous mode is disabled, which is the default setting. In asynchronous mode, errors are handled by the Aggregation agent and are not available in APL. For more information about using asynchronous mode, see Aggregation Agent in the Desktop user's guide.
Since sessionMirrors
does not return error codes and generally does not cause runtime errors, sessionMirrorLastErrorCode
or sessionMirrorLastErrorMessage
should be called after each operation to validate success.
int sessionMirrorLastErrorCode ()
Parameter | Description |
---|---|
Returns | 0 - All operations were successful. |
sessionMirrorLastErrorMessage - Couchbase Storage Only
This function returns the error message from the last call to sessionMirrors
function.
Note!
You should only use sessionMirrorLastErrorMessage
when asynchronous mode is disabled, which is the default setting. In asynchronous mode, errors are handled by the Aggregation agent and are not available in APL. For more information about using asynchronous mode, see Aggregation Agent in the Desktop user's guide.
Since sessionMirrors
does not return error codes and generally does not cause runtime errors, sessionMirrorLastErrorCode
or sessionMirrorLastErrorMessage
should be called after each operation to validate success.
string sessionMirrorLastErrorMessage()
Parameter | Description |
---|---|
Returns | An error message, or null if no error has occurred |
Example - Using sessionMirrorLastErrorMessage
sessionInit { list<any> allMirrorSessions = sessionMirrors(session); if (0 == sessionMirrorLastErrorCode()) { //No error } else { logError("sessionMirrorLastErrorCode:" + sessionMirrorLastErrorCode() + "sessionMirrorLastErrorMessage:" +sessionMirrorLastErrorMessage()); } }
sessionRemove - Batch and Real-Time
Removes the current session.
This function must be called when a session is considered to be closed and a new UDR has been emitted, or when a session is considered to be closed due to an expired timeout.
sessionRemove(session)
Parameter | Description |
---|---|
session | This is a built-in variable. For information about |
sessionTimeout - Batch and Real-Time
Sets a time limit to call the timeout function block or, if not available, the consume
block, within the number of seconds specified, or at an exact time. Only one timeout per session may exist, thus if a subsequent call to this function is made, the old timeout is cancelled.
Timeouts are not always called at the exact time stated. See Aggregation Agent in the Desktop user's guide for details on when the time limit is actually invoked.
The timeout for a session is cleared each time the consume or timeout function blocks are called.
void sessionTimeout(DRUDR session, long timeOutSeconds)
Parameter | Description |
---|---|
| This is a built-in variable. For information about |
timeoutSeconds | Number of seconds. If set to 0 (zero) or? |
sessionTimeout(session, date timeoutDate )
Parameter | Description |
---|---|
| This is a built-in variable. For information about |
timeoutDate | An exact date. If set to If set to a passed date, the session will be outdated. |