diff --git a/objectstore/ArchiveQueueFailedAlgorithms.cpp b/objectstore/ArchiveQueueFailedAlgorithms.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f44eb7a11d552cab9b6111e099b86808b82a4b54 --- /dev/null +++ b/objectstore/ArchiveQueueFailedAlgorithms.cpp @@ -0,0 +1,33 @@ +/** + * The CERN Tape Archive (CTA) project + * Copyright © 2018 CERN + * + * This program 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. + * + * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "ArchiveQueueAlgorithms.hpp" +#include "common/Timer.hpp" +#include "common/make_unique.hpp" + +namespace cta { namespace objectstore { + +// ArchiveQueueFailed full specialisations for ContainerTraits. + +template<> +const std::string ContainerTraits<ArchiveQueue,ArchiveQueueFailed>::c_containerTypeName = "ArchiveQueueFailed"; + +template<> +const std::string ContainerTraits<ArchiveQueue,ArchiveQueueFailed>::c_identifierType = "tapepool"; + +}} // namespace cta::objectstore diff --git a/objectstore/ArchiveQueueToReportAlgorithms.cpp b/objectstore/ArchiveQueueToReportAlgorithms.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5d855d542d9b6e761e262bf8d9c29851673b1e9b --- /dev/null +++ b/objectstore/ArchiveQueueToReportAlgorithms.cpp @@ -0,0 +1,78 @@ +/** + * The CERN Tape Archive (CTA) project + * Copyright © 2018 CERN + * + * This program 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. + * + * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "ArchiveQueueAlgorithms.hpp" +#include "common/Timer.hpp" +#include "common/make_unique.hpp" + +namespace cta { namespace objectstore { + +// ArchiveQueueToReport full specialisations for ContainerTraits. + +template<> +const std::string ContainerTraits<ArchiveQueue,ArchiveQueueToReport>::c_containerTypeName = "ArchiveQueueToReport"; + +template<> +const std::string ContainerTraits<ArchiveQueue,ArchiveQueueToReport>::c_identifierType = "tapepool"; + +template<> +void ContainerTraits<ArchiveQueue,ArchiveQueueToReport>::PoppedElementsSummary:: +addDeltaToLog(const PoppedElementsSummary &previous, log::ScopedParamContainer ¶ms) { + params.add("filesAdded", files - previous.files) + .add("filesBefore", previous.files) + .add("filesAfter", files); +} + +template<> +void ContainerTraits<ArchiveQueue,ArchiveQueueToReport>::PoppedElementsBatch:: +addToLog(log::ScopedParamContainer ¶ms) { + params.add("files", summary.files); +} + +template<> +auto ContainerTraits<ArchiveQueue,ArchiveQueueToReport>:: +getPoppingElementsCandidates(Container& cont, PopCriteria& unfulfilledCriteria, ElementsToSkipSet& elemtsToSkip, + log::LogContext& lc) -> PoppedElementsBatch +{ + PoppedElementsBatch ret; + auto candidateJobsFromQueue=cont.getCandidateList(std::numeric_limits<uint64_t>::max(), unfulfilledCriteria.files, elemtsToSkip); + for (auto &cjfq: candidateJobsFromQueue.candidates) { + ret.elements.emplace_back(PoppedElement()); + PoppedElement & elem = ret.elements.back(); + elem.archiveRequest = cta::make_unique<ArchiveRequest>(cjfq.address, cont.m_objectStore); + elem.copyNb = cjfq.copyNb; + elem.bytes = cjfq.size; + elem.archiveFile = common::dataStructures::ArchiveFile(); + elem.srcURL = ""; + elem.archiveReportURL = ""; + elem.errorReportURL = ""; + elem.latestError = ""; + elem.reportType = SchedulerDatabase::ArchiveJob::ReportType::Report; + ret.summary.files++; + } + return ret; +} + +template<> +auto ContainerTraits<ArchiveQueue,ArchiveQueueToReport>::PopCriteria:: +operator-=(const PoppedElementsSummary& pes) -> PopCriteria & { + files -= pes.files; + return *this; +} + +}} // namespace cta::objectstore