public void StopPlugin()
        {
            Log.Info("StopPlugin");

            Status = StatusEnum.Stopping;

            _cancellationTokenSource.Cancel();

            if (_taskManager != null)
            {
                _taskManager.ShutDown();
                _taskManager = null;
            }

            if (_queuesManager != null)
            {
                _queuesManager.ShutDown();
                _queuesManager = null;
            }

            if (_octaneApis != null)
            {
                _octaneApis.ShutDown();
                _octaneApis = null;
            }

            _octaneInitializationThread = null;
            Status = StatusEnum.Stopped;

            Log.Info("StopPlugin Done");
        }
Esempio n. 2
0
        public void StopPlugin(bool waitShutdown)
        {
            Status = StatusEnum.Stopping;
            StopAllThreads();
            if (waitShutdown)
            {
                if (_octaneInitializationThread != null)
                {
                    _octaneInitializationThread.Wait();
                }

                if (_queuesManager != null)
                {
                    _queuesManager.WaitShutdown();
                }

                if (_taskManager != null)
                {
                    _taskManager.WaitShutdown();
                }
            }

            _octaneInitializationThread = null;
            _taskManager   = null;
            _queuesManager = null;
            Status         = StatusEnum.Stopped;
        }
Esempio n. 3
0
        public QueueManagerTests()
        {
            _queueSenderMock        = Substitute.For <IQueueSender>();
            _commandsSerializerMock = Substitute.For <ICommandsSerializer>();
            _settings = new QueueManagerSettings("1");

            _queuesManager = new QueuesManager(_queueSenderMock, _commandsSerializerMock, _settings);
        }
Esempio n. 4
0
        private void StartPluginInternal(CancellationToken token)
        {
            Status = StatusEnum.Connecting;
            while (Status != StatusEnum.Connected && !token.IsCancellationRequested)
            {
                try
                {
                    TfsApis    tfsApis    = ConnectionCreator.CreateTfsConnection(_connectionDetails);
                    OctaneApis octaneApis = ConnectionCreator.CreateOctaneConnection(_connectionDetails);

                    _taskManager = new OctaneTaskManager(tfsApis, octaneApis);
                    _taskManager.Start();
                    _queuesManager = new QueuesManager(tfsApis, octaneApis);
                    _queuesManager.Start();

                    _initFailCounter = 0;
                    Status           = StatusEnum.Connected;
                }
                catch (Exception ex)
                {
                    Log.Error($"Error in StartPlugin : {ex.Message}", ex);
                    if (_queuesManager != null)
                    {
                        _queuesManager.ShutDown();
                        _queuesManager = null;
                    }
                    if (_taskManager != null)
                    {
                        _taskManager.ShutDown();
                        _taskManager = null;
                    }
                }

                //Sleep till next retry
                if (Status != StatusEnum.Connected)
                {
                    int initTimeoutIndex   = Math.Min((_initFailCounter / 3), _initTimeoutInMinutesArr.Length - 1);
                    int initTimeoutMinutes = _initTimeoutInMinutesArr[initTimeoutIndex];
                    Log.Info($"Wait {initTimeoutMinutes} minute(s) till next initialization attempt...");
                    Thread.Sleep(initTimeoutMinutes * 1000 * 60);
                    _initFailCounter++;
                }
            }
        }