public TaskEnumeratorResult GetEnumerator(TaskEnumeratorPointer pointer) { if (this.enumerators == null) { this.enumerators = new HashVector(); } if (this.enumerators.ContainsKey(pointer)) { throw new InvalidTaskEnumeratorException("Enumerator already exists with specified Pointer."); } if (!IsValidPointer(pointer)) { throw new InvalidTaskEnumeratorException("Invalid Enumerator Pointer specified."); } IEnumerator it = this.output.GetEnumerator(); it.MoveNext(); lock (_mutex) { this.enumerators.Add(pointer, it); } return(NextRecord(pointer)); }
public TaskPartitionedEnumerator(TaskEnumeratorHandler remoteCache, TaskEnumeratorPointer pntr, DictionaryEntry entry, string nodeaddress, bool isLast) { this.handler = remoteCache; this.pointer = pntr; this.nextRecordSet = entry; this.nodeAddress = nodeaddress; this.isLastResult = isLast; this.callbackId = pointer.CallbackId; if (nextRecordSet.Key != null) { isValid = true; } }
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); }
private bool IsValidPointer(TaskEnumeratorPointer pointer) { if (this.listeners != null) { lock (_mutex) { IEnumerator it = this.listeners.GetEnumerator(); while (it.MoveNext()) { TaskCallbackInfo callbackInfo = (TaskCallbackInfo)it.Current; if ((callbackInfo.Client.Equals(pointer.ClientId) && (callbackInfo.CallbackId.Equals(pointer.CallbackId)))) { return(true); } } } } return(false); }
private void RemoveFromListeners(TaskEnumeratorPointer pointer) { if (listeners != null) { lock (_mutex) { IEnumerator itListeners = listeners.GetEnumerator(); // change to for loop. for (int i = 0; i < listeners.Count; i++) { TaskCallbackInfo callBackInfo = (TaskCallbackInfo)listeners[i]; if (callBackInfo.Client.Equals(pointer.ClientId) && ((short)callBackInfo.CallbackId).Equals(pointer.CallbackId)) { listeners.RemoveAt(i); } } } } }
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."); } } }
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); }
public virtual TaskEnumeratorResult NextRecord(string serverAddress, TaskEnumeratorPointer pointer) { return(null); }