kea-custom-hooks
FeM custom hooks libraries for Kea DHCP
Public Types | Public Member Functions | Static Public Attributes | List of all members
arpwatch::Exporter Class Reference

Main lease-to-Redis/ARPwatch exporter. More...

#include <Exporter.hpp>

Public Types

using mac_addr_t = isc::dhcp::HWAddr
 
using ip4_addr_t = isc::asiolink::IOAddress
 
using subnet_id_t = isc::dhcp::SubnetID
 
using lease4_t = std::tuple< mac_addr_t, ip4_addr_t, subnet_id_t, std::chrono::seconds >
 

Public Member Functions

 Exporter (HiredisAdapter &redis_adapter, ArpwatchRPC &arpwatch_rpc)
 
 Exporter (const Exporter &)=delete
 
Exporteroperator= (const Exporter &)=delete
 
 Exporter (Exporter &&)=delete
 
Exporteroperator= (Exporter &&)=delete
 
 ~Exporter ()
 
Worker thread control
void start_worker ()
 
void stop_worker ()
 
Lease queue actions
void push_lease (const mac_addr_t &mac, const ip4_addr_t &ip4, subnet_id_t subnet_id=0, std::chrono::seconds valid_lft=DEFAULT_VALID_LFT)
 
void flush_lease_queue ()
 

Static Public Attributes

static constexpr std::chrono::seconds REDIS_RECONNECT_WAIT {5}
 
static constexpr std::chrono::seconds DEFAULT_VALID_LFT {600}
 
static constexpr double REDIS_EXPIRE_FACT = 1.5F
 
static constexpr std::chrono::milliseconds LEASE_QUEUE_FLUSH_WAIT {10}
 

Detailed Description

Main lease-to-Redis/ARPwatch exporter.

This class is the main exporter. It exports all leases provided to it by push_lease() to the Redis and ARPwatch servers accessible by the provided HiredisAdapter and ArpwatchRPC interface.

Assigned leases are queued internally, while a worker thread waits for new leases to arrive and then exports all leases sequentially.

Exported leases are automatically assigned and expire time in Redis, which is currently hard-coded in the class's member variables.

Todo:
Make Redis expire time configurable

Definition at line 35 of file Exporter.hpp.

Member Typedef Documentation

◆ ip4_addr_t

using arpwatch::Exporter::ip4_addr_t = isc::asiolink::IOAddress

Definition at line 39 of file Exporter.hpp.

◆ lease4_t

using arpwatch::Exporter::lease4_t = std::tuple<mac_addr_t, ip4_addr_t, subnet_id_t, std::chrono::seconds>

Definition at line 41 of file Exporter.hpp.

◆ mac_addr_t

using arpwatch::Exporter::mac_addr_t = isc::dhcp::HWAddr

Definition at line 38 of file Exporter.hpp.

◆ subnet_id_t

using arpwatch::Exporter::subnet_id_t = isc::dhcp::SubnetID

Definition at line 40 of file Exporter.hpp.

Constructor & Destructor Documentation

◆ Exporter() [1/3]

arpwatch::Exporter::Exporter ( HiredisAdapter redis_adapter,
ArpwatchRPC arpwatch_rpc 
)
inlineexplicit

Definition at line 48 of file Exporter.hpp.

◆ Exporter() [2/3]

arpwatch::Exporter::Exporter ( const Exporter )
delete

◆ Exporter() [3/3]

arpwatch::Exporter::Exporter ( Exporter &&  )
delete

◆ ~Exporter()

arpwatch::Exporter::~Exporter ( )

Definition at line 37 of file Exporter.cpp.

Member Function Documentation

◆ flush_lease_queue()

void arpwatch::Exporter::flush_lease_queue ( )

Definition at line 74 of file Exporter.cpp.

◆ operator=() [1/2]

Exporter & arpwatch::Exporter::operator= ( const Exporter )
delete

◆ operator=() [2/2]

Exporter & arpwatch::Exporter::operator= ( Exporter &&  )
delete

◆ push_lease()

void arpwatch::Exporter::push_lease ( const mac_addr_t mac,
const ip4_addr_t ip4,
const Exporter::subnet_id_t  subnet_id = 0,
std::chrono::seconds  valid_lft = DEFAULT_VALID_LFT 
)

Definition at line 61 of file Exporter.cpp.

◆ start_worker()

void arpwatch::Exporter::start_worker ( )

Definition at line 44 of file Exporter.cpp.

◆ stop_worker()

void arpwatch::Exporter::stop_worker ( )

Definition at line 51 of file Exporter.cpp.

Member Data Documentation

◆ DEFAULT_VALID_LFT

constexpr std::chrono::seconds arpwatch::Exporter::DEFAULT_VALID_LFT {600}
staticconstexpr

Definition at line 44 of file Exporter.hpp.

◆ LEASE_QUEUE_FLUSH_WAIT

constexpr std::chrono::milliseconds arpwatch::Exporter::LEASE_QUEUE_FLUSH_WAIT {10}
staticconstexpr

Definition at line 46 of file Exporter.hpp.

◆ REDIS_EXPIRE_FACT

constexpr double arpwatch::Exporter::REDIS_EXPIRE_FACT = 1.5F
staticconstexpr

Definition at line 45 of file Exporter.hpp.

◆ REDIS_RECONNECT_WAIT

constexpr std::chrono::seconds arpwatch::Exporter::REDIS_RECONNECT_WAIT {5}
staticconstexpr

Definition at line 43 of file Exporter.hpp.


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