SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
benchmax::ssh::SSHConnection Class Reference

A wrapper class that manages a single SSH connection as specified in a Node object (with all its channels). More...

#include <SSHConnection.h>

Collaboration diagram for benchmax::ssh::SSHConnection:

Public Member Functions

 SSHConnection (const Node &n)
 Create a new connection for the given node. More...
 
 ~SSHConnection ()
 Wait for all channels to terminate. More...
 
const NodegetNode () const
 Return the node. More...
 
bool jobFree ()
 Check if a new job could be started. More...
 
void newJob ()
 Increase job counter. More...
 
void finishJob ()
 Decrease job counter. More...
 
std::size_t jobs () const
 Current number of jobs. More...
 
bool busy ()
 Check if all channels are busy. More...
 
std::string createTmpDir (const std::string &folder)
 Create a temporary directory on the remote. More...
 
void removeDir (const std::string &folder)
 Remove a (temporary) directory on the remote.
More...
 
bool uploadFile (const fs::path &local, const std::string &base, const std::string &remote, int mode=S_IRUSR|S_IWUSR)
 Upload a file to the remote. More...
 
bool executeCommand (const std::string &cmd, BenchmarkResult &result)
 Execute a command on the remote. More...
 

Private Member Functions

std::chrono::milliseconds parse_duration (const std::string &output) const
 Parse a duration from stdout. More...
 
ssh_channel getChannel ()
 Allocate a new channel from the current SSH session. More...
 
ssh_scp getSCP (int mode, const std::string &basedir)
 Get a new SCP session for file transfer. More...
 
sftp_session getSFTP ()
 Get a new SFTP session for file transfer. More...
 
void destroy (ssh_channel channel)
 Terminate a SSH channel. More...
 
void destroy (ssh_scp scp)
 Terminate a SCP session. More...
 
void destroy (sftp_session sftp)
 Terminate a SFTP session. More...
 

Private Attributes

Node node
 The node object. More...
 
std::size_t curChannels
 The number of currently active channels. More...
 
std::size_t maxChannels
 The maximal number of channels allowed. More...
 
std::atomic< std::size_t > curJobs
 The number of currently running jobs. More...
 
ssh_session session
 The SSH session handle. More...
 
std::mutex mutex
 Mutex. More...
 
int verbosity
 Verbosity needed due to libssh interface. More...
 

Detailed Description

A wrapper class that manages a single SSH connection as specified in a Node object (with all its channels).

Definition at line 21 of file SSHConnection.h.

Constructor & Destructor Documentation

◆ SSHConnection()

benchmax::ssh::SSHConnection::SSHConnection ( const Node n)
inline

Create a new connection for the given node.

Definition at line 136 of file SSHConnection.h.

◆ ~SSHConnection()

benchmax::ssh::SSHConnection::~SSHConnection ( )
inline

Wait for all channels to terminate.

Definition at line 165 of file SSHConnection.h.

Member Function Documentation

◆ busy()

bool benchmax::ssh::SSHConnection::busy ( )
inline

Check if all channels are busy.

Definition at line 194 of file SSHConnection.h.

Here is the caller graph for this function:

◆ createTmpDir()

std::string benchmax::ssh::SSHConnection::createTmpDir ( const std::string &  folder)
inline

Create a temporary directory on the remote.

Definition at line 200 of file SSHConnection.h.

Here is the call graph for this function:

◆ destroy() [1/3]

void benchmax::ssh::SSHConnection::destroy ( sftp_session  sftp)
inlineprivate

Terminate a SFTP session.

Definition at line 128 of file SSHConnection.h.

◆ destroy() [2/3]

void benchmax::ssh::SSHConnection::destroy ( ssh_channel  channel)
inlineprivate

Terminate a SSH channel.

Definition at line 110 of file SSHConnection.h.

Here is the caller graph for this function:

◆ destroy() [3/3]

