Ejemplo n.º 1
0
        public void EnqueueMapperOutput(OutputMap output)
        {
            if (CombinerConfigured)
            {
                {
                    IEnumerator it = output.MapperOutput.GetEnumerator();
                    while (it.MoveNext())
                    {
                        KeyValuePair <object, List <object> > curr = (KeyValuePair <object, List <object> >)it.Current;

                        IList mapValues = (IList)curr.Value;
                        foreach (object val in mapValues)
                        {
                            combinerTask.CombinerInputQueue.Enqueue(new DictionaryEntry(curr.Key, val));
                            throttlingMgr.IncrementChunkSize();
                        }
                        lock (combinerTask.CombinerInputQueue)
                        {
                            Monitor.PulseAll(combinerTask.CombinerInputQueue);
                        }
                    }
                }
            }
            else
            {
                lock (ReducerDataQueue) {
                    IEnumerator it = output.MapperOutput.GetEnumerator();
                    while (it.MoveNext())
                    {
                        KeyValuePair <object, List <object> > curr = (KeyValuePair <object, List <object> >)it.Current;

                        IList mapValues = (IList)curr.Value;
                        foreach (object val in mapValues)
                        {
                            ReducerDataQueue.Enqueue(new DictionaryEntry(curr.Key, val));
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void Run()
        {
            try
            {
                if (parent.Context.NCacheLog != null)
                {
                    if (parent.Context.NCacheLog.IsInfoEnabled)
                    {
                        parent.Context.NCacheLog.Info("MapperTask(" + parent.TaskId + ").Start ", "Mapper task is started.");
                    }
                }
                bool completedSuccessfully = true;
                while (isAlive && inputProvider.MoveNext())
                {
                    try
                    {
                        object el = inputProvider.Entry;

                        if (el != null)
                        {
                            DictionaryEntry element = (DictionaryEntry)el;
                            if (keyFilter != null && !keyFilter.FilterKey(element.Key))
                            {
                                continue;
                            }

                            OutputMap output = new OutputMap();
                            // Real Map Method call.
                            mapper.Map(element.Key, element.Value, output);
                            this.MappedCount = MappedCount + 1;
                            if (parent.Context.PerfStatsColl != null)
                            {
                                parent.Context.PerfStatsColl.IncrementMappedPerSecRate();
                            }
                            parent.EnqueueMapperOutput(output);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (parent.ExceptionCount < parent.MaxExceptions)
                        {
                            if (parent.Context.NCacheLog != null)
                            {
                                parent.Context.NCacheLog.Error("MapperTask(" + parent.TaskId + ").Run", " Exception : " + ex.Message);
                            }
                            parent.ExceptionCount = parent.ExceptionCount + 1;
                        }
                        else
                        {
                            completedSuccessfully = false;
                            parent.LocalMapperFailed();
                            break;
                        }
                    }
                }
                if (completedSuccessfully && isAlive)
                {
                    parent.LocalMapperCompleted();
                    mapper.Dispose();
                }
            }
            catch (Exception ex)
            {
                try
                {
                    parent.LocalMapperFailed();
                }
                catch (Exception)
                {
                }
            }
        }