Class SshSessionPool

java.lang.Object
org.qubership.atp.mia.repo.impl.pool.ssh.SshSessionPool
All Implemented Interfaces:
ConnectionPool

@Service public class SshSessionPool extends Object implements ConnectionPool
  • Field Details

    • systemsForTimeShifting

      public static final Map<UUID,Boolean> systemsForTimeShifting
    • KEEP_ALIVE_MSG_INTERVAL

      public static int KEEP_ALIVE_MSG_INTERVAL
  • Constructor Details

    • SshSessionPool

      public SshSessionPool(@Value("${ssh.close.delay:300}") String cleanTimeout, @Value("${db.server.keep.alive:30000}") String keepAlive, MiaContext miaContext)
      Creates connection pool for SSH connections. After cleanTimeout (seconds) removes ssh connection from cache. Also every cleanTimeout (seconds) performs cleaning connections.
      Parameters:
      cleanTimeout - after this timeout in seconds cache will be
  • Method Details

    • addTimeShiftSession

      public void addTimeShiftSession(Server server, CommonConfiguration configuration)
      Adds SystemId and its time shift status, also creates/reopens session. We avoid recreation of timeShift session on purpose, because establishing such connection requires readiness of both connection sides.
      Parameters:
      server - - with ssh server credentials.
      configuration - - configuration to configure keystore.
    • removeTimeShiftSession

      public void removeTimeShiftSession(Server server)
      Removes and closes time shift session.
      Parameters:
      server - - which session need to remove.
    • getConnection

      public SshConnectionManager getConnection(Server server, String extPrefix)
      Checks if there is available connection in Cache. If it is then returns already opened connection otherwise creates a new one and overrides old.
      Specified by:
      getConnection in interface ConnectionPool
      Parameters:
      server - - object with ssh server credentials.
      Returns:
      SshConnectionManager which is ready to execute ssh commands.
    • cleanConnectionCache

      public void cleanConnectionCache()
      Invalidates all free and not executing connection in cache (soft clean).
    • cleanTimeShiftMap

      public void cleanTimeShiftMap()
      Removes all not time shifted entities (with false as a key).
    • resetCache

      public void resetCache()
      Specified by:
      resetCache in interface ConnectionPool