Skip to content

Commit

Permalink
Merge branch 'tickets/DM-43384' into tickets/DM-43715
Browse files Browse the repository at this point in the history
  • Loading branch information
jgates108 committed Apr 9, 2024
2 parents 2c52584 + fa63d49 commit 4e03cf1
Show file tree
Hide file tree
Showing 12 changed files with 858 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/ccontrol/UserQueryFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ UserQuery::Ptr UserQueryFactory::newUserQuery(std::string const& aQuery, std::st
// First check for SUBMIT and strip it
std::string query = aQuery;

// TODO: DM-43386 need to have WorkerChunkMap info at this point

std::string stripped;
bool async = false;
if (UserQueryType::isSubmit(query, stripped)) {
Expand Down
32 changes: 31 additions & 1 deletion src/czar/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
add_library(czar OBJECT)
add_dependencies(czar proto)

target_sources(czar PRIVATE
Czar.cc
CzarChunkMap.cc
HttpCzarSvc.cc
HttpCzarQueryModule.cc
HttpModule.cc
Expand Down Expand Up @@ -50,4 +52,32 @@ endfunction()

czar_utils(
qserv-czar-http
)
)

function(czar_tests)
foreach(TEST IN ITEMS ${ARGV})
add_executable(${TEST} ${TEST}.cc)
target_link_libraries(${TEST} PUBLIC
cconfig
ccontrol
czar
global
mysql
parser
qana
qdisp
qproc
qserv_meta
query
rproc
sql
Boost::unit_test_framework
)
add_test(NAME ${TEST} COMMAND ${TEST})
endforeach()
endfunction()

czar_tests(
testCzar
)

10 changes: 8 additions & 2 deletions src/czar/Czar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "ccontrol/UserQueryResources.h"
#include "ccontrol/UserQuerySelect.h"
#include "ccontrol/UserQueryType.h"
#include "czar/CzarChunkMap.h"
#include "czar/CzarErrors.h"
#include "czar/HttpSvc.h"
#include "czar/MessageTable.h"
Expand Down Expand Up @@ -138,8 +139,7 @@ Czar::Czar(string const& configFilePath, string const& czarName)
_czarConfig(cconfig::CzarConfig::create(configFilePath, czarName)),
_idCounter(),
_uqFactory(),
_clientToQuery(),
_mutex() {
_clientToQuery() {
// set id counter to milliseconds since the epoch, mod 1 year.
struct timeval tv;
gettimeofday(&tv, nullptr);
Expand All @@ -156,6 +156,12 @@ Czar::Czar(string const& configFilePath, string const& czarName)
// the name of the Czar gets translated into a numeric identifier.
_czarConfig->setId(_uqFactory->userQuerySharedResources()->qMetaCzarId);

try {
_czarChunkMap = CzarChunkMap::create(_uqFactory->userQuerySharedResources()->queryMetadata);
} catch (ChunkMapException const& exc) {
LOGS(_log, LOG_LVL_WARN, string(__func__) + " failed to create CzarChunkMap " + exc.what());
}

// Tell workers to cancel any queries that were submitted before this restart of Czar.
// Figure out which query (if any) was recorded in Czar database before the restart.
// The id will be used as the high-watermark for queries that need to be cancelled.
Expand Down
5 changes: 5 additions & 0 deletions src/czar/Czar.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class FileMonitor;

namespace lsst::qserv::czar {

class CzarChunkMap;

/// @addtogroup czar

/**
Expand Down Expand Up @@ -179,6 +181,9 @@ class Czar {

/// The HTTP server processing Czar management requests.
std::shared_ptr<HttpSvc> _controlHttpSvc;

/// Map of which chunks on which workers and shared scan order.
std::shared_ptr<CzarChunkMap> _czarChunkMap;
};

} // namespace lsst::qserv::czar
Expand Down
Loading

0 comments on commit 4e03cf1

Please sign in to comment.