E2SAR 0.2.0
All Data Structures Namespaces Functions Typedefs Enumerations
e2sar::EjfatURI Class Reference

#include <e2sarUtil.hpp>

Public Types

enum class  TokenType { admin , instance , session }
 

Public Member Functions

 EjfatURI (const std::string &uri, TokenType tt=TokenType::admin, bool preferV6=false)
 
 ~EjfatURI ()
 
bool get_useTls () const
 
void set_InstanceToken (const std::string &t)
 
void set_SessionToken (const std::string &t)
 
const result< std::string > get_InstanceToken () const
 
const result< std::string > get_SessionToken () const
 
const result< std::string > get_AdminToken () const
 
void set_lbName (const std::string &n)
 
void set_lbId (const std::string &i)
 
void set_sessionId (const std::string &i)
 
void set_syncAddr (const std::pair< ip::address, u_int16_t > &a)
 
void set_dataAddr (const std::pair< ip::address, u_int16_t > &a)
 
const std::string get_lbName () const
 
const std::string get_lbId () const
 
const std::string get_sessionId () const
 
const result< std::pair< ip::address, u_int16_t > > get_cpAddr () const
 
const result< std::pair< std::string, u_int16_t > > get_cpHost () const
 
const bool has_dataAddrv4 () const
 
const bool has_dataAddrv6 () const
 
const bool has_dataAddr () const
 
const bool has_syncAddr () const
 
const result< std::pair< ip::address, u_int16_t > > get_dataAddrv4 () const noexcept
 
const result< std::pair< ip::address, u_int16_t > > get_dataAddrv6 () const noexcept
 
const result< std::pair< ip::address, u_int16_t > > get_syncAddr () const noexcept
 
 operator std::string () const
 
const std::string to_string (TokenType tt=TokenType::admin) const
 
result< std::vector< ip::address > > getDataplaneLocalAddresses (bool v6=false) noexcept
 

Static Public Member Functions

static result< EjfatURIgetFromEnv (const std::string &envVar="EJFAT_URI"s, TokenType tt=TokenType::admin, bool preferV6=false) noexcept
 
static result< EjfatURIgetFromString (const std::string &uriStr, TokenType tt=TokenType::admin, bool preferV6=false) noexcept
 
static result< EjfatURIgetFromFile (const std::string &fileName="/tmp/ejfat_uri"s, TokenType tt=TokenType::admin, bool preferV6=false) noexcept
 

Friends

bool operator== (const EjfatURI &u1, const EjfatURI &u2)
 
bool operator!= (const EjfatURI &u1, const EjfatURI &u2)
 

Detailed Description

Structure to hold info parsed from an ejfat URI (and a little extra). The URI is of the format: ejfat[s]://[<token>@]<cp_host>:<cp_port>/lb/<lb_id>[?[data=<data_host>[:<data_port>]][&sync=<sync_host>:<sync_port>]][&sessionid=<string>]. More than one data= address can be specified (typically an IPv4 and IPv6). For data the port is optional and defaults to 19522, however for testing/debugging can be overridden

Constructor & Destructor Documentation

◆ EjfatURI()

e2sar::EjfatURI::EjfatURI ( const std::string & uri,
TokenType tt = TokenType::admin,
bool pV6 = false )

base constructor, sets instance token from string

Parameters
uri- the URI string
tt- convert to this token type (admin, instance, session)
preferV6- when connecting to the control plane, prefer IPv6 address if the name resolves to both (defaults to v4)

This is a class to maintain EJFAT URI. This URI contains information which both an event sender and event consumer can use to interact with the LB and CP as well as to send/receive packets in the dataplane. Different parts of the URI are used for different purposes in different contexts.

The URI is of the format: ejfat[s]://[<token>@]<cp_host>:<cp_port>/[lb/<lb_id>][?[data=<data_host>][&sync=<sync_host>:<sync_port>][&sessionid=<session id>]].

The token could be administrative, instance or session, depending on the context of the call. Constructor allows you to specify which token is in the URI string.

Load balancer ID can be specified if known (after the LB is reserved).

The data_host is the IP address to send events/data to. Likewise the sync_host & sync_port are the IP address and UDP port to which the sender sends sync messages.

Session id is used primarily for unregistering worker nodes and sending worker node queue state.

Addresses may be either ipV6 or ipV4, and a distinction is made between them. IPv6 address is surrounded with square brackets [] which are stripped off, as needed.

More information on the interpretation of different URI fields can be found in https://github.com/JeffersonLab/E2SAR/wiki/Integration

Parameters
uriURI to parse.

◆ ~EjfatURI()

e2sar::EjfatURI::~EjfatURI ( )
inline

destructor

Member Function Documentation

◆ get_AdminToken()

const result< std::string > e2sar::EjfatURI::get_AdminToken ( ) const
inline

return the admin token

◆ get_cpAddr()

const result< std::pair< ip::address, u_int16_t > > e2sar::EjfatURI::get_cpAddr ( ) const
inline

get control plane ip address and port

◆ get_cpHost()

const result< std::pair< std::string, u_int16_t > > e2sar::EjfatURI::get_cpHost ( ) const
inline

