#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< EjfatURI > | getFromEnv (const std::string &envVar="EJFAT_URI"s, TokenType tt=TokenType::admin, bool preferV6=false) noexcept |
static result< EjfatURI > | getFromString (const std::string &uriStr, TokenType tt=TokenType::admin, bool preferV6=false) noexcept |
static result< EjfatURI > | getFromFile (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) |
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
e2sar::EjfatURI::EjfatURI | ( | const std::string & | uri, |
TokenType | tt = TokenType::admin, | ||
bool | pV6 = false ) |
base constructor, sets instance token from string
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
uri | URI to parse. |
|
inline |
destructor
|
inline |
return the admin token
|
inline |
get control plane ip address and port
|
inline |
get control plane hostname and port
|
inlinenoexcept |
get data plane v4 address and port
|
inlinenoexcept |
get data plane v6 address and port
|
inline |
get instance token
|
inline |
get LB ID
|
inline |
get LB name
|
inline |
get session Id
|
inline |
get session token
|
inlinenoexcept |
get sync address and port
|
inline |
check if TLS should be used
|
noexcept |
Figure out the local outgoing dataplane addresses based on data= entries in the URI. This only works where NETLINK is available (Linux)
v6 | - if true look for v6 (default false) |
|
inlinestaticnoexcept |
from environment variable
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 |
|
inlinestaticnoexcept |
from a file
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 |
|
inlinestaticnoexcept |
from string
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 |
|
inline |
does the URI contain any dataplane address?
|
inline |
does the URI contain a v4 dataplane address?
|
inline |
does the URI contain a v6 dataplane address?
|
inline |
does the URI contain a sync address
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
|
inline |
Set a dataplane address (v4 or v6)
|
inline |
set instance token based on gRPC return
|
inline |
set LB Id
|
inline |
set LB name
|
inline |
set session Id from gRPC return
|
inline |
set session token based on gRPC return
|
inline |
Set the sync address (v4 or v6)