OmniSciDB  2e3a973ef4
foreign_storage::ForeignTableRefreshScheduler Class Reference

#include <ForeignTableRefresh.h>

Static Public Member Functions

static void start (std::atomic< bool > &is_program_running)
 
static void stop ()
 
static void setWaitDuration (int64_t duration_in_seconds)
 
static bool isRunning ()
 
static bool hasRefreshedTable ()
 
static void resetHasRefreshedTable ()
 

Static Private Attributes

static bool is_scheduler_running_ {false}
 
static std::chrono::seconds thread_wait_duration_ {60}
 
static std::thread scheduler_thread_
 
static std::atomic< bool > has_refreshed_table_ {false}
 

Detailed Description

Definition at line 28 of file ForeignTableRefresh.h.

Member Function Documentation

◆ hasRefreshedTable()

bool foreign_storage::ForeignTableRefreshScheduler::hasRefreshedTable ( )
static

Definition at line 92 of file ForeignTableRefresh.cpp.

References has_refreshed_table_.

92  {
93  return has_refreshed_table_;
94 }

◆ isRunning()

bool foreign_storage::ForeignTableRefreshScheduler::isRunning ( )
static

Definition at line 88 of file ForeignTableRefresh.cpp.

References is_scheduler_running_.

◆ resetHasRefreshedTable()

void foreign_storage::ForeignTableRefreshScheduler::resetHasRefreshedTable ( )
static

◆ setWaitDuration()

void foreign_storage::ForeignTableRefreshScheduler::setWaitDuration ( int64_t  duration_in_seconds)
static

Definition at line 84 of file ForeignTableRefresh.cpp.

References thread_wait_duration_.

84  {
85  thread_wait_duration_ = std::chrono::seconds{duration_in_seconds};
86 }

◆ start()

void foreign_storage::ForeignTableRefreshScheduler::start ( std::atomic< bool > &  is_program_running)
static

Definition at line 53 of file ForeignTableRefresh.cpp.

References logger::ERROR, has_refreshed_table_, Catalog_Namespace::SysCatalog::instance(), is_scheduler_running_, LOG, foreign_storage::refresh_foreign_table(), scheduler_thread_, run_benchmark_import::tables, and thread_wait_duration_.

Referenced by startMapdServer().

53  {
54  if (!is_scheduler_running_) {
55  scheduler_thread_ = std::thread([&is_program_running]() {
56  while (is_program_running) {
57  auto& sys_catalog = Catalog_Namespace::SysCatalog::instance();
58  for (const auto& catalog : sys_catalog.getCatalogsForAllDbs()) {
59  auto tables = catalog->getAllForeignTablesForRefresh();
60  for (auto table : tables) {
61  try {
62  refresh_foreign_table(*catalog, table->tableName, false);
63  } catch (std::runtime_error& e) {
64  LOG(ERROR) << "Scheduled refresh for table \"" << table->tableName
65  << "\" resulted in an error. " << e.what();
66  }
67  has_refreshed_table_ = true;
68  }
69  }
70  std::this_thread::sleep_for(thread_wait_duration_);
71  }
72  });
73  is_scheduler_running_ = true;
74  }
75 }
#define LOG(tag)
Definition: Logger.h:188
void refresh_foreign_table(Catalog_Namespace::Catalog &catalog, const std::string &table_name, const bool evict_cached_entries)
static SysCatalog & instance()
Definition: SysCatalog.h:286
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

void foreign_storage::ForeignTableRefreshScheduler::stop ( )
static

Definition at line 77 of file ForeignTableRefresh.cpp.

References is_scheduler_running_, and scheduler_thread_.

Referenced by startMapdServer().

+ Here is the caller graph for this function:

Member Data Documentation

◆ has_refreshed_table_

std::atomic< bool > foreign_storage::ForeignTableRefreshScheduler::has_refreshed_table_ {false}
staticprivate

Definition at line 43 of file ForeignTableRefresh.h.

Referenced by hasRefreshedTable(), resetHasRefreshedTable(), and start().

◆ is_scheduler_running_

bool foreign_storage::ForeignTableRefreshScheduler::is_scheduler_running_ {false}
staticprivate

Definition at line 40 of file ForeignTableRefresh.h.

Referenced by isRunning(), resetHasRefreshedTable(), start(), and stop().

◆ scheduler_thread_

std::thread foreign_storage::ForeignTableRefreshScheduler::scheduler_thread_
staticprivate

Definition at line 42 of file ForeignTableRefresh.h.

Referenced by resetHasRefreshedTable(), start(), and stop().

◆ thread_wait_duration_

std::chrono::seconds foreign_storage::ForeignTableRefreshScheduler::thread_wait_duration_ {60}
staticprivate

Definition at line 41 of file ForeignTableRefresh.h.

Referenced by resetHasRefreshedTable(), setWaitDuration(), and start().


The documentation for this class was generated from the following files: