NAME
Siebel::Srvrmgr::Daemon::Condition - object that checks which conditions should keep a Siebel::Srvrmgr::Daemon running
SYNOPSIS
my $condition = Siebel::Srvrmgr::Daemon::Condition->new(
{
is_infinite => 1,
total_commands => 10
}
);
DESCRIPTION
Siebel::Srvrmgr::Daemon::Condition class has one function: define if the Siebel::Srvrmgr::Daemon object instance should continue it's loop execution or stop.
There are several checkings that are carried (for example, if the loop must be infinite or if the stack of commands is finished) and the object of this class will return true (1) or false (0) depending on the context.
Since this class was used exclusively to control de loop of execution, it does not make much sense to use it outside of Siebel::Srvrmgr::Daemon class.
There are more status that this class will keep, please check the attributes and methods.
ATTRIBUTES
is_infinite
This is a boolean attribute and it is required during object creation. It tells if the object should always return true from the method check
or not.
If it's true, check
method will always return true (1), otherwise it will return false (0).
max_cmd_idx
Maximum command index. This is an integer attribute that identifies the last command from the commands stack (of Siebel::Srvrmgr::Daemon).
It's automatically set to total_commands
- 1 right after object creation.
total_commands
This is an integer that tells the total amount of commands available for execution. This class will keep track of the executed commands and the result of it will be part of the definition of the result returned from the method check
(unless is_infinite
attribute is set to true) and restart, if necessary, the stack of commands to be executed.
This attribute is required during object creation.
cmd_counter
An integer that keeps tracking of the current command being executed, always starting from zero.
This attribute has a default value of zero.
output_used
An boolean that identifies if the last executed command output was used or not.
cmd_sent
An boolean that identifies if the current command to be executed was truly submitted to srvrmgr
program or not.
METHODS
get_cmd_counter
Returns the content of the attribute cmd_counter
as an integer.
is_output_used
Returns a true or false based on the content of output_used
attribute.
set_output_used
Sets the output_used
attribute. Expects a 1 (true) or 0 (false) value as parameter.
If the parameter is true then the attribute cmd_sent
will be set to false (a new command will need to be submitted).
is_cmd_sent
Returns a true or false based on the content of cmd_sent
attribute.
set_cmd_sent
Sets the attribute cmd_sent
. Expects true (1) or false (0) as value.
max_cmd_idx
Returns an integer based on the content of max_cmd_idx
attribute.
is_infinite
Returns a true or false based on the content of is_infinite
attribute.
reduce_total_cmd
This method subtracts one from the total_cmd
attribute.
check
This method will check various conditions and depending on them will return true (1) or false (0).
The conditions that are taken in consideration:
The execution loop is infinite or not.
There is more items to execute from the commands/actions stack.
The output from a previous executed command was used or not.
add_cmd_counter
Increments by one the cmd_counter
attribute, if possible.
It will check if the cmd_counter
after incrementing will not pass the max_cmd_idx
attribute. In this case, the method will not change cmd_counter
value and will raise an exception.
can_increment
This method checks if the cmd_counter
can be increment or not, returning true (1) or false (0) depending on the conditions evaluated.
is_last_cmd
This method returns true (1) if the cmd_counter
holds the last command index from the command stack, otherwise it returns false.
reset_cmd_counter
Resets the cmd_counter
attributing setting it to zero. This is useful specially if the loop of execution is infinite (thus the command stack must be restarted).
CAVEATS
This class is becoming more and more complex due the several conditions that need to be evaluated for defining if the Siebel::Srvrmgr::Daemon should still execute the run
method or not. This probably should be replaced by a state machine.
SEE ALSO
AUTHOR
Alceu Rodrigues de Freitas Junior, <arfreitas@cpan.org>.
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 of Alceu Rodrigues de Freitas Junior, <arfreitas@cpan.org>.
This file is part of Siebel Monitoring Tools.
Siebel Monitoring Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Siebel Monitoring Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Siebel Monitoring Tools. If not, see http://www.gnu.org/licenses/.