diff --git a/src/command/archive/get/get.c b/src/command/archive/get/get.c index 9e8e9d3dd..8e7954a07 100644 --- a/src/command/archive/get/get.c +++ b/src/command/archive/get/get.c @@ -347,7 +347,7 @@ cmdArchiveGetAsync(void) (TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * MSEC_PER_SEC) / 2, archiveGetAsyncCallback, &jobData); for (unsigned int processIdx = 1; processIdx <= cfgOptionUInt(cfgOptProcessMax); processIdx++) - protocolParallelClientAdd(parallelExec, protocolLocalGet(protocolStorageTypeRepo, processIdx)); + protocolParallelClientAdd(parallelExec, protocolLocalGet(protocolStorageTypeRepo, 1, processIdx)); // Process jobs do diff --git a/src/command/archive/push/push.c b/src/command/archive/push/push.c index 30b53458a..279dbec77 100644 --- a/src/command/archive/push/push.c +++ b/src/command/archive/push/push.c @@ -498,7 +498,7 @@ cmdArchivePushAsync(void) (TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * MSEC_PER_SEC) / 2, archivePushAsyncCallback, &jobData); for (unsigned int processIdx = 1; processIdx <= cfgOptionUInt(cfgOptProcessMax); processIdx++) - protocolParallelClientAdd(parallelExec, protocolLocalGet(protocolStorageTypeRepo, processIdx)); + protocolParallelClientAdd(parallelExec, protocolLocalGet(protocolStorageTypeRepo, 1, processIdx)); // Process jobs do diff --git a/src/command/restore/restore.c b/src/command/restore/restore.c index fff7a4290..d880b8fc0 100644 --- a/src/command/restore/restore.c +++ b/src/command/restore/restore.c @@ -1929,7 +1929,7 @@ cmdRestore(void) (TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * MSEC_PER_SEC) / 2, restoreJobCallback, &jobData); for (unsigned int processIdx = 1; processIdx <= cfgOptionUInt(cfgOptProcessMax); processIdx++) - protocolParallelClientAdd(parallelExec, protocolLocalGet(protocolStorageTypeRepo, processIdx)); + protocolParallelClientAdd(parallelExec, protocolLocalGet(protocolStorageTypeRepo, 1, processIdx)); // Process jobs uint64_t sizeRestored = 0; diff --git a/src/protocol/helper.c b/src/protocol/helper.c index 2b83d47b6..4435a256f 100644 --- a/src/protocol/helper.c +++ b/src/protocol/helper.c @@ -102,10 +102,11 @@ pgIsLocal(unsigned int hostId) Get the command line required for local protocol execution ***********************************************************************************************************************************/ static StringList * -protocolLocalParam(ProtocolStorageType protocolStorageType, unsigned int protocolId) +protocolLocalParam(ProtocolStorageType protocolStorageType, unsigned int hostId, unsigned int protocolId) { FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(ENUM, protocolStorageType); + FUNCTION_LOG_PARAM(UINT, hostId); FUNCTION_LOG_PARAM(UINT, protocolId); FUNCTION_LOG_END(); @@ -120,10 +121,10 @@ protocolLocalParam(ProtocolStorageType protocolStorageType, unsigned int protoco kvPut(optionReplace, VARSTR(CFGOPT_COMMAND_STR), VARSTRZ(cfgCommandName(cfgCommand()))); // Add the process id -- used when more than one process will be called - kvPut(optionReplace, VARSTR(CFGOPT_PROCESS_STR), VARINT((int)protocolId)); + kvPut(optionReplace, VARSTR(CFGOPT_PROCESS_STR), VARUINT(protocolId)); - // Add the host id -- for now this is hard-coded to 1 - kvPut(optionReplace, VARSTR(CFGOPT_HOST_ID_STR), VARINT(1)); + // Add the host id + kvPut(optionReplace, VARSTR(CFGOPT_HOST_ID_STR), VARUINT(hostId)); // Add the storage type kvPut(optionReplace, VARSTR(CFGOPT_TYPE_STR), VARSTR(protocolStorageTypeStr(protocolStorageType))); @@ -147,10 +148,11 @@ protocolLocalParam(ProtocolStorageType protocolStorageType, unsigned int protoco Get the local protocol client ***********************************************************************************************************************************/ ProtocolClient * -protocolLocalGet(ProtocolStorageType protocolStorageType, unsigned int protocolId) +protocolLocalGet(ProtocolStorageType protocolStorageType, unsigned int hostId, unsigned int protocolId) { FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_PARAM(ENUM, protocolStorageType); + FUNCTION_LOG_PARAM(UINT, hostId); FUNCTION_LOG_PARAM(UINT, protocolId); FUNCTION_LOG_END(); @@ -179,7 +181,7 @@ protocolLocalGet(ProtocolStorageType protocolStorageType, unsigned int protocolI { // Execute the protocol command protocolHelperClient->exec = execNew( - cfgExe(), protocolLocalParam(protocolStorageType, protocolId), + cfgExe(), protocolLocalParam(protocolStorageType, hostId, protocolId), strNewFmt(PROTOCOL_SERVICE_LOCAL "-%u process", protocolId), (TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * 1000)); execOpen(protocolHelperClient->exec); diff --git a/src/protocol/helper.h b/src/protocol/helper.h index e25e9c467..ea6985874 100644 --- a/src/protocol/helper.h +++ b/src/protocol/helper.h @@ -27,7 +27,7 @@ Constants Functions ***********************************************************************************************************************************/ void protocolKeepAlive(void); -ProtocolClient *protocolLocalGet(ProtocolStorageType protocolStorageType, unsigned int protocolId); +ProtocolClient *protocolLocalGet(ProtocolStorageType protocolStorageType, unsigned int hostId, unsigned int protocolId); ProtocolClient *protocolRemoteGet(ProtocolStorageType protocolStorageType, unsigned int hostId); /*********************************************************************************************************************************** diff --git a/test/src/module/protocol/protocolTest.c b/test/src/module/protocol/protocolTest.c index 2525f7d55..5103622b7 100644 --- a/test/src/module/protocol/protocolTest.c +++ b/test/src/module/protocol/protocolTest.c @@ -172,28 +172,30 @@ testRun(void) harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)); TEST_RESULT_STR( - strPtr(strLstJoin(protocolLocalParam(protocolStorageTypeRepo, 0), "|")), + strPtr(strLstJoin(protocolLocalParam(protocolStorageTypeRepo, 1, 0), "|")), strPtr( strNew( "--command=archive-get|--host-id=1|--log-level-file=off|--log-level-stderr=error|--process=0|--stanza=test1" "|--type=backup|local")), - "local protocol params"); + "local repo protocol params"); // ------------------------------------------------------------------------------------------------------------------------- argList = strLstNew(); strLstAddZ(argList, "pgbackrest"); strLstAddZ(argList, "--stanza=test1"); + strLstAddZ(argList, "--pg1-path=/pg"); + strLstAddZ(argList, "--repo1-retention-full=1"); strLstAddZ(argList, "--log-subprocess"); - strLstAddZ(argList, "archive-get"); + strLstAddZ(argList, "backup"); harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)); TEST_RESULT_STR( - strPtr(strLstJoin(protocolLocalParam(protocolStorageTypeRepo, 1), "|")), + strPtr(strLstJoin(protocolLocalParam(protocolStorageTypePg, 2, 1), "|")), strPtr( strNew( - "--command=archive-get|--host-id=1|--log-level-file=info|--log-level-stderr=error|--log-subprocess|--process=1" - "|--stanza=test1|--type=backup|local")), - "local protocol params with replacements"); + "--command=backup|--host-id=2|--log-level-file=info|--log-level-stderr=error|--log-subprocess|--pg1-path=/pg" + "|--process=1|--stanza=test1|--type=db|local")), + "local pg protocol params"); } // ***************************************************************************************************************************** @@ -942,8 +944,8 @@ testRun(void) strLstAddZ(argList, "--process-max=2"); harnessCfgLoad(cfgCmdArchiveGetAsync, argList); - TEST_ASSIGN(client, protocolLocalGet(protocolStorageTypeRepo, 1), "get local protocol"); - TEST_RESULT_PTR(protocolLocalGet(protocolStorageTypeRepo, 1), client, "get local cached protocol"); + TEST_ASSIGN(client, protocolLocalGet(protocolStorageTypeRepo, 1, 1), "get local protocol"); + TEST_RESULT_PTR(protocolLocalGet(protocolStorageTypeRepo, 1, 1), client, "get local cached protocol"); TEST_RESULT_PTR(protocolHelper.clientLocal[0].client, client, "check location in cache"); TEST_RESULT_VOID(protocolFree(), "free local and remote protocol objects");