void benchmax::ssh::SSHConnection::destroy ( ssh_scp  scp)
inlineprivate

Terminate a SCP session.

Definition at line 119 of file SSHConnection.h.

◆ executeCommand()

bool benchmax::ssh::SSHConnection::executeCommand ( const std::string &  cmd,
BenchmarkResult result 
)
inline

Execute a command on the remote.

Definition at line 273 of file SSHConnection.h.

Here is the call graph for this function:

◆ finishJob()

void benchmax::ssh::SSHConnection::finishJob ( )
inline

Decrease job counter.

Definition at line 186 of file SSHConnection.h.

◆ getChannel()

ssh_channel benchmax::ssh::SSHConnection::getChannel ( )
inlineprivate

Allocate a new channel from the current SSH session.

Definition at line 53 of file SSHConnection.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNode()

const Node& benchmax::ssh::SSHConnection::getNode ( ) const
inline

Return the node.

Definition at line 173 of file SSHConnection.h.

◆ getSCP()

ssh_scp benchmax::ssh::SSHConnection::getSCP ( int  mode,
const std::string &  basedir 
)
inlineprivate

Get a new SCP session for file transfer.

Definition at line 72 of file SSHConnection.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSFTP()

sftp_session benchmax::ssh::SSHConnection::getSFTP ( )
inlineprivate

Get a new SFTP session for file transfer.

Definition at line 91 of file SSHConnection.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ jobFree()

bool benchmax::ssh::SSHConnection::jobFree ( )
inline

Check if a new job could be started.

Definition at line 177 of file SSHConnection.h.

◆ jobs()

std::size_t benchmax::ssh::SSHConnection::jobs ( ) const
inline

Current number of jobs.

Definition at line 190 of file SSHConnection.h.

◆ newJob()

void benchmax::ssh::SSHConnection::newJob ( )
inline

Increase job counter.

Definition at line 181 of file SSHConnection.h.

◆ parse_duration()

std::chrono::milliseconds benchmax::ssh::SSHConnection::parse_duration ( const std::string &  output) const
inlineprivate

Parse a duration from stdout.

Definition at line 39 of file SSHConnection.h.

Here is the caller graph for this function:

◆ removeDir()

void benchmax::ssh::SSHConnection::removeDir ( const std::string &  folder)
inline

Remove a (temporary) directory on the remote.

Definition at line 214 of file SSHConnection.h.

Here is the call graph for this function:

◆ uploadFile()

bool benchmax::ssh::SSHConnection::uploadFile ( const fs::path &  local,
const std::string &  base,
const std::string &  remote,
int  mode = S_IRUSR | S_IWUSR 
)
inline

Upload a file to the remote.

Definition at line 250 of file SSHConnection.h.

Here is the call graph for this function:

Field Documentation

◆ curChannels

std::size_t benchmax::ssh::SSHConnection::curChannels
private

The number of currently active channels.

Definition at line 26 of file SSHConnection.h.

◆ curJobs

std::atomic<std::size_t> benchmax::ssh::SSHConnection::curJobs
private

The number of currently running jobs.

Definition at line 30 of file SSHConnection.h.

◆ maxChannels

std::size_t benchmax::ssh::SSHConnection::maxChannels
private

The maximal number of channels allowed.

Definition at line 28 of file SSHConnection.h.

◆ mutex

std::mutex benchmax::ssh::SSHConnection::mutex
private

Mutex.

Definition at line 34 of file SSHConnection.h.

◆ node

Node benchmax::ssh::SSHConnection::node
private

The node object.

Definition at line 24 of file SSHConnection.h.

◆ session

ssh_session benchmax::ssh::SSHConnection::session
private

The SSH session handle.

Definition at line 32 of file SSHConnection.h.

◆ verbosity

int benchmax::ssh::SSHConnection::verbosity
private

Verbosity needed due to libssh interface.

Definition at line 36 of file SSHConnection.h.


The documentation for this class was generated from the following file: