1 /* 2 BAREOS® - Backup Archiving REcovery Open Sourced 3 4 Copyright (C) 2000-2012 Free Software Foundation Europe e.V. 5 Copyright (C) 2011-2016 Planets Communications B.V. 6 Copyright (C) 2019-2019 Bareos GmbH & Co. KG 7 8 This program is Free Software; you can redistribute it and/or 9 modify it under the terms of version three of the GNU Affero General Public 10 License as published by the Free Software Foundation and included 11 in the file LICENSE. 12 13 This program is distributed in the hope that it will be useful, but 14 WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Affero General Public License for more details. 17 18 You should have received a copy of the GNU Affero General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21 02110-1301, USA. 22 */ 23 24 #ifndef BAREOS_SRC_DIRD_RUN_ON_INCOMING_CONNECT_INTERVAL_H_ 25 #define BAREOS_SRC_DIRD_RUN_ON_INCOMING_CONNECT_INTERVAL_H_ 26 27 #include <string> 28 29 class BareosDb; 30 31 namespace directordaemon { 32 33 class Scheduler; 34 class JobResource; 35 36 class RunOnIncomingConnectInterval { 37 public: 38 explicit RunOnIncomingConnectInterval(std::string client_name); 39 40 ~RunOnIncomingConnectInterval() = default; 41 RunOnIncomingConnectInterval(const RunOnIncomingConnectInterval&) = delete; 42 RunOnIncomingConnectInterval(RunOnIncomingConnectInterval&&) = delete; 43 RunOnIncomingConnectInterval operator=(const RunOnIncomingConnectInterval&) = 44 delete; 45 RunOnIncomingConnectInterval operator=(RunOnIncomingConnectInterval&&) = 46 delete; 47 48 void Run(); 49 50 // testing 51 RunOnIncomingConnectInterval(std::string client_name, 52 Scheduler& scheduler, 53 BareosDb* db); 54 55 private: 56 time_t FindLastJobStart(JobResource* job); 57 void RunJobIfIntervalExceeded(JobResource* job, time_t last_start_time); 58 59 std::string client_name_; 60 Scheduler& scheduler_; 61 BareosDb* db_{nullptr}; 62 }; 63 64 } // namespace directordaemon 65 66 #endif // BAREOS_SRC_DIRD_RUN_ON_INCOMING_CONNECT_INTERVAL_H_ 67