Beispiel #1
0
        public static RMContext MockRMContext(int numApps, int racks, int numNodes, int mbsPerNode
                                              )
        {
            IList <RMApp> apps = MockAsm.NewApplications(numApps);
            ConcurrentMap <ApplicationId, RMApp> applicationsMaps = Maps.NewConcurrentMap();

            foreach (RMApp app in apps)
            {
                applicationsMaps[app.GetApplicationId()] = app;
            }
            IList <RMNode> nodes = MockNodes.NewNodes(racks, numNodes, MockNodes.NewResource(mbsPerNode
                                                                                             ));
            ConcurrentMap <NodeId, RMNode> nodesMap = Maps.NewConcurrentMap();

            foreach (RMNode node in nodes)
            {
                nodesMap[node.GetNodeID()] = node;
            }
            IList <RMNode> deactivatedNodes = MockNodes.DeactivatedNodes(racks, numNodes, MockNodes.NewResource
                                                                             (mbsPerNode));
            ConcurrentMap <string, RMNode> deactivatedNodesMap = Maps.NewConcurrentMap();

            foreach (RMNode node_1 in deactivatedNodes)
            {
                deactivatedNodesMap[node_1.GetHostName()] = node_1;
            }
            RMContextImpl rmContext = new _RMContextImpl_183(applicationsMaps, deactivatedNodesMap
                                                             , nodesMap, null, null, null, null, null, null, null, null, null, null);

            rmContext.SetNodeLabelManager(new NullRMNodeLabelsManager());
            return(rmContext);
        }
Beispiel #2
0
                protected internal override void RebootNodeStatusUpdaterAndRegisterWithRM()
                {
                    ConcurrentMap <ContainerId, Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Container.Container
                                   > containers = this._enclosing.GetNMContext().GetContainers();

                    try
                    {
                        // ensure that containers are empty before restart nodeStatusUpdater
                        if (!containers.IsEmpty())
                        {
                            foreach (Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Container.Container
                                     container in containers.Values)
                            {
                                NUnit.Framework.Assert.AreEqual(ContainerState.Complete, container.CloneAndGetContainerStatus
                                                                    ().GetState());
                            }
                        }
                        base.RebootNodeStatusUpdaterAndRegisterWithRM();
                        // After this point new containers are free to be launched, except
                        // containers from previous RM
                        // Wait here so as to sync with the main test thread.
                        this._enclosing._enclosing.syncBarrier.Await();
                    }
                    catch (Exception)
                    {
                    }
                    catch (BrokenBarrierException)
                    {
                    }
                    catch (Exception ae)
                    {
                        Sharpen.Runtime.PrintStackTrace(ae);
                        this._enclosing._enclosing.assertionFailedInThread.Set(true);
                    }
                }
Beispiel #3
0
        public virtual RMContext MockRMContext(int n, long time)
        {
            IList <RMApp> apps = NewRMApps(n, time, RMAppState.Finished);
            ConcurrentMap <ApplicationId, RMApp> map = Maps.NewConcurrentMap();

            foreach (RMApp app in apps)
            {
                map[app.GetApplicationId()] = app;
            }
            Dispatcher rmDispatcher = new AsyncDispatcher();
            ContainerAllocationExpirer containerAllocationExpirer = new ContainerAllocationExpirer
                                                                        (rmDispatcher);
            AMLivelinessMonitor        amLivelinessMonitor = new AMLivelinessMonitor(rmDispatcher);
            AMLivelinessMonitor        amFinishingMonitor  = new AMLivelinessMonitor(rmDispatcher);
            RMApplicationHistoryWriter writer = Org.Mockito.Mockito.Mock <RMApplicationHistoryWriter
                                                                          >();
            RMContext context = new _RMContextImpl_121(map, rmDispatcher, containerAllocationExpirer
                                                       , amLivelinessMonitor, amFinishingMonitor, null, null, null, null, null);

            ((RMContextImpl)context).SetStateStore(Org.Mockito.Mockito.Mock <RMStateStore>());
            metricsPublisher = Org.Mockito.Mockito.Mock <SystemMetricsPublisher>();
            context.SetSystemMetricsPublisher(metricsPublisher);
            context.SetRMApplicationHistoryWriter(writer);
            return(context);
        }
Beispiel #4
0
 internal LocalResourcesTrackerImpl(string user, ApplicationId appId, Dispatcher dispatcher
                                    , ConcurrentMap <LocalResourceRequest, LocalizedResource> localrsrc, bool useLocalCacheDirectoryManager
                                    , Configuration conf, NMStateStoreService stateStore)
 {
     /*
      * This flag controls whether this resource tracker uses hierarchical
      * directories or not. For PRIVATE and PUBLIC resource trackers it
      * will be set whereas for APPLICATION resource tracker it would
      * be false.
      */
     /*
      * It is used to keep track of resource into hierarchical directory
      * while it is getting downloaded. It is useful for reference counting
      * in case resource localization fails.
      */
     /*
      * starting with 10 to accommodate 0-9 directories created as a part of
      * LocalCacheDirectoryManager. So there will be one unique number generator
      * per APPLICATION, USER and PUBLIC cache.
      */
     this.appId      = appId;
     this.user       = user;
     this.dispatcher = dispatcher;
     this.localrsrc  = localrsrc;
     this.useLocalCacheDirectoryManager = useLocalCacheDirectoryManager;
     if (this.useLocalCacheDirectoryManager)
     {
         directoryManagers           = new ConcurrentHashMap <Path, LocalCacheDirectoryManager>();
         inProgressLocalResourcesMap = new ConcurrentHashMap <LocalResourceRequest, Path>();
     }
     this.conf       = conf;
     this.stateStore = stateStore;
 }
Beispiel #5
0
 /// <summary>Close all DFSClient instances in the Cache.</summary>
 /// <param name="onlyAutomatic">only close those that are marked for automatic closing
 ///     </param>
 /// <exception cref="System.IO.IOException"/>
 internal virtual void CloseAll(bool onlyAutomatic)
 {
     lock (this)
     {
         IList <IOException> exceptions        = new AList <IOException>();
         ConcurrentMap <string, DFSClient> map = clientCache.AsMap();
         foreach (KeyValuePair <string, DFSClient> item in map)
         {
             DFSClient client = item.Value;
             if (client != null)
             {
                 try
                 {
                     client.Close();
                 }
                 catch (IOException ioe)
                 {
                     exceptions.AddItem(ioe);
                 }
             }
         }
         if (!exceptions.IsEmpty())
         {
             throw MultipleIOException.CreateIOException(exceptions);
         }
     }
 }
Beispiel #6
0
 internal Updater(Lock @lock, ReadableState <Key> store, ConcurrentMap <Key, ChangeEntry> changes, AtomicLong changeCounter, long version) : base(@lock)
 {
     this.ChangeCounter = changeCounter;
     this.Store         = store;
     this.Changes       = changes;
     this.Version       = version;
 }
Beispiel #7
0
        public override void ReleaseShared(ResourceType resourceType, params long[] resourceIds)
        {
            _stateHolder.incrementActiveClients(this);

            try
            {
                MutableLongIntMap sharedLocks    = _sharedLockCounts[resourceType.TypeId()];
                MutableLongIntMap exclusiveLocks = _exclusiveLockCounts[resourceType.TypeId()];
                ConcurrentMap <long, ForsetiLockManager.Lock> resourceTypeLocks = _lockMaps[resourceType.TypeId()];
                foreach (long resourceId in resourceIds)
                {
                    if (ReleaseLocalLock(resourceType, resourceId, sharedLocks))
                    {
                        continue;
                    }
                    // Only release if we were not holding an exclusive lock as well
                    if (!exclusiveLocks.containsKey(resourceId))
                    {
                        ReleaseGlobalLock(resourceTypeLocks, resourceId);
                    }
                }
            }
            finally
            {
                _stateHolder.decrementActiveClients();
            }
        }
        /// <exception cref="System.IO.IOException"/>
        public virtual void ApplicationAttemptFinished(ApplicationAttemptFinishData appAttemptFinish
                                                       )
        {
            ConcurrentMap <ApplicationAttemptId, ApplicationAttemptHistoryData> subMap = GetSubMap
                                                                                             (appAttemptFinish.GetApplicationAttemptId().GetApplicationId());
            ApplicationAttemptHistoryData data = subMap[appAttemptFinish.GetApplicationAttemptId
                                                            ()];

            if (data == null)
            {
                throw new IOException("The finish information of application attempt " + appAttemptFinish
                                      .GetApplicationAttemptId() + " is stored before" + " the start information.");
            }
            // Make the assumption that YarnApplicationAttemptState should not be null
            // if the finish information is already recorded
            if (data.GetYarnApplicationAttemptState() != null)
            {
                throw new IOException("The finish information of application attempt " + appAttemptFinish
                                      .GetApplicationAttemptId() + " is already stored.");
            }
            data.SetTrackingURL(appAttemptFinish.GetTrackingURL());
            data.SetDiagnosticsInfo(appAttemptFinish.GetDiagnosticsInfo());
            data.SetFinalApplicationStatus(appAttemptFinish.GetFinalApplicationStatus());
            data.SetYarnApplicationAttemptState(appAttemptFinish.GetYarnApplicationAttemptState
                                                    ());
        }
Beispiel #9
0
 internal Factory(WeakCache <K, P, V> outerInstance, K key, P parameter, Object subKey, ConcurrentMap <Object, Supplier <V> > valuesMap)
 {
     this.OuterInstance = outerInstance;
     this.Key           = key;
     this.Parameter     = parameter;
     this.SubKey        = subKey;
     this.ValuesMap     = valuesMap;
 }
Beispiel #10
0
        private int MaybeScheduleASpeculation(TaskType type)
        {
            int  successes = 0;
            long now       = clock.GetTime();
            ConcurrentMap <JobId, AtomicInteger> containerNeeds = type == TaskType.Map ? mapContainerNeeds
                                 : reduceContainerNeeds;

            foreach (KeyValuePair <JobId, AtomicInteger> jobEntry in containerNeeds)
            {
                // This race conditon is okay.  If we skip a speculation attempt we
                //  should have tried because the event that lowers the number of
                //  containers needed to zero hasn't come through, it will next time.
                // Also, if we miss the fact that the number of containers needed was
                //  zero but increased due to a failure it's not too bad to launch one
                //  container prematurely.
                if (jobEntry.Value.Get() > 0)
                {
                    continue;
                }
                int numberSpeculationsAlready = 0;
                int numberRunningTasks        = 0;
                // loop through the tasks of the kind
                Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = context.GetJob(jobEntry.Key);
                IDictionary <TaskId, Task> tasks  = job.GetTasks(type);
                int numberAllowedSpeculativeTasks = (int)Math.Max(minimumAllowedSpeculativeTasks,
                                                                  proportionTotalTasksSpeculatable * tasks.Count);
                TaskId bestTaskID           = null;
                long   bestSpeculationValue = -1L;
                // this loop is potentially pricey.
                // TODO track the tasks that are potentially worth looking at
                foreach (KeyValuePair <TaskId, Task> taskEntry in tasks)
                {
                    long mySpeculationValue = SpeculationValue(taskEntry.Key, now);
                    if (mySpeculationValue == AlreadySpeculating)
                    {
                        ++numberSpeculationsAlready;
                    }
                    if (mySpeculationValue != NotRunning)
                    {
                        ++numberRunningTasks;
                    }
                    if (mySpeculationValue > bestSpeculationValue)
                    {
                        bestTaskID           = taskEntry.Key;
                        bestSpeculationValue = mySpeculationValue;
                    }
                }
                numberAllowedSpeculativeTasks = (int)Math.Max(numberAllowedSpeculativeTasks, proportionRunningTasksSpeculatable
                                                              * numberRunningTasks);
                // If we found a speculation target, fire it off
                if (bestTaskID != null && numberAllowedSpeculativeTasks > numberSpeculationsAlready)
                {
                    AddSpeculativeAttempt(bestTaskID);
                    ++successes;
                }
            }
            return(successes);
        }
Beispiel #11
0
 internal SharedDiscoveryService()
 {
     _coreMembers      = new ConcurrentDictionary <MemberId, CoreServerInfo>();
     _readReplicas     = new ConcurrentDictionary <MemberId, ReadReplicaInfo>();
     _listeningClients = new CopyOnWriteArrayList <SharedDiscoveryCoreClient>();
     _clusterIdDbNames = new ConcurrentDictionary <string, ClusterId>();
     _leaderMap        = new ConcurrentDictionary <string, LeaderInfo>();
     _enoughMembers    = new System.Threading.CountdownEvent(MIN_DISCOVERY_MEMBERS);
 }
Beispiel #12
0
        /// <summary>
        /// Lazily initializes the internal data structure for tracking the specified
        /// phase and step.
        /// </summary>
        /// <remarks>
        /// Lazily initializes the internal data structure for tracking the specified
        /// phase and step.  Returns either the newly initialized data structure or the
        /// existing one.  Initialization is atomic, so there is no risk of lost updates
        /// even if multiple threads attempt to initialize the same step simultaneously.
        /// </remarks>
        /// <param name="phase">Phase to initialize</param>
        /// <param name="step">Step to initialize</param>
        /// <returns>StepTracking newly initialized, or existing if found</returns>
        private StepTracking LazyInitStep(Phase phase, Step step)
        {
            ConcurrentMap <Step, StepTracking> steps = phases[phase].steps;

            if (!steps.Contains(step))
            {
                steps.PutIfAbsent(step, new StepTracking());
            }
            return(steps[step]);
        }
 public _RMContextImpl_159(ConcurrentMap <ApplicationId, RMApp> applicationsMaps, Dispatcher
                           baseArg1, ContainerAllocationExpirer baseArg2, AMLivelinessMonitor baseArg3, AMLivelinessMonitor
                           baseArg4, DelegationTokenRenewer baseArg5, AMRMTokenSecretManager baseArg6, RMContainerTokenSecretManager
                           baseArg7, NMTokenSecretManagerInRM baseArg8, ClientToAMTokenSecretManagerInRM baseArg9
                           , ResourceScheduler baseArg10)
     : base(baseArg1, baseArg2, baseArg3, baseArg4, baseArg5, baseArg6, baseArg7, baseArg8
            , baseArg9, baseArg10)
 {
     this.applicationsMaps = applicationsMaps;
 }
Beispiel #14
0
 public _RMContextImpl_121(ConcurrentMap <ApplicationId, RMApp> map, Dispatcher baseArg1
                           , ContainerAllocationExpirer baseArg2, AMLivelinessMonitor baseArg3, AMLivelinessMonitor
                           baseArg4, DelegationTokenRenewer baseArg5, AMRMTokenSecretManager baseArg6, RMContainerTokenSecretManager
                           baseArg7, NMTokenSecretManagerInRM baseArg8, ClientToAMTokenSecretManagerInRM baseArg9
                           )
     : base(baseArg1, baseArg2, baseArg3, baseArg4, baseArg5, baseArg6, baseArg7, baseArg8
            , baseArg9)
 {
     this.map = map;
 }
