public void Retry(WorkerItem item) { lock (_connectionLock) { if (_events.TryRemove(item.CorrelationId, out item)) { var newCorrId = Guid.NewGuid(); item.CorrelationId = newCorrId; item.Attempt += 1; Interlocked.Exchange(ref item.LastUpdatedTicks, DateTime.UtcNow.Ticks); _events.TryAdd(newCorrId, item); _connection.EnqueueSend(_packager(newCorrId, item.Event).AsByteArray()); } else { SignalWorkerFailed(null, string.Format("Worker {0} couldn't remove event '{1}' on retry. Concurrency failure!", Name, item != null ? item.CorrelationId.ToString() : "null")); } } }
private void Retry(WorkerItem item) { lock (_connectionLock) { if (_items.TryRemove(item.CorrelationId, out item)) { var newCorrId = Guid.NewGuid(); item.CorrelationId = newCorrId; item.Attempt += 1; Interlocked.Exchange(ref item.LastUpdatedTicks, DateTime.UtcNow.Ticks); if (item.Attempt > 100) { _coordinator.SignalWorkerFailed(error: string.Format("Item's {0} current attempt is {1}!", item, item.Attempt)); } _items.TryAdd(newCorrId, item); _connection.EnqueueSend(item.Task.CreateNetworkPackage(newCorrId).AsByteArray()); } else { _coordinator.SignalWorkerFailed(null, string.Format("Worker {0} couldn't remove corrid '{1}' on retry. Concurrency failure!", _name, item != null ? item.CorrelationId.ToString() : "null")); } } }
private bool TryRemoveWorkItem(WorkerItem workItem) { if (!_items.TryRemove(workItem.CorrelationId, out workItem)) { _coordinator.SignalWorkerFailed(null, string.Format("Worker {0} couldn't remove corrid '{1}'. Concurrency failure!", _name, workItem.CorrelationId)); return(false); } Interlocked.Decrement(ref _inProgressCount); return(true); }
public bool TryRemoveWorkItem(WorkerItem workItem) { if (!_events.TryRemove(workItem.CorrelationId, out workItem)) { SignalWorkerFailed( error: string.Format("Worker {0} couldn't remove event '{1}'. Concurrency failure!", Name, workItem.Event.Event.EventId)); return(false); } Interlocked.Decrement(ref _inProgressCount); return(true); }
public void NotifyItemProcessed(WorkerItem item) { switch (_role) { case WorkerRole.Writer: Interlocked.Increment(ref _totalProcessedEventCount); _coordinator.NotifyEventCommitted(item.Event); break; case WorkerRole.Verifier: Interlocked.Increment(ref _totalProcessedEventCount); _coordinator.NotifyEventVerified(item.Event); break; default: throw new ArgumentOutOfRangeException(); } }
private void NotifyItemProcessed(WorkerItem item) { Interlocked.Increment(ref _totalProcessedEventCount); _coordinator.Complete(item.Task); }
public void Retry(WorkerItem item) { lock (_connectionLock) { if (_events.TryRemove(item.CorrelationId, out item)) { var newCorrId = Guid.NewGuid(); item.CorrelationId = newCorrId; item.Attempt += 1; Interlocked.Exchange(ref item.LastUpdatedTicks, DateTime.UtcNow.Ticks); _events.TryAdd(newCorrId, item); _connection.EnqueueSend(_packager(newCorrId, item.Event).AsByteArray()); } else SignalWorkerFailed(null, string.Format("Worker {0} couldn't remove event '{1}' on retry. Concurrency failure!", Name, item != null ? item.CorrelationId.ToString() : "null")); } }
public bool TryRemoveWorkItem(WorkerItem workItem) { if (!_events.TryRemove(workItem.CorrelationId, out workItem)) { SignalWorkerFailed( error: string.Format("Worker {0} couldn't remove event '{1}'. Concurrency failure!", Name, workItem.Event.Event.EventId)); return false; } Interlocked.Decrement(ref _inProgressCount); return true; }
public bool TryGetWorkItem(Guid key, out WorkerItem value) { return _events.TryGetValue(key, out value); }
public bool TryGetWorkItem(Guid key, out WorkerItem value) { return(_events.TryGetValue(key, out value)); }
private void Retry(WorkerItem item) { lock (_connectionLock) { if (_items.TryRemove(item.CorrelationId, out item)) { var newCorrId = Guid.NewGuid(); item.CorrelationId = newCorrId; item.Attempt += 1; Interlocked.Exchange(ref item.LastUpdatedTicks, DateTime.UtcNow.Ticks); if (item.Attempt > 100) _coordinator.SignalWorkerFailed(error: string.Format("Item's {0} current attempt is {1}!", item, item.Attempt)); _items.TryAdd(newCorrId, item); _connection.EnqueueSend(item.Task.CreateNetworkPackage(newCorrId).AsByteArray()); } else _coordinator.SignalWorkerFailed(null, string.Format("Worker {0} couldn't remove corrid '{1}' on retry. Concurrency failure!", _name, item != null ? item.CorrelationId.ToString() : "null")); } }
private bool TryRemoveWorkItem(WorkerItem workItem) { if (!_items.TryRemove(workItem.CorrelationId, out workItem)) { _coordinator.SignalWorkerFailed(null, string.Format("Worker {0} couldn't remove corrid '{1}'. Concurrency failure!", _name, workItem.CorrelationId)); return false; } Interlocked.Decrement(ref _inProgressCount); return true; }