Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
21f3ea90
Commit
21f3ea90
authored
Jun 05, 2013
by
Thomas Markwalder
Browse files
[2956] Changes to address review comments. Note that the module name is
now b10-dhcp-ddns.
parent
b222f7fa
Changes
16
Hide whitespace changes
Inline
Side-by-side
src/bin/d2/Makefile.am
View file @
21f3ea90
...
...
@@ -18,15 +18,15 @@ pkglibexecdir = $(libexecdir)/@PACKAGE@
CLEANFILES
=
*
.gcno
*
.gcda spec_config.h d2_messages.h d2_messages.cc
man_MANS
=
b10-d
2
.8
man_MANS
=
b10-d
hcp-ddns
.8
DISTCLEANFILES
=
$(man_MANS)
EXTRA_DIST
=
$(man_MANS)
b10-d
2.xml d2
.spec
EXTRA_DIST
=
$(man_MANS)
b10-d
hcp-ddns.xml dhcp-ddns
.spec
if
GENERATE_DOCS
b10-d
2
.8
:
b10-d
2
.xml
b10-d
hcp-ddns
.8
:
b10-d
hcp-ddns
.xml
@
XSLTPROC@
--novalid
--xinclude
--nonet
-o
$@
\
http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
\
$(srcdir)
/b10-d
2
.xml
$(srcdir)
/b10-d
chdp-ddns
.xml
else
...
...
@@ -44,23 +44,23 @@ d2_messages.h d2_messages.cc: d2_messages.mes
BUILT_SOURCES
=
spec_config.h d2_messages.h d2_messages.cc
pkglibexec_PROGRAMS
=
b10-d
2
pkglibexec_PROGRAMS
=
b10-d
hcp-ddns
b10_d
2
_SOURCES
=
main.cc
b10_d
2
_SOURCES
+=
d2_log.cc d2_log.h
b10_d
2
_SOURCES
+=
d_process.h
b10_d
2
_SOURCES
+=
d2_process.cc d2_process.h
b10_d
2
_SOURCES
+=
d_controller.cc d_controller.h
b10_d
2
_SOURCES
+=
d2_controller.cc d2_controller.h
b10_d
hcp_ddns
_SOURCES
=
main.cc
b10_d
hcp_ddns
_SOURCES
+=
d2_log.cc d2_log.h
b10_d
hcp_ddns
_SOURCES
+=
d_process.h
b10_d
hcp_ddns
_SOURCES
+=
d2_process.cc d2_process.h
b10_d
hcp_ddns
_SOURCES
+=
d_controller.cc d_controller.h
b10_d
hcp_ddns
_SOURCES
+=
d2_controller.cc d2_controller.h
nodist_b10_d
2
_SOURCES
=
d2_messages.h d2_messages.cc
nodist_b10_d
hcp_ddns
_SOURCES
=
d2_messages.h d2_messages.cc
EXTRA_DIST
+=
d2_messages.mes
b10_d
2
_LDADD
=
$(top_builddir)
/src/lib/log/libb10-log.la
b10_d
2
_LDADD
+=
$(top_builddir)
/src/lib/exceptions/libb10-exceptions.la
b10_d
2
_LDADD
+=
$(top_builddir)
/src/lib/cc/libb10-cc.la
b10_d
2
_LDADD
+=
$(top_builddir)
/src/lib/asiolink/libb10-asiolink.la
b10_d
2
_LDADD
+=
$(top_builddir)
/src/lib/config/libb10-cfgclient.la
b10_d
hcp_ddns
_LDADD
=
$(top_builddir)
/src/lib/log/libb10-log.la
b10_d
hcp_ddns
_LDADD
+=
$(top_builddir)
/src/lib/exceptions/libb10-exceptions.la
b10_d
hcp_ddns
_LDADD
+=
$(top_builddir)
/src/lib/cc/libb10-cc.la
b10_d
hcp_ddns
_LDADD
+=
$(top_builddir)
/src/lib/asiolink/libb10-asiolink.la
b10_d
hcp_ddns
_LDADD
+=
$(top_builddir)
/src/lib/config/libb10-cfgclient.la
b10_d
2
dir
=
$(pkgdatadir)
b10_d
2
_DATA
=
d
2
.spec
b10_d
hcp_ddns
dir
=
$(pkgdatadir)
b10_d
hcp_ddns
_DATA
=
d
hcp-ddns
.spec
src/bin/d2/b10-d
2
.xml
→
src/bin/d2/b10-d
hcp-ddns
.xml
View file @
21f3ea90
...
...
@@ -24,13 +24,13 @@
</refentryinfo>
<refmeta>
<refentrytitle>
b10-d
2
</refentrytitle>
<refentrytitle>
b10-d
hcp-ddns
</refentrytitle>
<manvolnum>
8
</manvolnum>
<refmiscinfo>
BIND10
</refmiscinfo>
</refmeta>
<refnamediv>
<refname>
b10-d
2
</refname>
<refname>
b10-d
hcp-ddns
</refname>
<refpurpose>
D2 process in BIND 10 architecture
</refpurpose>
</refnamediv>
...
...
@@ -43,14 +43,14 @@
<refsynopsisdiv>
<cmdsynopsis>
<command>
b10-d
2
</command>
<command>
b10-d
hcp-ddns
</command>
<arg><option>
-v
</option></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsynopsisdiv>
<cmdsynopsis>
<command>
b10-d
2
</command>
<command>
b10-d
hcp-ddns
</command>
<arg><option>
-s
</option></arg>
</cmdsynopsis>
</refsynopsisdiv>
...
...
@@ -59,7 +59,7 @@
<refsect1>
<title>
DESCRIPTION
</title>
<para>
The
<command>
b10-d
2
</command>
daemon processes requests to
The
<command>
b10-d
hcp-ddns
</command>
daemon processes requests to
to update DNS mapping based on DHCP lease change events.
</para>
...
...
@@ -95,7 +95,7 @@
<title>
SEE ALSO
</title>
<para>
<citerefentry>
<refentrytitle>
b10-d
2
</refentrytitle><manvolnum>
8
</manvolnum>
<refentrytitle>
b10-d
hcp-ddns
</refentrytitle><manvolnum>
8
</manvolnum>
</citerefentry>
,
<citerefentry>
<refentrytitle>
bind10
</refentrytitle><manvolnum>
8
</manvolnum>
...
...
@@ -106,7 +106,7 @@
<refsect1>
<title>
HISTORY
</title>
<para>
The
<command>
b10-d
2
</command>
process was first coded in
The
<command>
b10-d
hcp-ddns
</command>
process was first coded in
May 2013 by the ISC Kea/Dhcp team.
</para>
</refsect1>
...
...
src/bin/d2/d2_controller.cc
View file @
21f3ea90
...
...
@@ -23,10 +23,11 @@ DControllerBasePtr&
D2Controller
::
instance
()
{
// If the instance hasn't been created yet, create it. Note this method
// must use the base class singleton instance methods. The base class
// must
own
the singleton in order to use it within BIND10
static function
// callbacks.
// must
have access to
the singleton in order to use it within BIND10
//
static function
callbacks.
if
(
!
getController
())
{
setController
(
new
D2Controller
());
DControllerBasePtr
controller_ptr
(
new
D2Controller
());
setController
(
controller_ptr
);
}
return
(
getController
());
...
...
src/bin/d2/d2_log.cc
View file @
21f3ea90
...
...
@@ -21,7 +21,7 @@ namespace d2 {
/// @brief Defines the service name which is used in the controller constructor
/// and ultimately defines the BIND10 module name.
const
char
*
const
D2_MODULE_NAME
=
"b10-d
2
"
;
const
char
*
const
D2_MODULE_NAME
=
"b10-d
hpc-ddns
"
;
/// @brief Defines the logger used within D2.
isc
::
log
::
Logger
d2_logger
(
D2_MODULE_NAME
);
...
...
src/bin/d2/d2_messages.mes
View file @
21f3ea90
...
...
@@ -27,11 +27,11 @@ This is a debug message issued when the service process has been instructed
to shut down by the controller.
% D2PRC_PROCESS_INIT DHCP-DDNS application init invoked
This is a debug message issued when the D2 process enters it
'
s
This is a debug message issued when the D2 process enters its
init method.
% D2PRC_RUN_ENTER process has entered the event loop
This is a debug message issued when the D2 process enters it
'
s
This is a debug message issued when the D2 process enters its
run method.
% D2PRC_RUN_EXIT process is exiting the event loop
...
...
@@ -52,15 +52,17 @@ has been invoked.
% D2CTL_INIT_PROCESS initializing application proces
This debug message is issued just before the controller attempts
to create and initialize it
'
s process instance.
to create and initialize its process instance.
% D2CTL_SESSION_FAIL failed to establish BIND 10 session: %1
The controller has failed to establish communication with the rest of BIND
10 and will exit.
% D2CTL_DISCONNECT_FAIL failed to disconnect from BIND 10 session: %1
The controller has failed to terminate communication with the rest of BIND
10.
This message indicates that while shutting down, the DHCP-DDNS controller
encountered an error terminating communication with the BIND10. The service
will still exit. While theoretically possible, this situation is rather
unlikely.
% D2CTL_STANDALONE skipping message queue, running standalone
This is a debug message indicating that the controller is running in the
...
...
src/bin/d2/d2_process.cc
View file @
21f3ea90
...
...
@@ -45,7 +45,7 @@ D2Process::run() {
}
catch
(
const
std
::
exception
&
ex
)
{
LOG_FATAL
(
d2_logger
,
D2PRC_FAILED
).
arg
(
ex
.
what
());
isc_throw
(
DProcessBaseError
,
std
::
string
(
"Process run method failed:"
)
+
ex
.
what
());
"Process run method failed:"
<<
ex
.
what
());
}
}
...
...
src/bin/d2/d_controller.cc
View file @
21f3ea90
...
...
@@ -32,7 +32,7 @@ DControllerBase::DControllerBase(const char* name)
}
void
DControllerBase
::
setController
(
DControllerBase
*
controller
)
{
DControllerBase
::
setController
(
const
DControllerBase
Ptr
&
controller
)
{
if
(
controller_
)
{
// This shouldn't happen, but let's make sure it can't be done.
// It represents a programmatic error.
...
...
@@ -40,41 +40,34 @@ DControllerBase::setController(DControllerBase* controller) {
"Multiple controller instances attempted."
);
}
controller_
=
DControllerBasePtr
(
controller
)
;
controller_
=
controller
;
}
int
void
DControllerBase
::
launch
(
int
argc
,
char
*
argv
[])
{
int
ret
=
d2
::
NORMAL_EXIT
;
// Step 1 is to parse the command line arguments.
try
{
parseArgs
(
argc
,
argv
);
}
catch
(
const
InvalidUsage
&
ex
)
{
usage
(
ex
.
what
());
return
(
d2
::
INVALID_USAGE
);
throw
;
// rethrow it
}
#if 1
//@TODO During initial development default to max log, no buffer
isc
::
log
::
initLogger
(
name_
,
isc
::
log
::
DEBUG
,
isc
::
log
::
MAX_DEBUG_LEVEL
,
NULL
,
false
);
#else
// Now that we know what the mode flags are, we can init logging.
// If standalone is enabled, do not buffer initial log messages
isc
::
log
::
initLogger
(
name_
,
((
verbose_
&&
stand_alone_
)
?
isc
::
log
::
DEBUG
:
isc
::
log
::
INFO
),
isc
::
log
::
MAX_DEBUG_LEVEL
,
NULL
,
!
stand_alone_
);
#endif
LOG_DEBUG
(
d2_logger
,
DBGLVL_START_SHUT
,
D2CTL_STARTING
).
arg
(
getpid
());
try
{
// Step 2 is to create and initialize the application process.
// Step 2 is to create and initialize the application process
object
.
initProcess
();
}
catch
(
const
std
::
exception
&
ex
)
{
LOG_ERROR
(
d2_logger
,
D2CTL_SESSION_FAIL
).
arg
(
ex
.
what
());
return
(
PROCESS_INIT_ERROR
);
LOG_FATAL
(
d2_logger
,
D2CTL_INIT_PROCESS
).
arg
(
ex
.
what
());
isc_throw
(
ProcessInitError
,
"Application Process initialization failed:"
<<
ex
.
what
());
}
// Next we connect if we are running integrated.
...
...
@@ -84,8 +77,9 @@ DControllerBase::launch(int argc, char* argv[]) {
try
{
establishSession
();
}
catch
(
const
std
::
exception
&
ex
)
{
LOG_ERROR
(
d2_logger
,
D2CTL_SESSION_FAIL
).
arg
(
ex
.
what
());
return
(
d2
::
SESSION_START_ERROR
);
LOG_FATAL
(
d2_logger
,
D2CTL_SESSION_FAIL
).
arg
(
ex
.
what
());
isc_throw
(
SessionStartError
,
"Session start up failed:"
<<
ex
.
what
());
}
}
...
...
@@ -95,24 +89,25 @@ DControllerBase::launch(int argc, char* argv[]) {
runProcess
();
}
catch
(
const
std
::
exception
&
ex
)
{
LOG_FATAL
(
d2_logger
,
D2CTL_FAILED
).
arg
(
ex
.
what
());
ret
=
d2
::
RUN_ERROR
;
isc_throw
(
ProcessRunError
,
"Application process event loop failed:"
<<
ex
.
what
());
}
// If running integrated,
always try to
disconnect.
// If running integrated, disconnect.
if
(
!
stand_alone_
)
{
try
{
disconnectSession
();
}
catch
(
const
std
::
exception
&
ex
)
{
LOG_ERROR
(
d2_logger
,
D2CTL_DISCONNECT_FAIL
).
arg
(
ex
.
what
());
ret
=
d2
::
SESSION_END_ERROR
;
isc_throw
(
SessionEndError
,
"Session end failed:"
<<
ex
.
what
())
;
}
}
// All done, so bail out.
LOG_INFO
(
d2_logger
,
D2CTL_STOPPING
);
return
(
ret
);
}
void
DControllerBase
::
parseArgs
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -137,11 +132,10 @@ DControllerBase::parseArgs(int argc, char* argv[])
case
'?'
:
{
// We hit an invalid option.
std
::
stringstream
tmp
;
tmp
<<
" unsupported option: ["
<<
(
char
)
optopt
<<
"] "
<<
(
!
optarg
?
""
:
optarg
);
isc_throw
(
InvalidUsage
,
"unsupported option: ["
<<
static_cast
<
char
>
(
optopt
)
<<
"] "
<<
(
!
optarg
?
""
:
optarg
)
)
;
isc_throw
(
InvalidUsage
,
tmp
.
str
());
break
;
}
...
...
@@ -149,10 +143,9 @@ DControllerBase::parseArgs(int argc, char* argv[])
// We hit a valid custom option
if
(
!
customOption
(
ch
,
optarg
))
{
// This would be a programmatic error.
std
::
stringstream
tmp
;
tmp
<<
" Option listed but implemented?: ["
<<
(
char
)
ch
<<
"] "
<<
(
!
optarg
?
""
:
optarg
);
isc_throw
(
InvalidUsage
,
tmp
.
str
());
isc_throw
(
InvalidUsage
,
" Option listed but implemented?: ["
<<
static_cast
<
char
>
(
ch
)
<<
"] "
<<
(
!
optarg
?
""
:
optarg
));
}
break
;
}
...
...
@@ -160,9 +153,7 @@ DControllerBase::parseArgs(int argc, char* argv[])
// There was too much information on the command line.
if
(
argc
>
optind
)
{
std
::
stringstream
tmp
;
tmp
<<
"extraneous command line information"
;
isc_throw
(
InvalidUsage
,
tmp
.
str
());
isc_throw
(
InvalidUsage
,
"extraneous command line information"
);
}
}
...
...
@@ -181,13 +172,13 @@ DControllerBase::initProcess() {
try
{
process_
.
reset
(
createProcess
());
}
catch
(
const
std
::
exception
&
ex
)
{
isc_throw
(
DControllerBaseError
,
std
::
string
(
"createProcess failed:"
)
+
ex
.
what
());
isc_throw
(
DControllerBaseError
,
std
::
string
(
"createProcess failed:"
)
+
ex
.
what
());
}
// This is pretty unlikely, but will test for it just to be safe..
if
(
!
process_
)
{
isc_throw
(
DControllerBaseError
,
"createProcess returned NULL"
);
isc_throw
(
DControllerBaseError
,
"createProcess returned NULL"
);
}
// Invoke application's init method (Note this call should throw
...
...
@@ -300,7 +291,7 @@ DControllerBase::configHandler(isc::data::ConstElementPtr new_config) {
// Static callback which invokes non-static handler on singleton
isc
::
data
::
ConstElementPtr
DControllerBase
::
commandHandler
(
const
std
::
string
&
command
,
isc
::
data
::
ConstElementPtr
args
)
{
isc
::
data
::
ConstElementPtr
args
)
{
LOG_DEBUG
(
d2_logger
,
DBGLVL_COMMAND
,
D2CTL_COMMAND_RECEIVED
)
.
arg
(
command
).
arg
(
args
->
str
());
...
...
@@ -403,14 +394,6 @@ DControllerBase::customControllerCommand(const std::string& command,
isc
::
data
::
ConstElementPtr
DControllerBase
::
shutdown
()
{
// @TODO (tmark) - not sure about io_service_->stop here
// IF application is using this service for all of its IO, stopping
// here would mean, no more work by the application.. UNLESS it resets
// it. People have discussed letting the application finish any in-progress
// updates before shutting down. If we don't stop it here, then
// application can't use io_service_->run(), it will never "see" the
// shutdown.
io_service_
->
stop
();
if
(
process_
)
{
process_
->
shutdown
();
}
else
{
...
...
src/bin/d2/d_controller.h
View file @
21f3ea90
...
...
@@ -35,19 +35,6 @@ namespace d2 {
/// normal or otherwise, the Controller's launch method will return one of
/// these values.
/// @brief Indicates normal shutdown.
static
const
int
NORMAL_EXIT
=
0
;
/// @brief Indicates invalid command line.
static
const
int
INVALID_USAGE
=
1
;
/// @brief Failed to create and initialize application process.
static
const
int
PROCESS_INIT_ERROR
=
2
;
/// @brief Could not connect to BIND10 (integrated mode only).
static
const
int
SESSION_START_ERROR
=
3
;
/// @brief A fatal error occurred in the application process.
static
const
int
RUN_ERROR
=
4
;
/// @brief Error occurred disconnecting from BIND10 (integrated mode only).
static
const
int
SESSION_END_ERROR
=
5
;
/// @brief Exception thrown when the command line is invalid.
class
InvalidUsage
:
public
isc
::
Exception
{
public:
...
...
@@ -55,6 +42,36 @@ public:
isc
::
Exception
(
file
,
line
,
what
)
{
};
};
/// @brief Exception thrown when the application process fails.
class
ProcessInitError
:
public
isc
::
Exception
{
public:
ProcessInitError
(
const
char
*
file
,
size_t
line
,
const
char
*
what
)
:
isc
::
Exception
(
file
,
line
,
what
)
{
};
};
/// @brief Exception thrown when the session start up fails.
class
SessionStartError
:
public
isc
::
Exception
{
public:
SessionStartError
(
const
char
*
file
,
size_t
line
,
const
char
*
what
)
:
isc
::
Exception
(
file
,
line
,
what
)
{
};
};
/// @brief Exception thrown when the application process encounters an
/// operation in its event loop (i.e. run method).
class
ProcessRunError
:
public
isc
::
Exception
{
public:
ProcessRunError
(
const
char
*
file
,
size_t
line
,
const
char
*
what
)
:
isc
::
Exception
(
file
,
line
,
what
)
{
};
};
/// @brief Exception thrown when the session end fails.
class
SessionEndError
:
public
isc
::
Exception
{
public:
SessionEndError
(
const
char
*
file
,
size_t
line
,
const
char
*
what
)
:
isc
::
Exception
(
file
,
line
,
what
)
{
};
};
/// @brief Exception thrown when the controller encounters an operational error.
class
DControllerBaseError
:
public
isc
::
Exception
{
public:
...
...
@@ -82,15 +99,24 @@ typedef boost::shared_ptr<isc::config::ModuleCCSession> ModuleCCSessionPtr;
/// integrated mode as a BIND10 module or stand-alone. It coordinates command
/// line argument parsing, process instantiation and initialization, and runtime
/// control through external command and configuration event handling.
/// It creates the
io_s
ervice
_
instance which is used for runtime control
/// events and passes the
io_s
ervice into the application process at process
/// It creates the
IOS
ervice instance which is used for runtime control
/// events and passes the
IOS
ervice into the application process at process
/// creation. In integrated mode it is responsible for establishing BIND10
/// session(s) and passes this io_service_ into the session creation method(s).
/// It also provides the callback handlers for command and configuration events.
/// session(s) and passes this IOService into the session creation method(s).
/// It also provides the callback handlers for command and configuration events
/// received from the external framework (aka BIND10). For example, when
/// running in integrated mode and a user alters the configuration with the
/// bindctl tool, BIND10 will emit a configuration message which is sensed by
/// the controller's IOService. The IOService in turn invokes the configuration
/// callback, DControllerBase::configHandler(). If the user issues a command
/// such as shutdown via bindctl, BIND10 will emit a command message, which is
/// sensed by controller's IOService which invokes the command callback,
/// DControllerBase::commandHandler().
///
/// NOTE: Derivations must supply their own static singleton instance method(s)
/// for creating and fetching the instance. The base class declares the instance
/// member in order for it to be available for BIND10 callback functions. This
/// would not be required if BIND10 supported instance method callbacks.
/// would not be required if BIND10 supported instance method callbacks.
class
DControllerBase
:
public
boost
::
noncopyable
{
public:
/// @brief Constructor
...
...
@@ -119,16 +145,16 @@ public:
/// @param argc is the number of command line arguments supplied
/// @param argv is the array of string (char *) command line arguments
///
/// @return returns one of the following integer values:
/// d2::NORMAL_EXIT - Indicates normal shutdown.
/// d2::INVALID_USAGE - Indicates invalid command line.
/// d2::PROCESS_INIT_ERROR - Failed to create and initialize application
/// process
/// d2::SESSION_START_ERROR - Could not connect to BIND10 (integrated mode
/// @throw throws one of the following exceptions:
/// InvalidUsage - Indicates invalid command line.
/// ProcessInitError - Failed to create and initialize application
/// process object.
/// SessionStartError - Could not connect to BIND10 (integrated mode only).
/// ProcessRunError - A fatal error occurred while in the application
/// process event loop.
/// SessionEndError - Could not disconnect from BIND10 (integrated mode
/// only).
/// d2::RUN_ERROR - An fatal error occurred in the application process
/// d2::SESSION_END_ERROR = 4;
int
launch
(
int
argc
,
char
*
argv
[]);
void
launch
(
int
argc
,
char
*
argv
[]);
/// @brief A dummy configuration handler that always returns success.
///
...
...
@@ -240,11 +266,11 @@ protected:
virtual
bool
customOption
(
int
option
,
char
*
optarg
);
/// @brief Abstract method that is responsible for instantiating the
/// application process
instance
. It is invoked by the controller after
/// application process
object
. It is invoked by the controller after
/// command line argument parsing as part of the process initialization
/// (see initProcess method).
///
/// @return returns a pointer to the new process
instance
(DProcessBase*)
/// @return returns a pointer to the new process
object
(DProcessBase*)
/// or NULL if the create fails.
/// Note this value is subsequently wrapped in a smart pointer.
virtual
DProcessBase
*
createProcess
()
=
0
;
...
...
@@ -294,7 +320,7 @@ protected:
/// invalid usage conditions.
///
/// @return returns the desired text.
virtual
const
std
::
string
getUsageText
()
{
virtual
const
std
::
string
getUsageText
()
const
{
return
(
""
);
}
...
...
@@ -304,21 +330,21 @@ protected:
/// line interpretation.
///
/// @return returns a string containing the custom option letters.
virtual
const
std
::
string
getCustomOpts
()
{
virtual
const
std
::
string
getCustomOpts
()
const
{
return
(
""
);
}
/// @brief Supplies the controller name.
///
/// @return returns the controller name string
const
std
::
string
&
getName
()
{
const
std
::
string
getName
()
const
{
return
(
name_
);
}
/// @brief Supplies whether or not the controller is in stand alone mode.
///
/// @return returns true if in stand alone mode, false otherwise
bool
isStandAlone
()
{
const
bool
isStandAlone
()
const
{
return
(
stand_alone_
);
}
...
...
@@ -332,7 +358,7 @@ protected:
/// @brief Supplies whether or not verbose logging is enabled.
///
/// @return returns true if verbose logging is enabled.
bool
isVerbose
()
{
const
bool
isVerbose
()
const
{
return
(
verbose_
);
}
...
...
@@ -354,7 +380,7 @@ protected:
/// file.
///
/// @return returns the file name string.
const
std
::
string
&
getSpecFileName
()
{
const
std
::
string
getSpecFileName
()
const
{
return
(
spec_file_name_
);
}
...
...
@@ -373,13 +399,13 @@ protected:
return
(
controller_
);
}
/// @brief Static setter which returns the singleton instance.
/// @brief Static setter which sets the singleton instance.
///
/// @param controller is a pointer to the singleton instance.
///
/// @return returns a pointer reference to the private singleton instance
/// member.
/// @throw throws DControllerBase error if an attempt is made to set the
/// instance a second time.
static
void
setController
(
DControllerBase
*
controller
);
static
void
setController
(
const
DControllerBase
Ptr
&
controller
);
private:
/// @brief Processes the command line arguments. It is the first step
...
...
@@ -452,7 +478,7 @@ private:
///
/// @param text is a string message which will preceded the usage text.
/// This is intended to be used for specific usage violation messages.
void
usage
(
const
std
::
string
&
text
);
void
usage
(
const
std
::
string
&
text
);
private:
/// @brief Text label for the controller. Typically this would be the
...
...
@@ -462,9 +488,10 @@ private:
/// @brief Indicates if the controller stand alone mode is enabled. When
/// enabled, the controller will not establish connectivity with BIND10.
bool
stand_alone_
;
/// @brief Indicates if the verbose logging mode is enabled.
/// @brief Indicates if the verbose logging mode is enabled.
bool
verbose_
;
/// @brief The absolute file name of the BIND10 spec file.
std
::
string
spec_file_name_
;
...
...
src/bin/d2/d_process.h
View file @
21f3ea90
...
...
@@ -72,20 +72,24 @@ public:
/// to application. It must be invoked prior to invoking run. This would
/// likely include the creation of additional IO sources and their
/// integration into the io_service.
/// @throw throws
a
DProcessBaseError if the initialization fails.
/// @throw throws DProcessBaseError if the initialization fails.
virtual
void
init
()
=
0
;
/// @brief Implements the process's event loop. In its simplest form it
/// would an invocation io_service_->run(). This method should not exit
/// until the process itself is exiting due to a request to shutdown or
/// some anomaly is forcing an exit.
/// @throw throws
a
DProcessBaseError if an operational error is encountered.
/// @throw throws DProcessBaseError if an operational error is encountered.
virtual
void
run
()
=
0
;
/// @brief Implements the process's shutdown processing. When invoked, it
/// should ensure that the process gracefully exits the run method.
/// @throw throws a DProcessBaseError if an operational error is encountered.
virtual
void
shutdown
()
=
0
;
/// The default implementation sets the shutdown flag and stops IOService.
/// @throw throws DProcessBaseError if an operational error is encountered.
virtual
void
shutdown
()
{
setShutdownFlag
(
true
);
stopIOService
();
};
/// @brief Processes the given configuration.
///
...
...
@@ -123,7 +127,7 @@ public:
/// @brief Checks if the process has been instructed to shut down.
///
/// @return returns true if process shutdown flag is true.
bool
shouldShutdown
()
{
const
bool
shouldShutdown
()
const
{
return
(
shut_down_flag_
);
}
...
...
@@ -137,7 +141,7 @@ public:
/// @brief Fetches the name of the controller.
///
/// @return returns a reference the controller's name string.
const
std
::
string
&
getName
()
const
{
const
std
::
string
getName
()
const
{
return
(
name_
);
}
...
...
@@ -148,6 +152,14 @@ public:
return
(
io_service_
);
}
/// @brief Convenience method for stopping IOservice processing.
/// Invoking this will cause the process to exit any blocking
/// IOService method such as run(). No further IO events will be
/// processed.
void
stopIOService
()
{
io_service_
->
stop
();