Beispiel #15
0
 internal ConcurrentMapState(ReadableState <Key> store, File file, VersionContextSupplier versionContextSupplier) : base(store, versionContextSupplier)
 {
     this._previousVersion        = store.Version();
     this._file                   = file;
     this._versionContextSupplier = versionContextSupplier;
     this._highestAppliedVersion  = new AtomicLong(_previousVersion);
     this._changes                = new ConcurrentDictionary <Key, ChangeEntry>();
     this._appliedChanges         = new AtomicLong();
     _hasTrackedChanges           = new AtomicBoolean();
 }
Beispiel #16
0
 private ConcurrentMapState(Prototype <Key> prototype, ReadableState <Key> store, File file, VersionContextSupplier versionContextSupplier) : base(store, versionContextSupplier)
 {
     this._previousVersion        = store.Version();
     this._versionContextSupplier = versionContextSupplier;
     this._file = file;
     this._hasTrackedChanges     = prototype.HasTrackedChanges;
     this._changes               = prototype.Changes;
     this._highestAppliedVersion = prototype.HighestAppliedVersion;
     this._appliedChanges        = prototype.AppliedChanges;
 }
Beispiel #17
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static <Key> DataProvider dataProvider(ReadableState<Key> store, java.util.concurrent.ConcurrentMap<Key, ChangeEntry> changes) throws java.io.IOException
        private static DataProvider DataProvider <Key>(ReadableState <Key> store, ConcurrentMap <Key, ChangeEntry> changes)
        {
            if (changes.Empty)
            {
                return(store.DataProvider());
            }
            else
            {
                KeyFormat <Key> keys = store.KeyFormat();
                return(new KeyValueMerger(store.DataProvider(), new UpdateProvider(SortedUpdates(keys, changes)), keys.KeySize(), keys.ValueSize()));
            }
        }
Beispiel #18
0
 public _RMContextImpl_183(ConcurrentMap <ApplicationId, RMApp> applicationsMaps, ConcurrentMap
                           <string, RMNode> deactivatedNodesMap, ConcurrentMap <NodeId, RMNode> nodesMap, Dispatcher
                           baseArg1, ContainerAllocationExpirer baseArg2, AMLivelinessMonitor baseArg3, AMLivelinessMonitor
                           baseArg4, DelegationTokenRenewer baseArg5, AMRMTokenSecretManager baseArg6, RMContainerTokenSecretManager
                           baseArg7, NMTokenSecretManagerInRM baseArg8, ClientToAMTokenSecretManagerInRM baseArg9
                           , ResourceScheduler baseArg10)
     : base(baseArg1, baseArg2, baseArg3, baseArg4, baseArg5, baseArg6, baseArg7, baseArg8
            , baseArg9, baseArg10)
 {
     this.applicationsMaps    = applicationsMaps;
     this.deactivatedNodesMap = deactivatedNodesMap;
     this.nodesMap            = nodesMap;
 }
 public TaskHeartbeatHandler(EventHandler eventHandler, Clock clock, int numThreads
                             )
     : base("TaskHeartbeatHandler")
 {
     //thread which runs periodically to see the last time since a heartbeat is
     //received from a task.
     // 5 mins
     // 30 seconds.
     this.eventHandler = eventHandler;
     this.clock        = clock;
     runningAttempts   = new ConcurrentHashMap <TaskAttemptId, TaskHeartbeatHandler.ReportTime
                                                >(16, 0.75f, numThreads);
 }
Beispiel #20
0
        public override void ReleaseExclusive(ResourceType resourceType, params long[] resourceIds)
        {
            _stateHolder.incrementActiveClients(this);

            try
            {
                ConcurrentMap <long, ForsetiLockManager.Lock> resourceTypeLocks = _lockMaps[resourceType.TypeId()];
                MutableLongIntMap exclusiveLocks = _exclusiveLockCounts[resourceType.TypeId()];
                MutableLongIntMap sharedLocks    = _sharedLockCounts[resourceType.TypeId()];
                foreach (long resourceId in resourceIds)
                {
                    if (ReleaseLocalLock(resourceType, resourceId, exclusiveLocks))
                    {
                        continue;
                    }

                    if (sharedLocks.containsKey(resourceId))
                    {
                        // We are still holding a shared lock, so we will release it to be reused
                        ForsetiLockManager.Lock @lock = resourceTypeLocks.get(resourceId);
                        if (@lock is SharedLock)
                        {
                            SharedLock sharedLock = ( SharedLock )@lock;
                            if (sharedLock.UpdateLock)
                            {
                                sharedLock.ReleaseUpdateLock();
                            }
                            else
                            {
                                throw new System.InvalidOperationException("Incorrect state of exclusive lock. Lock should be updated " + "to exclusive before attempt to release it. Lock: " + this);
                            }
                        }
                        else
                        {
                            // in case if current lock is exclusive we swap it to new shared lock
                            SharedLock sharedLock = new SharedLock(this);
                            resourceTypeLocks.put(resourceId, sharedLock);
                        }
                    }
                    else
                    {
                        // we do not hold shared lock so we just releasing it
                        ReleaseGlobalLock(resourceTypeLocks, resourceId);
                    }
                }
            }
            finally
            {
                _stateHolder.decrementActiveClients();
            }
        }
Beispiel #21
0
        public override bool TryExclusiveLock(ResourceType resourceType, long resourceId)
        {
            _hasLocks = true;
            _stateHolder.incrementActiveClients(this);

            try
            {
                ConcurrentMap <long, ForsetiLockManager.Lock> lockMap = _lockMaps[resourceType.TypeId()];
                MutableLongIntMap heldLocks = _exclusiveLockCounts[resourceType.TypeId()];

                int heldCount = heldLocks.getIfAbsent(resourceId, -1);
                if (heldCount != -1)
                {
                    // We already have a lock on this, just increment our local reference counter.
                    heldLocks.put(resourceId, Math.incrementExact(heldCount));
                    return(true);
                }

                // Grab the global lock
                ForsetiLockManager.Lock @lock;
                if ((@lock = lockMap.putIfAbsent(resourceId, _myExclusiveLock)) != null)
                {
                    if (@lock is SharedLock && _sharedLockCounts[resourceType.TypeId()].containsKey(resourceId))
                    {
                        SharedLock sharedLock = ( SharedLock )@lock;
                        if (sharedLock.TryAcquireUpdateLock(this))
                        {
                            if (sharedLock.NumberOfHolders() == 1)
                            {
                                heldLocks.put(resourceId, 1);
                                return(true);
                            }
                            else
                            {
                                sharedLock.ReleaseUpdateLock();
                                return(false);
                            }
                        }
                    }
                    return(false);
                }

                heldLocks.put(resourceId, 1);
                return(true);
            }
            finally
            {
                _stateHolder.decrementActiveClients();
            }
        }
Beispiel #22
0
                protected internal override void RebootNodeStatusUpdaterAndRegisterWithRM()
                {
                    ConcurrentMap <ContainerId, Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Container.Container
                                   > containers = this._enclosing.GetNMContext().GetContainers();

                    try
                    {
                        try
                        {
                            if (this._enclosing.containersShouldBePreserved)
                            {
                                NUnit.Framework.Assert.IsFalse(containers.IsEmpty());
                                NUnit.Framework.Assert.IsTrue(containers.Contains(this._enclosing.existingCid));
                                NUnit.Framework.Assert.AreEqual(ContainerState.Running, containers[this._enclosing
                                                                                                   .existingCid].CloneAndGetContainerStatus().GetState());
                            }
                            else
                            {
                                // ensure that containers are empty or are completed before
                                // restart nodeStatusUpdater
                                if (!containers.IsEmpty())
                                {
                                    NUnit.Framework.Assert.AreEqual(ContainerState.Complete, containers[this._enclosing
                                                                                                        .existingCid].CloneAndGetContainerStatus().GetState());
                                }
                            }
                            base.RebootNodeStatusUpdaterAndRegisterWithRM();
                        }
                        catch (Exception ae)
                        {
                            Sharpen.Runtime.PrintStackTrace(ae);
                            this._enclosing._enclosing.assertionFailedInThread.Set(true);
                        }
                        finally
                        {
                            this._enclosing._enclosing.syncBarrier.Await();
                        }
                    }
                    catch (Exception)
                    {
                    }
                    catch (BrokenBarrierException)
                    {
                    }
                    catch (Exception ae)
                    {
                        Sharpen.Runtime.PrintStackTrace(ae);
                        this._enclosing._enclosing.assertionFailedInThread.Set(true);
                    }
                }
