public void CheckpointErrorHandling() { WriteActions( new InitializeAction("0"), new ProcessRecordsAction(new DefaultRecord("456", "cat", "bWVvdw==")), new CheckpointAction(null) { Error = "oh noes" }, new ShardEndedAction() ); bool handlerCodeCalled = false; CheckpointErrorHandler handler = (sequenceNumber, errorMsg, checkpointer) => { handlerCodeCalled = true; }; TestRecordProcessor recordProcessor = new TestRecordProcessor { ProcessFunc = (input) => input.Checkpointer.Checkpoint(input.Records.Last(), handler) }; KclProcess.Create(recordProcessor, _ioHandler).Run(); Assert.IsTrue(handlerCodeCalled); }
internal override void Checkpoint(string sequenceNumber, CheckpointErrorHandler errorHandler = null) { _p.CheckpointSeqNo = sequenceNumber; _p._stateMachine.Fire(Trigger.BeginCheckpoint); if (_p.CheckpointError != null && errorHandler != null) { errorHandler.Invoke(sequenceNumber, _p.CheckpointError, this); } }
internal override void Checkpoint(string sequenceNumber, CheckpointErrorHandler errorHandler = null) { _kclProcess._iohandler.WriteAction(new CheckpointAction(sequenceNumber)); var response = _kclProcess._iohandler.ReadAction(); if (response is CheckpointAction checkpointResponse) { if (!string.IsNullOrEmpty(checkpointResponse.Error)) { errorHandler?.Invoke(sequenceNumber, checkpointResponse.Error, this); } } else { errorHandler?.Invoke(sequenceNumber, $"Unexpected response type {response.GetType().Name}", this); } }
/// <summary> /// <para> /// This method will checkpoint the progress at the sequence number of the specified record. /// </para> /// <para> /// Upon failover (after a successful checkpoint() call), the new/replacement IRecordProcessor instance /// will receive data records whose sequenceNumber > checkpoint position (for each partition key). /// </para> /// <para> /// In steady state, applications should checkpoint periodically (e.g. once every 5 minutes). /// </para> /// <para> /// Calling this API too frequently can slow down the application (because it puts pressure on the underlying /// checkpoint storage layer). /// </para> /// <para> /// You may optionally pass a CheckpointErrorHandler to the method, which will be invoked when the /// checkpoint operation fails. /// </para> /// </summary> /// <param name="record">Record whose sequence number to checkpoint at.</param> /// <param name="errorHandler">CheckpointErrorHandler that is invoked when the checkpoint operation fails.</param> public void Checkpoint(Record record, CheckpointErrorHandler errorHandler = null) { Checkpoint(record.SequenceNumber, errorHandler); }
/// <summary> /// <para> /// This method will checkpoint the progress at the last data record that was delivered to the record processor. /// </para> /// <para> /// Upon failover (after a successful checkpoint() call), the new/replacement IRecordProcessor instance /// will receive data records whose sequenceNumber > checkpoint position (for each partition key). /// </para> /// <para> /// In steady state, applications should checkpoint periodically (e.g. once every 5 minutes). /// </para> /// <para> /// Calling this API too frequently can slow down the application (because it puts pressure on the underlying /// checkpoint storage layer). /// </para> /// <para> /// You may optionally pass a CheckpointErrorHandler to the method, which will be invoked when the /// checkpoint operation fails. /// </para> /// </summary> /// <param name="errorHandler">CheckpointErrorHandler that is invoked when the checkpoint operation fails.</param> public void Checkpoint(CheckpointErrorHandler errorHandler = null) { Checkpoint(null as string, errorHandler); }
public abstract void Checkpoint(string sequenceNumber, CheckpointErrorHandler errorHandler = null);
internal abstract void Checkpoint(string sequenceNumber, CheckpointErrorHandler errorHandler = null);