Example #1
0
        /// <summary>Absorbs one TaskAttemptStatus</summary>
        /// <param name="reportedStatus">
        /// the status report that we got from a task attempt
        /// that we want to fold into the speculation data for this job
        /// </param>
        /// <param name="timestamp">
        /// the time this status corresponds to.  This matters
        /// because statuses contain progress.
        /// </param>
        protected internal virtual void StatusUpdate(TaskAttemptStatusUpdateEvent.TaskAttemptStatus
                                                     reportedStatus, long timestamp)
        {
            string        stateString = reportedStatus.taskState.ToString();
            TaskAttemptId attemptID   = reportedStatus.id;
            TaskId        taskID      = attemptID.GetTaskId();

            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = context.GetJob(taskID.GetJobId()
                                                                            );
            if (job == null)
            {
                return;
            }
            Task task = job.GetTask(taskID);

            if (task == null)
            {
                return;
            }
            estimator.UpdateAttempt(reportedStatus, timestamp);
            if (stateString.Equals(TaskAttemptState.Running.ToString()))
            {
                runningTasks.PutIfAbsent(taskID, true);
            }
            else
            {
                runningTasks.Remove(taskID, true);
                if (!stateString.Equals(TaskAttemptState.Starting.ToString()))
                {
                    Sharpen.Collections.Remove(runningTaskAttemptStatistics, attemptID);
                }
            }
        }
Example #2
0
            public override V Get()             // serialize access
            {
                lock (this)
                {
                    // re-check
                    Supplier <V> supplier = ValuesMap[SubKey];
                    if (supplier != this)
                    {
                        // something changed while we were waiting:
                        // might be that we were replaced by a CacheValue
                        // or were removed because of failure ->
                        // return null to signal WeakCache.get() to retry
                        // the loop
                        return(null);
                    }
                    // else still us (supplier == this)

                    // create new value
                    V value = null;
                    try
                    {
                        value = Objects.RequireNonNull(outerInstance.ValueFactory.Apply(Key, Parameter));
                    }
                    finally
                    {
                        if (value == null)                         // remove us on failure
                        {
                            ValuesMap.Remove(SubKey, this);
                        }
                    }
                    // the only path to reach here is with non-null value
                    Debug.Assert(value != null);

                    // wrap value with CacheValue (WeakReference)
                    CacheValue <V> cacheValue = new CacheValue <V>(value);

                    // try replacing us with CacheValue (this should always succeed)
                    if (ValuesMap.Replace(SubKey, this, cacheValue))
                    {
                        // put also in reverseMap
                        outerInstance.ReverseMap[cacheValue] = true;
                    }
                    else
                    {
                        throw new AssertionError("Should not reach here");
                    }

                    // successfully replaced us with new CacheValue -> return the value
                    // wrapped by it
                    return(value);
                }
            }
Example #3
0
            internal void expungeFrom <T1, T2>(ConcurrentMap <T1> map, ConcurrentMap <T2> reverseMap) where T1 : java.util.concurrent.ConcurrentMap <T1, T1>
            {
                // removing just by key is always safe here because after a CacheKey
                // is cleared and enqueue-ed it is only equal to itself
                // (see equals method)...
//JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
//ORIGINAL LINE: java.util.concurrent.ConcurrentMap<?, ?> valuesMap = map.remove(this);
                ConcurrentMap <?, ?> valuesMap = map.Remove(this);

                // remove also from reverseMap if needed
                if (valuesMap != null)
                {
                    foreach (Object cacheValue in valuesMap.Values)
                    {
                        reverseMap.Remove(cacheValue);
                    }
                }
            }