Beispiel #1
0
    /// <summary>
    /// Enable and initialise the remote nodes. </summary>
    /// <param name="nodeAddresses"> Addresses of remote nodes </param>
    public virtual void initialise(IList <string> nodeAddresses)
    {
        lock (@lock)
        {
            if (enabled.compareAndSet(false, true))
            {
                startScheduler(nodeAddresses.Count + 1);
            }
            else
            {
                scheduler.CorePoolSize = nodeAddresses.Count + 1;
            }

            IList <string> newNodeAddresses = new List <string>(nodeAddresses);

            for (IEnumerator <RemoteNodeProcessor> iterator = processors.GetEnumerator(); iterator.MoveNext();)
            {
                RemoteNodeProcessor processor = iterator.Current;

                if (!newNodeAddresses.Remove(processor.NodeAddress))
                {
                    processor.shutdown();
                    //JAVA TO C# CONVERTER TODO TASK: .NET enumerators are read-only:
                    iterator.remove();
                }
            }

            foreach (string nodeAddress in newNodeAddresses)
            {
                RemoteNodeProcessor processor = new RemoteNodeProcessor(playerManager, nodeAddress, scheduler, httpInterfaceManager, abandonedTrackManager);

                scheduler.submit(processor);
                processors.Add(processor);
            }

            activeProcessors = new List <RemoteNodeProcessor>(processors);
        }
    }