Beispiel #23
0
        /*   *************************************************************    */
        // This section contains the code that gets run for a SpeculatorEvent
        private AtomicInteger ContainerNeed(TaskId taskID)
        {
            JobId    jobID    = taskID.GetJobId();
            TaskType taskType = taskID.GetTaskType();
            ConcurrentMap <JobId, AtomicInteger> relevantMap = taskType == TaskType.Map ? mapContainerNeeds
                                 : reduceContainerNeeds;
            AtomicInteger result = relevantMap[jobID];

            if (result == null)
            {
                relevantMap.PutIfAbsent(jobID, new AtomicInteger(0));
                result = relevantMap[jobID];
            }
            return(result);
        }
Beispiel #24
0
 /// <summary>
 /// Release a lock from the global pool. </summary>
 private void ReleaseGlobalLock(ConcurrentMap <long, ForsetiLockManager.Lock> lockMap, long resourceId)
 {
     ForsetiLockManager.Lock @lock = lockMap.get(resourceId);
     if (@lock is ExclusiveLock)
     {
         lockMap.remove(resourceId);
     }
     else if (@lock is SharedLock && (( SharedLock )@lock).Release(this))
     {
         // We were the last to hold this lock, it is now dead and we should remove it.
         // Also cleaning updater reference that can hold lock in memory
         (( SharedLock )@lock).CleanUpdateHolder();
         lockMap.remove(resourceId);
     }
 }
