Kea
1.9.9-git
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
perfdhcp/main.cc
Go to the documentation of this file.
1
// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC")
2
//
3
// This Source Code Form is subject to the terms of the Mozilla Public
4
// License, v. 2.0. If a copy of the MPL was not distributed with this
5
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7
#include <config.h>
8
9
#include <
perfdhcp/avalanche_scen.h
>
10
#include <
perfdhcp/basic_scen.h
>
11
#include <
perfdhcp/command_options.h
>
12
13
#include <
exceptions/exceptions.h
>
14
15
#include <iostream>
16
#include <stdint.h>
17
18
using namespace
isc::perfdhcp
;
19
20
int
21
main
(
int
argc,
char
* argv[]) {
22
CommandOptions
command_options;
23
std::string diags(command_options.
getDiags
());
24
int
ret_code = 0;
25
try
{
26
// If parser returns true it means that user specified
27
// 'h' or 'v' command line option. Program shows the
28
// help or version message and exits here.
29
// The third argument indicates that the command line
30
// should be printed when it gets parsed. This is useful
31
// in particular when the command line needs to be
32
// extracted from the log file.
33
if
(command_options.
parse
(argc, argv,
true
)) {
34
return
(ret_code);
35
}
36
}
catch
(
const
isc::Exception
& e) {
37
ret_code = 1;
38
command_options.
usage
();
39
std::cerr <<
"\nERROR: parsing command line options: "
40
<< e.
what
() << std::endl;
41
if
(diags.find(
'e'
) != std::string::npos) {
42
std::cerr <<
"Fatal error"
<< std::endl;
43
}
44
return
(ret_code);
45
}
46
try
{
47
auto
scenario = command_options.
getScenario
();
48
PerfSocket
socket(command_options);
49
if
(scenario ==
Scenario::BASIC
) {
50
BasicScen
scen(command_options, socket);
51
ret_code = scen.
run
();
52
}
else
if
(scenario ==
Scenario::AVALANCHE
) {
53
AvalancheScen
scen(command_options, socket);
54
ret_code = scen.
run
();
55
}
56
}
catch
(
const
std::exception& e) {
57
ret_code = 1;
58
std::cerr <<
"\nERROR: running perfdhcp: "
<< e.what() << std::endl;
59
if
(diags.find(
'e'
) != std::string::npos) {
60
std::cerr <<
"Fatal error"
<< std::endl;
61
}
62
}
63
return
(ret_code);
64
}
isc::perfdhcp::CommandOptions::parse
bool parse(int argc, char **const argv, bool print_cmd_line=false)
Parse command line.
Definition:
command_options.cc:172
basic_scen.h
isc::perfdhcp::Scenario::BASIC
isc::perfdhcp::CommandOptions::getScenario
Scenario getScenario() const
Returns selected scenario.
Definition:
command_options.h:388
exceptions.h
isc::perfdhcp::PerfSocket
Socket wrapper structure.
Definition:
perf_socket.h:64
isc::perfdhcp::BasicScen
Basic Scenario class.
Definition:
basic_scen.h:23
command_options.h
isc::perfdhcp::Scenario::AVALANCHE
isc::perfdhcp::CommandOptions::getDiags
std::string getDiags() const
Returns diagnostic selectors.
Definition:
command_options.h:368
main
int main(int argc, char *argv[])
Definition:
perfdhcp/main.cc:21
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition:
exceptions/exceptions.cc:32
isc::perfdhcp::AvalancheScen::run
int run() override
brief\ Run performance test.
Definition:
avalanche_scen.cc:96
isc::Exception
This is a base class for exceptions thrown from the DNS library module.
Definition:
exceptions/exceptions.h:23
isc::perfdhcp::CommandOptions
Command Options.
Definition:
command_options.h:30
isc::perfdhcp::BasicScen::run
int run() override
brief\ Run performance test.
Definition:
basic_scen.cc:126
isc::perfdhcp
Definition:
abstract_scen.h:15
isc::perfdhcp::CommandOptions::usage
void usage() const
Print usage.
Definition:
command_options.cc:1169
isc::perfdhcp::AvalancheScen
Avalanche Scenario class.
Definition:
avalanche_scen.h:36
avalanche_scen.h
src
bin
perfdhcp
main.cc
Generated on Wed Sep 15 2021 10:48:31 for Kea by
1.8.9.1