2014-10-05 19:49:30 -04:00
|
|
|
####################################################################################################################################
|
2015-08-05 08:43:41 -04:00
|
|
|
# PROTOCOL REMOTE MINION MODULE
|
2014-10-05 19:49:30 -04:00
|
|
|
####################################################################################################################################
|
2017-05-15 11:12:14 -04:00
|
|
|
package pgBackRest::Protocol::Remote::Minion;
|
|
|
|
use parent 'pgBackRest::Protocol::Command::Minion';
|
2014-10-05 19:49:30 -04:00
|
|
|
|
|
|
|
use strict;
|
2015-03-25 15:15:55 -04:00
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
|
|
|
|
|
|
|
use File::Basename qw(dirname);
|
2015-06-17 11:26:07 -04:00
|
|
|
|
2017-05-15 16:01:00 -04:00
|
|
|
use pgBackRest::Backup::File;
|
2016-04-14 09:30:54 -04:00
|
|
|
use pgBackRest::Common::Log;
|
2017-01-10 19:59:32 -05:00
|
|
|
use pgBackRest::Archive::ArchiveGet;
|
2017-01-27 11:02:27 -05:00
|
|
|
use pgBackRest::Archive::ArchivePushFile;
|
2017-01-10 19:54:51 -05:00
|
|
|
use pgBackRest::Check::Check;
|
2016-04-14 09:30:54 -04:00
|
|
|
use pgBackRest::Config::Config;
|
|
|
|
use pgBackRest::Db;
|
|
|
|
use pgBackRest::File;
|
|
|
|
use pgBackRest::Info;
|
2017-05-15 11:12:14 -04:00
|
|
|
use pgBackRest::Protocol::Command::Minion;
|
|
|
|
use pgBackRest::Protocol::Common::Common;
|
2015-06-17 11:26:07 -04:00
|
|
|
|
2014-10-05 19:49:30 -04:00
|
|
|
####################################################################################################################################
|
|
|
|
# CONSTRUCTOR
|
|
|
|
####################################################################################################################################
|
2015-03-25 15:15:55 -04:00
|
|
|
sub new
|
2014-10-05 19:49:30 -04:00
|
|
|
{
|
2015-03-25 15:15:55 -04:00
|
|
|
my $class = shift; # Class name
|
2015-06-18 15:39:30 -04:00
|
|
|
|
2015-08-29 14:20:46 -04:00
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
|
|
my
|
|
|
|
(
|
|
|
|
$strOperation,
|
2015-10-08 11:43:56 -04:00
|
|
|
$strCommand, # Command the master process is running
|
|
|
|
$iBufferMax, # Maximum buffer size
|
2015-08-29 14:20:46 -04:00
|
|
|
$iCompressLevel, # Set compression level
|
2015-10-08 11:43:56 -04:00
|
|
|
$iCompressLevelNetwork, # Set compression level for network only compression,
|
|
|
|
$iProtocolTimeout # Protocol timeout
|
2015-08-29 14:20:46 -04:00
|
|
|
) =
|
|
|
|
logDebugParam
|
|
|
|
(
|
2016-08-11 17:32:28 -04:00
|
|
|
__PACKAGE__ . '->new', \@_,
|
2015-10-08 11:43:56 -04:00
|
|
|
{name => 'strCommand'},
|
|
|
|
{name => 'iBufferMax'},
|
|
|
|
{name => 'iCompressLevel'},
|
|
|
|
{name => 'iCompressNetworkLevel'},
|
|
|
|
{name => 'iProtocolTimeout'}
|
2015-08-29 14:20:46 -04:00
|
|
|
);
|
2015-06-18 15:39:30 -04:00
|
|
|
|
|
|
|
# Init object and store variables
|
2015-10-08 11:43:56 -04:00
|
|
|
my $self = $class->SUPER::new(CMD_REMOTE, $strCommand, $iBufferMax, $iCompressLevel,
|
|
|
|
$iCompressLevelNetwork, $iProtocolTimeout);
|
2015-08-05 08:43:41 -04:00
|
|
|
bless $self, $class;
|
2015-03-25 15:15:55 -04:00
|
|
|
|
2015-08-29 14:20:46 -04:00
|
|
|
# Return from function and log return values if any
|
|
|
|
return logDebugReturn
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
{name => 'self', value => $self}
|
|
|
|
);
|
2014-10-05 19:49:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
2016-09-06 09:15:22 -04:00
|
|
|
# init
|
2014-10-05 19:49:30 -04:00
|
|
|
####################################################################################################################################
|
2016-09-06 09:15:22 -04:00
|
|
|
sub init
|
2014-10-05 19:49:30 -04:00
|
|
|
{
|
2016-09-06 09:15:22 -04:00
|
|
|
my $self = shift;
|
2014-10-05 19:49:30 -04:00
|
|
|
|
2016-09-06 09:15:22 -04:00
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
|
|
my ($strOperation) = logDebugParam(__PACKAGE__ . '->init');
|
2014-10-05 19:49:30 -04:00
|
|
|
|
2016-09-06 09:15:22 -04:00
|
|
|
# Create objects
|
2016-12-03 17:34:51 -05:00
|
|
|
my $oFile = new pgBackRest::File
|
2016-09-06 09:15:22 -04:00
|
|
|
(
|
|
|
|
optionGet(OPTION_STANZA, false),
|
|
|
|
optionGet(OPTION_REPO_PATH, false),
|
|
|
|
$self
|
|
|
|
);
|
|
|
|
|
2017-01-10 19:59:32 -05:00
|
|
|
my $oArchiveGet = new pgBackRest::Archive::ArchiveGet();
|
2017-01-10 19:54:51 -05:00
|
|
|
my $oCheck = new pgBackRest::Check::Check();
|
2016-12-03 17:34:51 -05:00
|
|
|
my $oInfo = new pgBackRest::Info();
|
|
|
|
my $oDb = new pgBackRest::Db();
|
2014-10-05 19:49:30 -04:00
|
|
|
|
2016-12-03 17:34:51 -05:00
|
|
|
# Create anonymous subs for each command
|
|
|
|
my $hCommandMap =
|
|
|
|
{
|
2017-01-10 19:59:32 -05:00
|
|
|
# ArchiveGet commands
|
|
|
|
&OP_ARCHIVE_GET_ARCHIVE_ID => sub {$oArchiveGet->getArchiveId($oFile)},
|
|
|
|
&OP_ARCHIVE_GET_CHECK => sub {$oArchiveGet->getCheck($oFile, @{shift()})},
|
|
|
|
|
|
|
|
# ArchivePush commands
|
2017-01-27 11:02:27 -05:00
|
|
|
&OP_ARCHIVE_PUSH_CHECK => sub {archivePushCheck($oFile, @{shift()})},
|
2016-12-03 17:34:51 -05:00
|
|
|
|
2017-01-10 19:54:51 -05:00
|
|
|
# Check commands
|
|
|
|
&OP_CHECK_BACKUP_INFO_CHECK => sub {$oCheck->backupInfoCheck($oFile, @{shift()})},
|
|
|
|
|
2016-12-03 17:34:51 -05:00
|
|
|
# Db commands
|
|
|
|
&OP_DB_CONNECT => sub {$oDb->connect()},
|
|
|
|
&OP_DB_EXECUTE_SQL => sub {$oDb->executeSql(@{shift()})},
|
|
|
|
&OP_DB_INFO => sub {$oDb->info(@{shift()})},
|
|
|
|
|
|
|
|
# File commands
|
|
|
|
&OP_FILE_COPY => sub {my $rParam = shift; $oFile->copy(PATH_ABSOLUTE, shift(@{$rParam}), PATH_ABSOLUTE, @{$rParam})},
|
|
|
|
&OP_FILE_COPY_IN => sub {my $rParam = shift; $oFile->copy(PIPE_STDIN, shift(@{$rParam}), PATH_ABSOLUTE, @{$rParam})},
|
|
|
|
&OP_FILE_COPY_OUT => sub {my $rParam = shift; $oFile->copy(PATH_ABSOLUTE, shift(@{$rParam}), PIPE_STDOUT, @{$rParam})},
|
|
|
|
&OP_FILE_EXISTS => sub {$oFile->exists(PATH_ABSOLUTE, @{shift()})},
|
|
|
|
&OP_FILE_LIST => sub {$oFile->list(PATH_ABSOLUTE, @{shift()})},
|
|
|
|
&OP_FILE_MANIFEST => sub {$oFile->manifest(PATH_ABSOLUTE, @{shift()})},
|
|
|
|
&OP_FILE_PATH_CREATE => sub {$oFile->pathCreate(PATH_ABSOLUTE, @{shift()})},
|
|
|
|
&OP_FILE_WAIT => sub {$oFile->wait(PATH_ABSOLUTE, @{shift()})},
|
|
|
|
|
|
|
|
# Info commands
|
|
|
|
&OP_INFO_STANZA_LIST => sub {$oInfo->stanzaList($oFile, @{shift()})},
|
|
|
|
};
|
2014-10-05 19:49:30 -04:00
|
|
|
|
2016-12-03 17:34:51 -05:00
|
|
|
# Return from function and log return values if any
|
|
|
|
return logDebugReturn
|
2015-06-17 11:26:07 -04:00
|
|
|
(
|
2016-09-06 09:15:22 -04:00
|
|
|
$strOperation,
|
2016-12-03 17:34:51 -05:00
|
|
|
{name => 'hCommandMap', value => $hCommandMap}
|
|
|
|
);
|
2014-10-05 19:49:30 -04:00
|
|
|
}
|
|
|
|
|
2015-03-25 15:15:55 -04:00
|
|
|
1;
|