LCOV - code coverage report
Current view: top level - serverManager/common/source - SessionServerAppManager.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 96.7 % 274 265
Test Date: 2025-10-07 14:22:52 Functions: 100.0 % 39 39

            Line data    Source code
       1              : /*
       2              :  * If not stated otherwise in this file or this component's LICENSE file the
       3              :  * following copyright and licenses apply:
       4              :  *
       5              :  * Copyright 2022 Sky UK
       6              :  *
       7              :  * Licensed under the Apache License, Version 2.0 (the "License");
       8              :  * you may not use this file except in compliance with the License.
       9              :  * You may obtain a copy of the License at
      10              :  *
      11              :  * http://www.apache.org/licenses/LICENSE-2.0
      12              :  *
      13              :  * Unless required by applicable law or agreed to in writing, software
      14              :  * distributed under the License is distributed on an "AS IS" BASIS,
      15              :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      16              :  * See the License for the specific language governing permissions and
      17              :  * limitations under the License.
      18              :  */
      19              : 
      20              : #include "SessionServerAppManager.h"
      21              : #include "RialtoServerManagerLogging.h"
      22              : #include "Utils.h"
      23              : #include <algorithm>
      24              : #include <future>
      25              : #include <utility>
      26              : 
      27              : namespace
      28              : {
      29              : const std::unique_ptr<rialto::servermanager::common::ISessionServerApp> kInvalidSessionServer;
      30              : } // namespace
      31              : 
      32              : namespace rialto::servermanager::common
      33              : {
      34           32 : SessionServerAppManager::SessionServerAppManager(
      35              :     std::unique_ptr<ipc::IController> &ipcController, const std::shared_ptr<service::IStateObserver> &stateObserver,
      36              :     std::unique_ptr<ISessionServerAppFactory> &&sessionServerAppFactory,
      37              :     std::unique_ptr<IHealthcheckServiceFactory> &&healthcheckServiceFactory,
      38              :     const std::shared_ptr<firebolt::rialto::common::IEventThreadFactory> &eventThreadFactory,
      39           32 :     const firebolt::rialto::ipc::INamedSocketFactory &namedSocketFactory)
      40           32 :     : m_ipcController{ipcController},
      41           64 :       m_eventThread{eventThreadFactory->createEventThread("rialtoservermanager-appmanager")},
      42           32 :       m_sessionServerAppFactory{std::move(sessionServerAppFactory)}, m_stateObserver{stateObserver},
      43           32 :       m_healthcheckService{healthcheckServiceFactory->createHealthcheckService(*this)},
      44           64 :       m_namedSocketFactory{namedSocketFactory}, m_isShuttingDown{false}
      45              : {
      46           32 : }
      47              : 
      48           64 : SessionServerAppManager::~SessionServerAppManager()
      49              : {
      50           32 :     m_eventThread->add(&SessionServerAppManager::shutdownAllSessionServers, this);
      51           32 :     m_eventThread->flush();
      52           32 :     m_eventThread.reset();
      53           64 : }
      54              : 
      55            7 : void SessionServerAppManager::preloadSessionServers(unsigned numOfPreloadedServers)
      56              : {
      57            7 :     m_eventThread->add(
      58            7 :         [this, numOfPreloadedServers]()
      59              :         {
      60           14 :             for (unsigned i = 0; i < numOfPreloadedServers; ++i)
      61              :             {
      62            7 :                 connectSessionServer(preloadSessionServer());
      63              :             }
      64            7 :         });
      65              : }
      66              : 
      67           28 : bool SessionServerAppManager::initiateApplication(const std::string &appName,
      68              :                                                   const firebolt::rialto::common::SessionServerState &state,
      69              :                                                   const firebolt::rialto::common::AppConfig &appConfig)
      70              : {
      71           28 :     std::promise<bool> p;
      72           28 :     std::future<bool> f{p.get_future()};
      73           56 :     m_eventThread->add([&]() { return p.set_value(handleInitiateApplication(appName, state, appConfig)); });
      74           56 :     return f.get();
      75           28 : }
      76              : 
      77           28 : bool SessionServerAppManager::handleInitiateApplication(const std::string &appName,
      78              :                                                         const firebolt::rialto::common::SessionServerState &state,
      79              :                                                         const firebolt::rialto::common::AppConfig &appConfig)
      80              : {
      81           28 :     RIALTO_SERVER_MANAGER_LOG_INFO("RialtoServerManager requests to launch %s with initial state: %s", appName.c_str(),
      82              :                                    toString(state));
      83           28 :     if (state != firebolt::rialto::common::SessionServerState::NOT_RUNNING && !getServerByAppName(appName))
      84              :     {
      85           26 :         const auto &preloadedServer{getPreloadedServer()};
      86           26 :         if (preloadedServer)
      87              :         {
      88            4 :             return configurePreloadedSessionServer(preloadedServer, appName, state, appConfig);
      89              :         }
      90           22 :         return connectSessionServer(launchSessionServer(appName, state, appConfig));
      91              :     }
      92            2 :     else if (state == firebolt::rialto::common::SessionServerState::NOT_RUNNING)
      93              :     {
      94            1 :         RIALTO_SERVER_MANAGER_LOG_ERROR("Initialization of %s failed - wrong state", appName.c_str());
      95              :     }
      96              :     else
      97              :     {
      98            1 :         RIALTO_SERVER_MANAGER_LOG_ERROR("Initialization of %s failed. App is already launched", appName.c_str());
      99              :     }
     100            2 :     return false;
     101              : }
     102              : 
     103            4 : bool SessionServerAppManager::setSessionServerState(const std::string &appName,
     104              :                                                     const firebolt::rialto::common::SessionServerState &newState)
     105              : {
     106            4 :     std::promise<bool> p;
     107            4 :     std::future<bool> f{p.get_future()};
     108            8 :     m_eventThread->add([&]() { return p.set_value(changeSessionServerState(appName, newState)); });
     109            8 :     return f.get();
     110            4 : }
     111              : 
     112           15 : void SessionServerAppManager::onSessionServerStateChanged(int serverId,
     113              :                                                           const firebolt::rialto::common::SessionServerState &newState)
     114              : {
     115           15 :     RIALTO_SERVER_MANAGER_LOG_DEBUG("Queue state change of serverId: %d to %s", serverId, toString(newState));
     116              :     // Event loop needed here, as function caller may be deleted as a result of this call
     117           15 :     m_eventThread->add(&SessionServerAppManager::handleSessionServerStateChange, this, serverId, newState);
     118              : }
     119              : 
     120            2 : void SessionServerAppManager::sendPingEvents(int pingId)
     121              : {
     122            2 :     RIALTO_SERVER_MANAGER_LOG_DEBUG("Queue ping procedure with id: %d", pingId);
     123            2 :     m_eventThread->add(
     124            2 :         [this, pingId]()
     125              :         {
     126            2 :             if (m_healthcheckService)
     127              :             {
     128            4 :                 for (const auto &sessionServer : m_sessionServerApps)
     129              :                 {
     130            2 :                     auto serverId{sessionServer->getServerId()};
     131            2 :                     if (!m_ipcController->performPing(serverId, pingId))
     132              :                     {
     133            1 :                         RIALTO_SERVER_MANAGER_LOG_ERROR("Ping with id: %d failed for server: %d", pingId, serverId);
     134            1 :                         m_healthcheckService->onPingFailed(serverId, pingId);
     135            1 :                         continue;
     136              :                     }
     137            1 :                     m_healthcheckService->onPingSent(serverId, pingId);
     138              :                 }
     139              :             }
     140            2 :         });
     141              : }
     142              : 
     143            2 : void SessionServerAppManager::onAck(int serverId, int pingId, bool success)
     144              : {
     145            2 :     RIALTO_SERVER_MANAGER_LOG_DEBUG("Queue ack handling for serverId: %d ping id: %d", serverId, pingId);
     146            2 :     m_eventThread->add(&SessionServerAppManager::handleAck, this, serverId, pingId, success);
     147              : }
     148              : 
     149            7 : std::string SessionServerAppManager::getAppConnectionInfo(const std::string &appName) const
     150              : {
     151            7 :     std::promise<std::string> p;
     152            7 :     std::future<std::string> f{p.get_future()};
     153            7 :     m_eventThread->add(
     154            7 :         [&]()
     155              :         {
     156            7 :             const auto &kSessionServer{getServerByAppName(appName)};
     157            7 :             if (kSessionServer)
     158              :             {
     159            1 :                 return p.set_value(kSessionServer->getSessionManagementSocketName());
     160              :             }
     161            6 :             RIALTO_SERVER_MANAGER_LOG_ERROR("App: %s could not be found", appName.c_str());
     162           18 :             return p.set_value("");
     163              :         });
     164           14 :     return f.get();
     165            7 : }
     166              : 
     167            2 : bool SessionServerAppManager::setLogLevels(const service::LoggingLevels &logLevels) const
     168              : {
     169            2 :     std::promise<bool> p;
     170            2 :     std::future<bool> f{p.get_future()};
     171            2 :     m_eventThread->add(
     172            2 :         [&]()
     173              :         {
     174            2 :             setLocalLogLevels(logLevels);
     175            2 :             if (!m_ipcController->setLogLevels(logLevels))
     176              :             {
     177            1 :                 RIALTO_SERVER_MANAGER_LOG_WARN("Change log levels failed.");
     178            1 :                 return p.set_value(false);
     179              :             }
     180            1 :             RIALTO_SERVER_MANAGER_LOG_INFO("Change log levels succeeded.");
     181            1 :             return p.set_value(true);
     182              :         });
     183            4 :     return f.get();
     184            2 : }
     185              : 
     186            2 : void SessionServerAppManager::restartServer(int serverId)
     187              : {
     188            2 :     RIALTO_SERVER_MANAGER_LOG_DEBUG("Queue restart server handling for serverId: %d", serverId);
     189            2 :     m_eventThread->add(&SessionServerAppManager::handleRestartServer, this, serverId);
     190              : }
     191              : 
     192            2 : void SessionServerAppManager::handleRestartServer(int serverId)
     193              : {
     194            2 :     if (m_isShuttingDown)
     195              :     {
     196            0 :         RIALTO_SERVER_MANAGER_LOG_DEBUG("Not restarting serverId: %d as server manager is shutting down", serverId);
     197            1 :         return;
     198              :     }
     199            2 :     const auto &kSessionServer{getServerById(serverId)};
     200            2 :     if (!kSessionServer)
     201              :     {
     202            0 :         RIALTO_SERVER_MANAGER_LOG_WARN("Unable to restart server, serverId: %d", serverId);
     203            0 :         return;
     204              :     }
     205              :     // First, get all needed information from current app
     206            2 :     const std::string kAppName{kSessionServer->getAppName()};
     207            2 :     const firebolt::rialto::common::SessionServerState kState{kSessionServer->getExpectedState()};
     208            2 :     const firebolt::rialto::common::AppConfig kAppConfig{kSessionServer->getSessionManagementSocketName(),
     209            2 :                                                          kSessionServer->getClientDisplayName()};
     210            2 :     std::unique_ptr<firebolt::rialto::ipc::INamedSocket> namedSocket{std::move(kSessionServer->releaseNamedSocket())};
     211            2 :     if (firebolt::rialto::common::SessionServerState::INACTIVE != kState &&
     212            1 :         firebolt::rialto::common::SessionServerState::ACTIVE != kState)
     213              :     {
     214            1 :         RIALTO_SERVER_MANAGER_LOG_DEBUG("Restart server to %s not needed for serverId: %d", toString(kState), serverId);
     215            1 :         return;
     216              :     }
     217            1 :     RIALTO_SERVER_MANAGER_LOG_DEBUG("Restarting server with id: %d", serverId);
     218              :     // Then kill the app
     219            1 :     kSessionServer->kill();
     220            1 :     handleSessionServerStateChange(serverId, firebolt::rialto::common::SessionServerState::NOT_RUNNING);
     221              : 
     222              :     // Finally, spawn the new app with old settings and set named socket if present
     223            1 :     auto app = m_sessionServerAppFactory->create(kAppName, kState, kAppConfig, *this, std::move(namedSocket));
     224            1 :     if (app->launch())
     225              :     {
     226            1 :         auto result = m_sessionServerApps.emplace(std::move(app));
     227            1 :         if (result.second)
     228              :         {
     229            1 :             connectSessionServer(*result.first);
     230              :         }
     231              :     }
     232              :     else
     233              :     {
     234            0 :         RIALTO_SERVER_MANAGER_LOG_ERROR("Failed to restart server");
     235              :     }
     236            4 : }
     237              : 
     238           35 : bool SessionServerAppManager::connectSessionServer(const std::unique_ptr<ISessionServerApp> &kSessionServer)
     239              : {
     240           35 :     if (!kSessionServer)
     241              :     {
     242            7 :         RIALTO_SERVER_MANAGER_LOG_ERROR("Unable to connect Session Server - pointer is null!");
     243            7 :         return false;
     244              :     }
     245           28 :     if (!m_ipcController->createClient(kSessionServer->getServerId(), kSessionServer->getAppManagementSocketName()))
     246              :     {
     247            2 :         RIALTO_SERVER_MANAGER_LOG_ERROR("Failed to establish RialtoServerManager - RialtoSessionServer connection for "
     248              :                                         "session server with id: %d",
     249              :                                         kSessionServer->getServerId());
     250            2 :         kSessionServer->kill();
     251            2 :         if (m_healthcheckService)
     252              :         {
     253            2 :             m_healthcheckService->onServerRemoved(kSessionServer->getServerId());
     254              :         }
     255            2 :         m_sessionServerApps.erase(kSessionServer);
     256            2 :         return false;
     257              :     }
     258           26 :     RIALTO_SERVER_MANAGER_LOG_INFO("RialtoServerManager with id %d successfully connected",
     259              :                                    kSessionServer->getServerId());
     260           26 :     return true;
     261              : }
     262              : 
     263            8 : bool SessionServerAppManager::configureSessionServer(const std::unique_ptr<ISessionServerApp> &kSessionServer)
     264              : {
     265            8 :     if (!kSessionServer)
     266              :     {
     267            0 :         RIALTO_SERVER_MANAGER_LOG_ERROR("Unable to configure Session Server - pointer is null!");
     268            0 :         return false;
     269              :     }
     270            8 :     if (kSessionServer->isNamedSocketInitialized())
     271              :     {
     272            2 :         return configureSessionServerWithSocketFd(kSessionServer);
     273              :     }
     274            6 :     return configureSessionServerWithSocketName(kSessionServer);
     275              : }
     276              : 
     277            4 : bool SessionServerAppManager::configurePreloadedSessionServer(const std::unique_ptr<ISessionServerApp> &kSessionServer,
     278              :                                                               const std::string &appName,
     279              :                                                               const firebolt::rialto::common::SessionServerState &state,
     280              :                                                               const firebolt::rialto::common::AppConfig &appConfig)
     281              : {
     282            4 :     RIALTO_SERVER_MANAGER_LOG_INFO("Configuration of preloaded session server with id: %d for %s app",
     283              :                                    kSessionServer->getServerId(), appName.c_str());
     284            4 :     if (kSessionServer->configure(appName, state, appConfig) && configureSessionServer(kSessionServer))
     285              :     {
     286              :         // Schedule adding new preloaded session server (as we've just used one) and return immediately
     287            4 :         m_eventThread->add([this]() { connectSessionServer(preloadSessionServer()); });
     288            2 :         return true;
     289              :     }
     290              :     // Configuration failed, kill server and return error
     291            2 :     handleSessionServerStateChange(kSessionServer->getServerId(), firebolt::rialto::common::SessionServerState::ERROR);
     292            2 :     kSessionServer->kill();
     293            2 :     handleSessionServerStateChange(kSessionServer->getServerId(),
     294              :                                    firebolt::rialto::common::SessionServerState::NOT_RUNNING);
     295              :     // Schedule adding new preloaded session server
     296            4 :     m_eventThread->add([this]() { connectSessionServer(preloadSessionServer()); });
     297            2 :     return false;
     298              : }
     299              : 
     300            4 : bool SessionServerAppManager::changeSessionServerState(const std::string &appName,
     301              :                                                        const firebolt::rialto::common::SessionServerState &newState)
     302              : {
     303            4 :     RIALTO_SERVER_MANAGER_LOG_INFO("RialtoServerManager requests to change state of %s to %s", appName.c_str(),
     304              :                                    toString(newState));
     305            4 :     const auto &kSessionServer{getServerByAppName(appName)};
     306            4 :     if (!kSessionServer)
     307              :     {
     308            1 :         RIALTO_SERVER_MANAGER_LOG_ERROR("Change state of %s to %s failed - session server not found.", appName.c_str(),
     309              :                                         toString(newState));
     310            1 :         return false;
     311              :     }
     312            3 :     kSessionServer->setExpectedState(newState);
     313            3 :     if (!m_ipcController->performSetState(kSessionServer->getServerId(), newState))
     314              :     {
     315            2 :         RIALTO_SERVER_MANAGER_LOG_ERROR("Change state of %s to %s failed.", appName.c_str(), toString(newState));
     316            2 :         handleStateChangeFailure(kSessionServer, newState);
     317            2 :         return false;
     318              :     }
     319            1 :     RIALTO_SERVER_MANAGER_LOG_INFO("Change state of %s to %s succeeded.", appName.c_str(), toString(newState));
     320            1 :     return true;
     321              : }
     322              : 
     323           26 : void SessionServerAppManager::handleSessionServerStateChange(int serverId,
     324              :                                                              firebolt::rialto::common::SessionServerState newState)
     325              : {
     326           26 :     RIALTO_SERVER_MANAGER_LOG_INFO("SessionServer with id: %d changed state to %s", serverId, toString(newState));
     327           26 :     const auto &kSessionServer{getServerById(serverId)};
     328           26 :     if (!kSessionServer)
     329              :     {
     330            0 :         RIALTO_SERVER_MANAGER_LOG_WARN("SessionServer with id: %d not found", serverId);
     331            0 :         return;
     332              :     }
     333           26 :     std::string appName{kSessionServer->getAppName()};
     334           26 :     if (!appName.empty() && m_stateObserver) // empty app name is when SessionServer is preloaded
     335              :     {
     336           17 :         m_stateObserver->stateChanged(appName, newState);
     337              :     }
     338           26 :     if (firebolt::rialto::common::SessionServerState::UNINITIALIZED == newState)
     339              :     {
     340           10 :         kSessionServer->cancelStartupTimer();
     341           10 :         if (!kSessionServer->isPreloaded() && !configureSessionServer(kSessionServer))
     342              :         {
     343            2 :             handleSessionServerStateChange(serverId, firebolt::rialto::common::SessionServerState::ERROR);
     344            2 :             kSessionServer->kill();
     345            2 :             handleSessionServerStateChange(serverId, firebolt::rialto::common::SessionServerState::NOT_RUNNING);
     346              :         }
     347              :     }
     348           16 :     else if (newState == firebolt::rialto::common::SessionServerState::ERROR && kSessionServer->isPreloaded())
     349              :     {
     350            1 :         m_ipcController->removeClient(serverId);
     351            1 :         kSessionServer->kill();
     352            1 :         if (m_healthcheckService)
     353              :         {
     354            1 :             m_healthcheckService->onServerRemoved(kSessionServer->getServerId());
     355              :         }
     356            1 :         m_sessionServerApps.erase(kSessionServer);
     357            1 :         connectSessionServer(preloadSessionServer());
     358              :     }
     359           15 :     else if (newState == firebolt::rialto::common::SessionServerState::NOT_RUNNING)
     360              :     {
     361            7 :         m_ipcController->removeClient(serverId);
     362            7 :         if (m_healthcheckService)
     363              :         {
     364            7 :             m_healthcheckService->onServerRemoved(kSessionServer->getServerId());
     365              :         }
     366            7 :         m_sessionServerApps.erase(kSessionServer);
     367              :     }
     368           26 : }
     369              : 
     370            2 : void SessionServerAppManager::handleAck(int serverId, int pingId, bool success)
     371              : {
     372            2 :     if (success)
     373              :     {
     374            1 :         RIALTO_SERVER_MANAGER_LOG_DEBUG("Ping with id: %d succeeded for server: %d", pingId, serverId);
     375              :     }
     376              :     else
     377              :     {
     378            1 :         RIALTO_SERVER_MANAGER_LOG_ERROR("Ping with id: %d failed for server: %d", pingId, serverId);
     379              :     }
     380            2 :     if (m_healthcheckService)
     381              :     {
     382            2 :         m_healthcheckService->onAckReceived(serverId, pingId, success);
     383              :     }
     384              : }
     385              : 
     386           32 : void SessionServerAppManager::shutdownAllSessionServers()
     387              : {
     388           32 :     m_isShuttingDown = true;
     389           32 :     m_healthcheckService.reset();
     390           50 :     for (const auto &kSessionServer : m_sessionServerApps)
     391              :     {
     392           18 :         kSessionServer->kill();
     393              :     }
     394           32 :     m_sessionServerApps.clear();
     395              : }
     396              : 
     397              : const std::unique_ptr<ISessionServerApp> &
     398           22 : SessionServerAppManager::launchSessionServer(const std::string &appName,
     399              :                                              const firebolt::rialto::common::SessionServerState &kInitialState,
     400              :                                              const firebolt::rialto::common::AppConfig &appConfig)
     401              : {
     402           22 :     RIALTO_SERVER_MANAGER_LOG_INFO("Launching Rialto Session Server for %s", appName.c_str());
     403           22 :     auto app = m_sessionServerAppFactory->create(appName, kInitialState, appConfig, *this,
     404           22 :                                                  m_namedSocketFactory.createNamedSocket());
     405           22 :     if (app->launch())
     406              :     {
     407           21 :         auto result = m_sessionServerApps.emplace(std::move(app));
     408           21 :         if (result.second)
     409              :         {
     410           21 :             return *result.first;
     411              :         }
     412              :     }
     413            1 :     return kInvalidSessionServer;
     414           22 : }
     415              : 
     416           12 : const std::unique_ptr<ISessionServerApp> &SessionServerAppManager::preloadSessionServer()
     417              : {
     418           12 :     RIALTO_SERVER_MANAGER_LOG_INFO("Preloading new Rialto Session Server");
     419           12 :     auto app = m_sessionServerAppFactory->create(*this, m_namedSocketFactory.createNamedSocket());
     420           12 :     if (app->launch())
     421              :     {
     422            6 :         auto result = m_sessionServerApps.emplace(std::move(app));
     423            6 :         if (result.second)
     424              :         {
     425            6 :             return *result.first;
     426              :         }
     427              :     }
     428            6 :     return kInvalidSessionServer;
     429           12 : }
     430              : 
     431           26 : const std::unique_ptr<ISessionServerApp> &SessionServerAppManager::getPreloadedServer() const
     432              : {
     433           26 :     auto iter = std::find_if(m_sessionServerApps.begin(), m_sessionServerApps.end(),
     434            4 :                              [](const auto &srv) { return srv->isPreloaded() && srv->isConnected(); });
     435           26 :     if (m_sessionServerApps.end() != iter)
     436              :     {
     437            4 :         return *iter;
     438              :     }
     439           22 :     return kInvalidSessionServer;
     440              : }
     441              : 
     442           38 : const std::unique_ptr<ISessionServerApp> &SessionServerAppManager::getServerByAppName(const std::string &appName) const
     443              : {
     444           38 :     auto iter{std::find_if(m_sessionServerApps.begin(), m_sessionServerApps.end(),
     445            9 :                            [&](const auto &srv) { return srv->getAppName() == appName; })};
     446           38 :     if (m_sessionServerApps.end() != iter)
     447              :     {
     448            5 :         return *iter;
     449              :     }
     450           33 :     return kInvalidSessionServer;
     451              : }
     452              : 
     453           28 : const std::unique_ptr<ISessionServerApp> &SessionServerAppManager::getServerById(int serverId) const
     454              : {
     455           28 :     auto iter{std::find_if(m_sessionServerApps.begin(), m_sessionServerApps.end(),
     456           28 :                            [&](const auto &srv) { return srv->getServerId() == serverId; })};
     457           28 :     if (m_sessionServerApps.end() != iter)
     458              :     {
     459           28 :         return *iter;
     460              :     }
     461            0 :     return kInvalidSessionServer;
     462              : }
     463              : 
     464            2 : void SessionServerAppManager::handleStateChangeFailure(const std::unique_ptr<ISessionServerApp> &kSessionServer,
     465              :                                                        const firebolt::rialto::common::SessionServerState &state)
     466              : {
     467            2 :     if (state == firebolt::rialto::common::SessionServerState::NOT_RUNNING)
     468              :     {
     469            1 :         RIALTO_SERVER_MANAGER_LOG_WARN("Force change of %s to NotRunning.", kSessionServer->getAppName().c_str());
     470            1 :         kSessionServer->kill();
     471            1 :         handleSessionServerStateChange(kSessionServer->getServerId(), state);
     472              :     }
     473              :     else
     474              :     {
     475            1 :         handleSessionServerStateChange(kSessionServer->getServerId(),
     476              :                                        firebolt::rialto::common::SessionServerState::ERROR);
     477              :     }
     478            2 : }
     479              : 
     480            6 : bool SessionServerAppManager::configureSessionServerWithSocketName(const std::unique_ptr<ISessionServerApp> &kSessionServer)
     481              : {
     482            6 :     RIALTO_SERVER_MANAGER_LOG_DEBUG("Configuring Session Server using socket name");
     483            6 :     const auto kInitialState{kSessionServer->getInitialState()};
     484            6 :     const auto kSocketName{kSessionServer->getSessionManagementSocketName()};
     485            6 :     const auto kClientDisplayName{kSessionServer->getClientDisplayName()};
     486            6 :     const auto kSocketPermissions{kSessionServer->getSessionManagementSocketPermissions()};
     487            6 :     const auto kSocketOwner{kSessionServer->getSessionManagementSocketOwner()};
     488            6 :     const auto kSocketGroup{kSessionServer->getSessionManagementSocketGroup()};
     489            6 :     const auto kAppName{kSessionServer->getAppName()};
     490              : 
     491            6 :     const firebolt::rialto::common::MaxResourceCapabilitites kMaxResource{kSessionServer->getMaxPlaybackSessions(),
     492            6 :                                                                           kSessionServer->getMaxWebAudioPlayers()};
     493            6 :     if (!m_ipcController->performSetConfiguration(kSessionServer->getServerId(), kInitialState, kSocketName,
     494              :                                                   kClientDisplayName, kMaxResource, kSocketPermissions, kSocketOwner,
     495              :                                                   kSocketGroup, kAppName))
     496              :     {
     497            2 :         RIALTO_SERVER_MANAGER_LOG_ERROR("Configuration of server with id %d failed - ipc error.",
     498              :                                         kSessionServer->getServerId());
     499            2 :         return false;
     500              :     }
     501            4 :     RIALTO_SERVER_MANAGER_LOG_INFO("Configuration of server with id %d succeeded.", kSessionServer->getServerId());
     502            4 :     return true;
     503            6 : }
     504              : 
     505            2 : bool SessionServerAppManager::configureSessionServerWithSocketFd(const std::unique_ptr<ISessionServerApp> &kSessionServer)
     506              : {
     507            2 :     RIALTO_SERVER_MANAGER_LOG_DEBUG("Configuring Session Server using socket fd");
     508            2 :     const auto kInitialState{kSessionServer->getInitialState()};
     509            2 :     const auto kSocketFd{kSessionServer->getSessionManagementSocketFd()};
     510            2 :     const auto kClientDisplayName{kSessionServer->getClientDisplayName()};
     511            2 :     const auto kAppName{kSessionServer->getAppName()};
     512              : 
     513            2 :     const firebolt::rialto::common::MaxResourceCapabilitites kMaxResource{kSessionServer->getMaxPlaybackSessions(),
     514            2 :                                                                           kSessionServer->getMaxWebAudioPlayers()};
     515            2 :     if (!m_ipcController->performSetConfiguration(kSessionServer->getServerId(), kInitialState, kSocketFd,
     516              :                                                   kClientDisplayName, kMaxResource, kAppName))
     517              :     {
     518            1 :         RIALTO_SERVER_MANAGER_LOG_ERROR("Configuration of server with id %d failed - ipc error.",
     519              :                                         kSessionServer->getServerId());
     520            1 :         return false;
     521              :     }
     522            1 :     RIALTO_SERVER_MANAGER_LOG_INFO("Configuration of server with id %d succeeded.", kSessionServer->getServerId());
     523            1 :     return true;
     524            2 : }
     525              : } // namespace rialto::servermanager::common
        

Generated by: LCOV version 2.0-1