Apama Documentation : Developing Apama Applications : Developing Apama Applications in EPL : Using Correlator Persistence : Sample code for persistence applications : Sample code for recovery behavior based on downtime duration
Sample code for recovery behavior based on downtime duration
The following sample is the same as the discard-stale-data sample with some changes that provide a downtime policy. Downtime is the duration between the last committed snapshot and the time of day upon recovery.
This code sample ignores downtimes that are less than two hours. However, if recovery starts just under the two-hour limit the processing of old data might appear to be beyond the two hour threshold. The downtime policy must take this into account.
persistent monitor eg1 {
 
import "TimeFormatPlugin" as timeFormatPlugin;
// ... onload() and so on
boolean longDowntime;
action onBeginRecovery() {
// currentTime is the time of the last snapshot, which is
// approximately when the correlator went down.
// timeFormatPlugin.getTime() is the actual time of recovery.
if (timeFormatPlugin.getTime() - currentTime > (60.0 * 60.0 * 2)
{
// If we were down for less than 2 hours, pretend nothing
// happened. For longer gaps, skip stale data as it will be
// too expensive to process it.
longDowntime:=true;
log "Correlator was down for a long time - will discard stale
data.";
l.quit(); // Discard all recovered Data events.
lt.quit(); // Stop sending intermittent updates.
// Do not flood receivers.
}
}
action onConcludeRecovery() {
if longDowntime {
longDowntime:=false;
initiateListener(); // Go back to normal.
}
}
}
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback