Exemple #1
0
 public void UpdateChunkReduceSent(JobChunkUid chunkUid)
 {
     Logger.Log.Instance.Info(string.Format("CacheJobChunkRegistrator. Reduce chunk sent. JobId '{0}', ChunkId '{1}'",
                                            chunkUid.JobId,
                                            chunkUid.ChunkId));
     UpdateChunkStatusInCache(chunkUid, ChunkStatus.ReduceSent, ProcessingMode.Reduce);
 }
Exemple #2
0
 public void RegisterNewReduceChunk(JobChunkUid chunkUid)
 {
     Logger.Log.Instance.Info(string.Format("CacheJobChunkRegistrator. Register new reduce chunk. JobId '{0}', ChunkId '{1}'",
                                            chunkUid.JobId,
                                            chunkUid.ChunkId));
     UpdateJobSummeryInCache(chunkUid);
     AddChunkToCache(chunkUid, ProcessingMode.Reduce);
 }
Exemple #3
0
        private void AddChunkToCache(JobChunkUid chunkUid, ProcessingMode mode)
        {
            var chunkKey    = GetJobChunkKey(chunkUid, mode);
            var chunkStatus = new JobChunkStatus()
            {
                LastUpdate = DateTime.Now,
                Status     = mode == ProcessingMode.Map ? ChunkStatus.NewMap : ChunkStatus.NewReduce
            };

            chunkStatus.ChunkUid.JobId   = chunkUid.JobId;
            chunkStatus.ChunkUid.ChunkId = chunkUid.ChunkId;

            AzureClient.Instance.CacheClient.Add(chunkKey, chunkStatus);
        }
Exemple #4
0
        private void UpdateJobSummeryInCache(JobChunkUid chunkUid)
        {
            var sumKey     = GetJobSummeryKey(chunkUid.JobId);
            var jobSummery = AzureClient.Instance.CacheClient.Get(sumKey) as JobSplitDetails;

            if (jobSummery == null)
            {
                jobSummery       = new JobSplitDetails();
                jobSummery.JobId = chunkUid.JobId;
            }

            if (!jobSummery.JobChunkIds.Contains(chunkUid.ChunkId))
            {
                jobSummery.JobChunkIds.Add(chunkUid.ChunkId);
                AzureClient.Instance.CacheClient.Add(sumKey, jobSummery);
            }
        }
Exemple #5
0
        private void UpdateChunkStatusInCache(JobChunkUid chunkUid, ChunkStatus status, ProcessingMode mode)
        {
            var chunkKey    = GetJobChunkKey(chunkUid, mode);
            var chunkStatus = AzureClient.Instance.CacheClient.Get(chunkKey) as JobChunkStatus;

            if (chunkStatus == null)
            {
                throw new UnknownChunkException("Unrestered chunk")
                      {
                          ChunkUid = chunkUid
                      }
            }
            ;

            chunkStatus.Status     = status;
            chunkStatus.LastUpdate = DateTime.Now;
            AzureClient.Instance.CacheClient.Add(chunkKey, chunkStatus);
        }
Exemple #6
0
        public void UpdateChunkReduceComplete(JobChunkUid chunkUid)
        {
            Logger.Log.Instance.Info(string.Format("CacheJobChunkRegistrator. Reduce chunk complete. JobId '{0}', ChunkId '{1}'",
                                                   chunkUid.JobId,
                                                   chunkUid.ChunkId));
            UpdateChunkStatusInCache(chunkUid, ChunkStatus.ReduceCompleted, ProcessingMode.Reduce);
            if (AllJobChunksCompleted(chunkUid.JobId, ProcessingMode.Reduce))
            {
                Logger.Log.Instance.Info(string.Format("CacheJobChunkRegistrator. Reduce of all job chunks complete. JobId '{0}'",
                                                       chunkUid.JobId));

                var jobReduceComplete = JobReduceComplete;
                if (jobReduceComplete != null)
                {
                    Logger.Log.Instance.Info(string.Format("CacheJobChunkRegistrator. Raise job reduce complete event. JobId '{0}'",
                                                           chunkUid.JobId));
                    jobReduceComplete(this, chunkUid.JobId);
                }
            }
        }
Exemple #7
0
 private string GetJobChunkKey(JobChunkUid chunkUid, ProcessingMode mode)
 {
     return(string.Format("{3}_{0}{1}_{2}", JobChunkKeyPrefix, chunkUid.JobId, chunkUid.ChunkId, mode));
 }