public IEnumerable <IDataflowMessage <TOut> > TransformMany(IDataflowMessage <TIn> item) { try { if (item.IsBroken) { // Kind of unexpected, as those guys should usually be filtered return(new List <IDataflowMessage <TOut> > { new BrokenDataflowMessage <TOut>(null, item.Data) }); } var result = m_Decorated.TransformMany(item.Data).Select(c => new DefaultDataflowMessage <TOut>(c).WithTitle(Title)); return(result); } catch (DataflowNetworkRecoverableErrorException recoverableError) { return(new List <IDataflowMessage <TOut> > { new BrokenDataflowMessage <TOut>(recoverableError, item.Data) }); } catch (DataflowNetworkUnrecoverableErrorException unrecoverableError) { // bring the network down. m_LogAgent.LogFatal(DataflowNetworkConstituent.TransformMany, Title, unrecoverableError); m_Cancel.CancelNetwork(); return(new List <IDataflowMessage <TOut> > { new BrokenDataflowMessage <TOut>(unrecoverableError, item.Data) }); } }
public IDataflowMessage <TOut> Transform(IDataflowMessage <TIn>[] items) { // skipped broken messages - logDecoratorTransformBatched logs count of broken messages and their titles. var skippedBrokenItems = items.Where(item => !item.IsBroken).Select(item => item.Data).ToArray(); try { if (!skippedBrokenItems.Any()) { return(new BrokenDataflowMessage <TOut>( new DataflowNetworkRecoverableErrorException(string.Format("All messages in batch are broken, Batch-Size: {0}", items.Count())) , skippedBrokenItems)); } TOut result = m_DecoratedTransformation.Transform(skippedBrokenItems); return(new DefaultDataflowMessage <TOut>(result).WithTitle(Title)); } catch (DataflowNetworkUnrecoverableErrorException ex) { m_LogAgent.LogFatal(DataflowNetworkConstituent.TransformationBatched, m_DecoratedTransformation.Title, ex); m_Cancel.CancelNetwork(); return(new BrokenDataflowMessage <TOut>(ex, skippedBrokenItems)); } catch (DataflowNetworkRecoverableErrorException ex) { return(new BrokenDataflowMessage <TOut>(ex, skippedBrokenItems)); } }
public void Push(IDataflowMessage <TIn>[] items) { try { m_DecoratedTarget.Push(items.Where(item => !item.IsBroken).Select(item => item.Data).ToArray()); } catch (DataflowNetworkUnrecoverableErrorException ex) { m_LogAgent.LogFatal(DataflowNetworkConstituent.TargetBatched, m_DecoratedTarget.Title, ex); m_Cancel.CancelNetwork(); } catch (DataflowNetworkRecoverableErrorException ex) { m_LogAgent.LogUnknown(DataflowNetworkConstituent.TargetBatched, m_DecoratedTarget.Title, ex); } }
public void Push(IDataflowMessage <TIn> item) { try { if (!item.IsBroken) { m_DecoratedTarget.Push(item.Data); } } catch (DataflowNetworkUnrecoverableErrorException ex) { m_LogAgent.LogFatal(DataflowNetworkConstituent.Target, m_DecoratedTarget.Title, ex); // Halt the entire dataflow network. m_Cancel.CancelNetwork(); } catch (DataflowNetworkRecoverableErrorException ex) { var broken = new BrokenDataflowMessage <TIn>(ex, item.Data); m_LogAgent.LogBrokenMessage(DataflowNetworkConstituent.Target, Title, item.Title, broken); } }
public IDataflowMessage <TOut> Transform(IDataflowMessage <TIn> item) { try { if (item.IsBroken) { var broken = (IBrokenDataFlowMessage <TIn>)item; return(new BrokenDataflowMessage <TOut>(broken.BreakException, item.Data)); } TOut result = m_DecoratedTransformation.Transform(item.Data); return(new DefaultDataflowMessage <TOut>(result).WithTitle(Title)); } catch (DataflowNetworkUnrecoverableErrorException ex) { m_LogAgent.LogFatal(DataflowNetworkConstituent.Transformation, m_DecoratedTransformation.Title, ex); m_Cancel.CancelNetwork(); return(new BrokenDataflowMessage <TOut>(ex, item.Data)); } catch (DataflowNetworkRecoverableErrorException ex) { return(new BrokenDataflowMessage <TOut>(ex, item.Data)); } }