Beispiel #25
0
 /// <param name="playerManager"> Audio player manager </param>
 /// <param name="nodeAddress"> Address of this node </param>
 /// <param name="scheduledExecutor"> Scheduler to use to schedule reconnects </param>
 /// <param name="httpInterfaceManager"> HTTP interface manager to use for communicating with node </param>
 /// <param name="abandonedTrackManager"> Abandoned track manager, where the playing tracks are sent if node goes offline </param>
 public RemoteNodeProcessor(DefaultAudioPlayerManager playerManager, string nodeAddress, java.util.concurrent.ScheduledThreadPoolExecutor scheduledExecutor, HttpInterfaceManager httpInterfaceManager, AbandonedTrackManager abandonedTrackManager)
 {
     this.playerManager         = playerManager;
     this.nodeAddress           = nodeAddress;
     this.scheduledExecutor     = scheduledExecutor;
     this.httpInterfaceManager  = httpInterfaceManager;
     this.abandonedTrackManager = abandonedTrackManager;
     queuedMessages             = new LinkedBlockingQueue <>();
     playingTracks   = new ConcurrentHashMap <>();
     mapper          = new RemoteMessageMapper();
     threadRunning   = new AtomicBoolean();
     connectionState = new AtomicInteger(ConnectionState.OFFLINE.id());
     tickHistory     = new LinkedList <>(NODE_REQUEST_HISTORY);
     closed          = false;
 }
        /// <exception cref="System.IO.IOException"/>
        public virtual IDictionary <ContainerId, ContainerHistoryData> GetContainers(ApplicationAttemptId
                                                                                     appAttemptId)
        {
            ConcurrentMap <ContainerId, ContainerHistoryData> subMap = containerData[appAttemptId
                                                                       ];

            if (subMap == null)
            {
                return(Sharpen.Collections.EmptyMap <ContainerId, ContainerHistoryData>());
            }
            else
            {
                return(new Dictionary <ContainerId, ContainerHistoryData>(subMap));
            }
        }
        internal FulltextIndexProvider(IndexProviderDescriptor descriptor, IndexDirectoryStructure.Factory directoryStructureFactory, FileSystemAbstraction fileSystem, Config config, TokenHolders tokenHolders, DirectoryFactory directoryFactory, OperationalMode operationalMode, JobScheduler scheduler, AuxiliaryTransactionStateManager auxiliaryTransactionStateManager, Log log) : base(descriptor, directoryStructureFactory)
        {
            this._fileSystem      = fileSystem;
            this._config          = config;
            this._tokenHolders    = tokenHolders;
            this._operationalMode = operationalMode;
            this._auxiliaryTransactionStateManager = auxiliaryTransactionStateManager;
            this._log = log;

            _defaultAnalyzerName = config.Get(FulltextConfig.FulltextDefaultAnalyzer);
            _defaultEventuallyConsistentSetting = Convert.ToString(config.Get(FulltextConfig.EventuallyConsistent));
            _indexUpdateSink     = new IndexUpdateSink(scheduler, config.Get(FulltextConfig.EventuallyConsistentIndexUpdateQueueMaxLength));
            _openOnlineAccessors = new ConcurrentDictionary <StoreIndexDescriptor, FulltextIndexAccessor>();
            _indexStorageFactory = BuildIndexStorageFactory(fileSystem, directoryFactory);
        }
        /// <exception cref="System.IO.IOException"/>
        public virtual void ContainerStarted(ContainerStartData containerStart)
        {
            ConcurrentMap <ContainerId, ContainerHistoryData> subMap = GetSubMap(containerStart
                                                                                 .GetContainerId().GetApplicationAttemptId());
            ContainerHistoryData oldData = subMap.PutIfAbsent(containerStart.GetContainerId()
                                                              , ContainerHistoryData.NewInstance(containerStart.GetContainerId(), containerStart
                                                                                                 .GetAllocatedResource(), containerStart.GetAssignedNode(), containerStart.GetPriority
                                                                                                     (), containerStart.GetStartTime(), long.MaxValue, null, int.MaxValue, null));

            if (oldData != null)
            {
                throw new IOException("The start information of container " + containerStart.GetContainerId
                                          () + " is already stored.");
            }
        }
        public virtual ApplicationAttemptHistoryData GetApplicationAttempt(ApplicationAttemptId
                                                                           appAttemptId)
        {
            ConcurrentMap <ApplicationAttemptId, ApplicationAttemptHistoryData> subMap = applicationAttemptData
                                                                                         [appAttemptId.GetApplicationId()];

            if (subMap == null)
            {
                return(null);
            }
            else
            {
                return(subMap[appAttemptId]);
            }
        }
        /// <exception cref="System.IO.IOException"/>
        public virtual void ApplicationAttemptStarted(ApplicationAttemptStartData appAttemptStart
                                                      )
        {
            ConcurrentMap <ApplicationAttemptId, ApplicationAttemptHistoryData> subMap = GetSubMap
                                                                                             (appAttemptStart.GetApplicationAttemptId().GetApplicationId());
            ApplicationAttemptHistoryData oldData = subMap.PutIfAbsent(appAttemptStart.GetApplicationAttemptId
                                                                           (), ApplicationAttemptHistoryData.NewInstance(appAttemptStart.GetApplicationAttemptId
                                                                                                                             (), appAttemptStart.GetHost(), appAttemptStart.GetRPCPort(), appAttemptStart.GetMasterContainerId
                                                                                                                             (), null, null, null, null));

            if (oldData != null)
            {
                throw new IOException("The start information of application attempt " + appAttemptStart
                                      .GetApplicationAttemptId() + " is already stored.");
            }
        }