Exemple #1
0
        public override void StopTask()
        {
            if (Context != null)
            {
                if (Context.NCacheLog.IsInfoEnabled)
                {
                    Context.NCacheLog.Info("MapReduceTask(" + this.TaskId + ").StopTask", "MapReduce task is stopping.");
                }
            }

            if (mapperTask != null)
            {
                mapperTask.StopTask();
            }

            if (combinerTask != null && CombinerConfigured)
            {
                combinerTask.StopTask();
            }

            if (reducerTask != null && ReducerConfigured)
            {
                reducerTask.StopTask();
            }

            mapperTask   = null;
            combinerTask = null;
            reducerTask  = null;

            if (Context != null)
            {
                if (Context.NCacheLog.IsInfoEnabled)
                {
                    Context.NCacheLog.Info("MapReduceTask(" + this.TaskId + ").StopTask", "MapReduce task has been stopped.");
                }
            }
        }
Exemple #2
0
        public MapReduceTask(CacheBase parent, TaskCallback callback,
                             IMapper mapper,
                             ICombinerFactory combiner,
                             IReducerFactory reducer,
                             MapReduceInput inputProvider,
                             MapReduceOutput outputProvider,
                             Filter filter, CacheRuntimeContext context, int chunkSize, int maxExceps)
        {
            this._parent       = parent;
            this.Callback      = callback;
            this._context      = context;
            this.maxExceptions = maxExceps;

            this.mapperTask = new MapperTask(mapper, inputProvider, filter != null ? filter.KeyFilter : null, this);

            if (reducer != null)
            {
                ReducerConfigured = true;
                this.reducerTask  = new ReducerTask(reducer, this);
            }
            else
            {
                ReducerConfigured = true;
                this.reducerTask  = new ReducerTask(new IdentityReducerFactory(), this);
            }
            if (combiner != null)
            {
                CombinerConfigured = true;
                this.combinerTask  = new CombinerTask(combiner, this);
            }

            throttlingMgr       = new MapReduceThrottlingManager(chunkSize, this);
            this.outputProvider = outputProvider;

            if (_parent != null && _parent is LocalCacheImpl)
            {
                isLocal      = true;
                participants = new Hashtable();
                participants.Add(new Address(_parent.Context.Render.IPAddress, _parent.Context.Render.Port), new NodeTaskStatus());
            }
#if !CLIENT
            if (_parent != null && _parent is ClusterCacheBase)
            {
                ArrayList   list = ((ClusterCacheBase)_parent).ActiveServers;
                IEnumerator it   = list.GetEnumerator();
                participants = new Hashtable();
                while (it.MoveNext())
                {
                    participants.Add(it.Current, new NodeTaskStatus());
                }

                if (parent is PartitionedServerCache)
                {
                    distributionMgr = ((PartitionedServerCache)parent).DistributionMgr;
                }
            }
#endif

            //Queue itialization and synchronization
            Queue syncQueue = Queue.Synchronized(reducerDataQueue);
            this.reducerDataQueue = syncQueue;
        }