public TaskEnumeratorResult NextRecord(TaskEnumeratorPointer pointer) { if (!this.enumerators.ContainsKey(pointer)) { throw new InvalidTaskEnumeratorException("Enumerator does not exist with specified Pointer."); } TaskEnumeratorResult result = new TaskEnumeratorResult(); result.Pointer = pointer; IEnumerator it = null; lock (_mutex) { it = (IEnumerator)this.enumerators[pointer]; } try { if (it.Current != null) { TaskOutputPair pair = (TaskOutputPair)it.Current; result.RecordSet = new DictionaryEntry(pair.Key, pair.Value); } } catch (Exception exx) { } if (!it.MoveNext()) { result.IsLastResult = true; lock (_mutex) { this.enumerators.Remove(pointer); } this.RemoveFromListeners(pointer); if (this.enumerators.Count == 0 && this.listeners.Count == 0) { disposeOutput = true; } } return(result); }
public TaskEnumeratorResult NextRecord(TaskEnumeratorPointer pointer) { lock (objectMutex) { if (TaskOutputExists(pointer.TaskId)) { TaskOutput output = (TaskOutput)taskOutput[pointer.TaskId]; TaskEnumeratorResult result = output.NextRecord(pointer); if (output.OutputDisposed) { taskOutput.Remove(pointer.TaskId); } return(result); } else { throw new InvalidTaskEnumeratorException("Output with task id : " + pointer.TaskId + " got corrupted."); } } }
public TaskEnumeratorResult GetTaskEnumerator(TaskEnumeratorPointer pointer) { lock (objectMutex) { if (TaskOutputExists(pointer.TaskId)) { TaskOutput output = (TaskOutput)taskOutput[pointer.TaskId]; TaskEnumeratorResult result = output.GetEnumerator(pointer); if (output.OutputDisposed) { taskOutput.Remove(pointer.TaskId); } return(result); } else { throw new InvalidTaskEnumeratorException("Output with taskId '" + pointer.TaskId + "' does not exist. Task might be cancelled or failed."); } } }
public bool MoveNext() { if (IsValid) { currentRecordSet = nextRecordSet; // set the current record set. if (!IsLastResult) { try { TaskEnumeratorResult enumeratorResultSet = null; enumeratorResultSet = handler.NextRecord(pointer.ClusterAddress.IpAddress.ToString(), pointer); if (enumeratorResultSet != null) { nextRecordSet = enumeratorResultSet.RecordSet; IsLastResult = enumeratorResultSet.IsLastResult; isValid = true; } } catch (OperationFailedException ex) { isValid = false; throw new Exception("Output corrupted on node : " + pointer.ClientAddress.ToString() + "and Exception is :" + ex); } } else { isValid = false; // Means enumerator has the last entry. // Return True for that last entry return(true); } } return(IsValid); }
private Object NextRecord(MapReduceOperation operation) { TaskEnumeratorPointer pointer = (TaskEnumeratorPointer)operation.Data; // Task cancellation check if (this.cancelledTask.Contains(pointer.TaskId)) { throw new OperationFailedException("Task with specified Task ID was Cancelled."); } TaskEnumeratorResult result = null; if (taskOutputStore != null) { try { result = taskOutputStore.NextRecord(pointer); result.NodeAddress = _context.Render.IPAddress.ToString(); } catch (InvalidTaskEnumeratorException ex) { _context.NCacheLog.Error("TaskTracker.GetTaskEnumerator", ex.Message); throw ex; } } return(result); }
private object GetTaskEnumerator(MapReduceOperation operation) { TaskEnumeratorPointer pointer = (TaskEnumeratorPointer)operation.Data; if (clientAddress == null) { try { if (_context.Render != null) { clientAddress = new Address(_context.Render.IPAddress, _context.Render.Port); } } catch (Exception ex) { throw new InvalidTaskEnumeratorException(ex.Message, ex); } } pointer.ClientAddress = clientAddress; if (clusterAddress == null) { #if !CLIENT if (_context.CacheImpl is ClusterCacheBase) { clusterAddress = ((ClusterCacheBase)_context.CacheImpl).Cluster.LocalAddress; } else if (_context.CacheImpl is LocalCacheImpl) { clusterAddress = new Address(_context.Render.IPAddress, _context.Render.Port); } #else clusterAddress = new Address(_context.Render.IPAddress, _context.Render.Port); #endif } pointer.ClusterAddress = clusterAddress; // Task Cancellation check. if (this.cancelledTask.Contains(pointer.TaskId)) { throw new OperationFailedException("Task with specified Task ID was cancelled"); } TaskEnumeratorResult result = null; if (taskOutputStore != null) { try { result = taskOutputStore.GetTaskEnumerator(pointer); //result.NodeAddress = _context.Render.IPAddress.ToString(); result.Pointer = pointer; } catch (InvalidTaskEnumeratorException ex) { _context.NCacheLog.Error("TaskTracker.GetTaskEnumerator", ex.Message); throw ex; } } if (_context.NCacheLog.IsInfoEnabled) { _context.NCacheLog.Info("TaskTracker.GetTaskEnumerator", "Task Enumerator provided to client."); } return(result); }