get control plane hostname and port

◆ get_dataAddrv4()

const result< std::pair< ip::address, u_int16_t > > e2sar::EjfatURI::get_dataAddrv4 ( ) const
inlinenoexcept

get data plane v4 address and port

◆ get_dataAddrv6()

const result< std::pair< ip::address, u_int16_t > > e2sar::EjfatURI::get_dataAddrv6 ( ) const
inlinenoexcept

get data plane v6 address and port

◆ get_InstanceToken()

const result< std::string > e2sar::EjfatURI::get_InstanceToken ( ) const
inline

get instance token

◆ get_lbId()

const std::string e2sar::EjfatURI::get_lbId ( ) const
inline

get LB ID

◆ get_lbName()

const std::string e2sar::EjfatURI::get_lbName ( ) const
inline

get LB name

◆ get_sessionId()

const std::string e2sar::EjfatURI::get_sessionId ( ) const
inline

get session Id

◆ get_SessionToken()

const result< std::string > e2sar::EjfatURI::get_SessionToken ( ) const
inline

get session token

◆ get_syncAddr()

const result< std::pair< ip::address, u_int16_t > > e2sar::EjfatURI::get_syncAddr ( ) const
inlinenoexcept

get sync address and port

◆ get_useTls()

bool e2sar::EjfatURI::get_useTls ( ) const
inline

check if TLS should be used

◆ getDataplaneLocalAddresses()

result< std::vector< ip::address > > e2sar::EjfatURI::getDataplaneLocalAddresses ( bool v6 = false)
noexcept

Figure out the local outgoing dataplane addresses based on data= entries in the URI. This only works where NETLINK is available (Linux)

Parameters
v6- if true look for v6 (default false)

◆ getFromEnv()

static result< EjfatURI > e2sar::EjfatURI::getFromEnv ( const std::string & envVar = "EJFAT_URI"s,
TokenType tt = TokenType::admin,
bool preferV6 = false )
inlinestaticnoexcept

from environment variable

Parameters
envVar- name of environment variable containing the URI (defaults to EJFAT_URI)
tt- token type - one of EjfatURI::TokenType::[admin, instance, session], defaults to admin
preferV6- if control plane host specified by name use IPv6 address, defaults to false

◆ getFromFile()

static result< EjfatURI > e2sar::EjfatURI::getFromFile ( const std::string & fileName = "/tmp/ejfat_uri"s,
TokenType tt = TokenType::admin,
bool preferV6 = false )
inlinestaticnoexcept

from a file

Parameters
filename- file containing URI string
tt- token type - one of EjfatURI::TokenType::[admin, instance, session], defaults to admin
preferV6- if control plane host specified by name use IPv6 address, defaults to false

◆ getFromString()

static result< EjfatURI > e2sar::EjfatURI::getFromString ( const std::string & uriStr,
TokenType tt = TokenType::admin,
bool preferV6 = false )
inlinestaticnoexcept

from string

Parameters
uriStr- URI string
tt- token type - one of EjfatURI::TokenType::[admin, instance, session], defaults to admin
preferV6- if control plane host specified by name use IPv6 address, defaults to false

◆ has_dataAddr()

const bool e2sar::EjfatURI::has_dataAddr ( ) const
inline

does the URI contain any dataplane address?

◆ has_dataAddrv4()

const bool e2sar::EjfatURI::has_dataAddrv4 ( ) const
inline

does the URI contain a v4 dataplane address?

◆ has_dataAddrv6()

const bool e2sar::EjfatURI::has_dataAddrv6 ( ) const
inline

does the URI contain a v6 dataplane address?

◆ has_syncAddr()

const bool e2sar::EjfatURI::has_syncAddr ( ) const
inline

does the URI contain a sync address

◆ operator std::string()

e2sar::EjfatURI::operator std::string ( ) const

implicit cast to string which prints session token if available, otherwise insstance token if available, otherwise admin token if available, otherwise no token. To get the URI string with specific token use the to_string(TokenType) method.

implicit conversion operator

◆ set_dataAddr()

void e2sar::EjfatURI::set_dataAddr ( const std::pair< ip::address, u_int16_t > & a)
inline

Set a dataplane address (v4 or v6)

◆ set_InstanceToken()

void e2sar::EjfatURI::set_InstanceToken ( const std::string & t)
inline

set instance token based on gRPC return

◆ set_lbId()

void e2sar::EjfatURI::set_lbId ( const std::string & i)
inline

set LB Id

◆ set_lbName()

void e2sar::EjfatURI::set_lbName ( const std::string & n)
inline

set LB name

◆ set_sessionId()

void e2sar::EjfatURI::set_sessionId ( const std::string & i)
inline

set session Id from gRPC return

◆ set_SessionToken()

void e2sar::EjfatURI::set_SessionToken ( const std::string & t)
inline

set session token based on gRPC return

◆ set_syncAddr()

void e2sar::EjfatURI::set_syncAddr ( const std::pair< ip::address, u_int16_t > & a)
inline

Set the sync address (v4 or v6)


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