Flush Sessions

This section describes how to flush aggregation sessions in real-time and batch workflows.

The following functions for Aggregation flush described here are:


Real-Time Aggregation APL Flush Function

To flush Real-time workflow sessions, run an agent command from the Command Tab of the Aggregation agent in the Workflow Monitor or use the Command Line Tool mzsh. There is a choice of applying the command on all sessions or only on those with a timeout set. There is also an option of attaching information in a string to be available within the command function block in the Aggregation agent.

Note!

You cannot flush sessions that are stored in Couchbase.

Note!

The command function block works in the same way as the timeout function block, that is, code has to be written to route the session result and to remove the session.

Example - command block in Aggregation agent

A simple APL example of command:

command {
  OutputUDR finalUDR = udrCreate( OutputUDR );
  finalUDR.user = session.user;
  finalUDR.IPAddress = (string)session.IPAddress;
  finalUDR.downloadedBytes = session.downloadedBytes;
  finalUDR.uploadedBytes = session.uploadedBytes;
  if (instruction == "extra") { finalUDR.extraBytes = session.extraBytes; }
  udrRoute( finalUDR );
  sessionRemove(session);
} 

Using Workflow Monitor

To access the Command tab, you will have to access the Agent Status dialog from the Workflow Monitor. Select the Aggregation agent from the Workflow Monitor and click on the icon that appears above the agent. 

Aggregation agent in Workflow Monitor - Agent Status Button

Aggregation agent in Workflow Monitor - Command tab


ParameterDescription

Only session with timeout

Trigger a flush for sessions that have already timeout.

All sessions

Trigger a flush for all sessions, regardless if they have already timeout or not.

instruction

This is an optional string used only when there is a command function block defined within the Aggregation agent. If specified, the string will trigger the command function block in the Aggregation agent through the instruction variable. Refer to the example above and to Variables for further information.

Using MZSH Syntax

Syntax to run the command function block from mzsh:

$ mzsh wfcommand <Workflow Name> <Agent Name> <"true"|"false"> <instruction>

Example - Using mzsh to trigger flush

A simple mzsh example to trigger a flush for all sessions with the instruction "extra":

mzsh wfcommand Default.Aggregation_Workflow Aggregation_Agent_1 "true" extra
ParameterDescription

Workflow Name

The name of the workflow that contains the Aggregation agent

Agent Name

The name of the Aggregation agent in the workflow

"true"|"false"

Specifies what sessions to apply the command block for. true means apply on all sessions, while false means apply only on sessions with timeout set. To have the sessions removed, the command block must issue sessionRemove(session).

instruction

This is an optional string. If specified, the string will be available within the command function block in the Aggregation agent through the instruction variable. Refer to Variables for further information.

Batch Aggregation APL Flush Function

This section describes the APL function aggregationHintFlushSessions, which is used to timeout all stored sessions that have a timeout value in a batch Aggregation agent. The function is included in the package Batch Aggregation APL Flush Function.

The APL function aggregationHintFlushSessions may be called from Analysis APL code or Aggregation APL code in batch workflows.

The function is used to indicate that the timeout function block in the APL code for the specified Aggregation agent shall be called for all the sessions in the storage that have a timeout value. The timeout block execution will be performed after the drain function block has been executed in the specified Aggregation agent. The call to the function will not be remembered between batches.

Note!

Only sessions that have a timeout value will timeout even if the function aggregationHintFlushSessions has been called. To make sure that all sessions have a timeout value, set the Aggregation agent property If Timeout is Missing to Default or Abort. The Aggregation agent property If Timeout is Missing can be found under the tab called General in the Aggregation agent configuration.

When executed, the function will throw an exception if it is called from an illegal location or if the agent named aggregationAgentName is not an Aggregation agent in the workflow.

Function Definition:

void aggregationHintFlushSessions(string aggregationAgentName )


ParameterDescription

aggregationAgentName

The name of an Aggregation agent in the batch workflow

Example - Using aggregationHintFlushSessions

For example, consider a batch workflow containing one Aggregation agent named "Agg" which has the Aggregation agent property If Timeout is Missing set to Default. Also, consider that the beginBatch function block and the timeout function block in the APL code for the Aggregation agent are defined as in the following code:

beginBatch {            
    aggregationHintFlushSessions("Agg");        
}

timeout {
    sessionRemove(session);
}

Finally, consider that there are 10 sessions, with timeout values in the distant future, in the storage when the end of the drain function block in the Aggregation agent has been reached. Then the timeout function block will be executed 10 times, one time for every session in the storage, and thus all the sessions in the storage will be removed.

Note!

A workflow using aggregationHintFlushSession may get stuck in a loop if all sessions are not removed in the timeout block.