Namespace cleanup

This commit is contained in:
Eelco Dolstra 2015-07-07 10:29:43 +02:00
parent 63745b8e25
commit 16696a4aee
2 changed files with 22 additions and 25 deletions

View file

@ -4,18 +4,17 @@
#include "util.hh" #include "util.hh"
using namespace nix;
struct Connection : pqxx::connection struct Connection : pqxx::connection
{ {
Connection() : pqxx::connection(getFlags()) { }; Connection() : pqxx::connection(getFlags()) { };
string getFlags() std::string getFlags()
{ {
string s = getEnv("HYDRA_DBI", "dbi:Pg:dbname=hydra;"); using namespace nix;
string prefix = "dbi:Pg:"; auto s = getEnv("HYDRA_DBI", "dbi:Pg:dbname=hydra;");
if (string(s, 0, prefix.size()) != prefix) std::string prefix = "dbi:Pg:";
if (std::string(s, 0, prefix.size()) != prefix)
throw Error("$HYDRA_DBI does not denote a PostgreSQL database"); throw Error("$HYDRA_DBI does not denote a PostgreSQL database");
return concatStringsSep(" ", tokenizeString<Strings>(string(s, prefix.size()), ";")); return concatStringsSep(" ", tokenizeString<Strings>(string(s, prefix.size()), ";"));
} }
@ -27,7 +26,7 @@ struct receiver : public pqxx::notification_receiver
bool status = false; bool status = false;
receiver(pqxx::connection_base & c, const std::string & channel) receiver(pqxx::connection_base & c, const std::string & channel)
: pqxx::notification_receiver(c, channel) { } : pqxx::notification_receiver(c, channel) { }
void operator() (const string & payload, int pid) override void operator() (const std::string & payload, int pid) override
{ {
status = true; status = true;
}; };

View file

@ -17,8 +17,6 @@
#include "store-api.hh" #include "store-api.hh"
#include "derivations.hh" #include "derivations.hh"
using namespace nix;
typedef unsigned int BuildID; typedef unsigned int BuildID;
@ -70,8 +68,8 @@ struct Build
typedef std::weak_ptr<Build> wptr; typedef std::weak_ptr<Build> wptr;
BuildID id; BuildID id;
Path drvPath; nix::Path drvPath;
std::map<string, Path> outputs; std::map<std::string, nix::Path> outputs;
std::string fullJobName; std::string fullJobName;
unsigned int maxSilentTime, buildTimeout; unsigned int maxSilentTime, buildTimeout;
@ -86,8 +84,8 @@ struct Step
typedef std::shared_ptr<Step> ptr; typedef std::shared_ptr<Step> ptr;
typedef std::weak_ptr<Step> wptr; typedef std::weak_ptr<Step> wptr;
Path drvPath; nix::Path drvPath;
Derivation drv; nix::Derivation drv;
std::set<std::string> requiredSystemFeatures; std::set<std::string> requiredSystemFeatures;
bool preferLocalBuild; bool preferLocalBuild;
@ -160,9 +158,9 @@ class State
{ {
private: private:
Path hydraData, logDir; nix::Path hydraData, logDir;
StringSet localPlatforms; nix::StringSet localPlatforms;
/* The queued builds. */ /* The queued builds. */
typedef std::map<BuildID, Build::ptr> Builds; typedef std::map<BuildID, Build::ptr> Builds;
@ -172,7 +170,7 @@ private:
queued builds). Note that these are weak pointers. Steps are queued builds). Note that these are weak pointers. Steps are
kept alive by being reachable from Builds or by being in kept alive by being reachable from Builds or by being in
progress. */ progress. */
typedef std::map<Path, Step::wptr> Steps; typedef std::map<nix::Path, Step::wptr> Steps;
Sync<Steps> steps; Sync<Steps> steps;
/* Build steps that have no unbuilt dependencies. */ /* Build steps that have no unbuilt dependencies. */
@ -187,10 +185,10 @@ private:
Pool<Connection> dbPool; Pool<Connection> dbPool;
/* The build machines. */ /* The build machines. */
typedef std::map<string, Machine::ptr> Machines; typedef std::map<std::string, Machine::ptr> Machines;
Sync<Machines> machines; // FIXME: use atomic_shared_ptr Sync<Machines> machines; // FIXME: use atomic_shared_ptr
Path machinesFile; nix::Path machinesFile;
struct stat machinesFileStat; struct stat machinesFileStat;
/* Token server limiting the number of threads copying closures in /* Token server limiting the number of threads copying closures in
@ -216,7 +214,7 @@ private:
counter bytesReceived{0}; counter bytesReceived{0};
/* Log compressor work queue. */ /* Log compressor work queue. */
Sync<std::queue<Path>> logCompressorQueue; Sync<std::queue<nix::Path>> logCompressorQueue;
std::condition_variable_any logCompressorWakeup; std::condition_variable_any logCompressorWakeup;
/* Notification sender work queue. FIXME: if hydra-queue-runner is /* Notification sender work queue. FIXME: if hydra-queue-runner is
@ -248,7 +246,7 @@ private:
BuildID propagatedFrom = 0); BuildID propagatedFrom = 0);
void finishBuildStep(pqxx::work & txn, time_t startTime, time_t stopTime, BuildID buildId, int stepNr, void finishBuildStep(pqxx::work & txn, time_t startTime, time_t stopTime, BuildID buildId, int stepNr,
const std::string & machine, BuildStepStatus status, const string & errorMsg = "", const std::string & machine, BuildStepStatus status, const std::string & errorMsg = "",
BuildID propagatedFrom = 0); BuildID propagatedFrom = 0);
void updateBuild(pqxx::work & txn, Build::ptr build, BuildStatus status); void updateBuild(pqxx::work & txn, Build::ptr build, BuildStatus status);
@ -257,12 +255,12 @@ private:
void queueMonitorLoop(); void queueMonitorLoop();
void getQueuedBuilds(Connection & conn, std::shared_ptr<StoreAPI> store, unsigned int & lastBuildId); void getQueuedBuilds(Connection & conn, std::shared_ptr<nix::StoreAPI> store, unsigned int & lastBuildId);
void removeCancelledBuilds(Connection & conn); void removeCancelledBuilds(Connection & conn);
Step::ptr createStep(std::shared_ptr<StoreAPI> store, const Path & drvPath, Step::ptr createStep(std::shared_ptr<nix::StoreAPI> store, const nix::Path & drvPath,
Build::ptr referringBuild, Step::ptr referringStep, std::set<Path> & finishedDrvs, Build::ptr referringBuild, Step::ptr referringStep, std::set<nix::Path> & finishedDrvs,
std::set<Step::ptr> & newSteps, std::set<Step::ptr> & newRunnable); std::set<Step::ptr> & newSteps, std::set<Step::ptr> & newRunnable);
void makeRunnable(Step::ptr step); void makeRunnable(Step::ptr step);
@ -276,7 +274,7 @@ private:
/* Perform the given build step. Return true if the step is to be /* Perform the given build step. Return true if the step is to be
retried. */ retried. */
bool doBuildStep(std::shared_ptr<StoreAPI> store, Step::ptr step, bool doBuildStep(std::shared_ptr<nix::StoreAPI> store, Step::ptr step,
Machine::ptr machine); Machine::ptr machine);
void buildRemote(std::shared_ptr<nix::StoreAPI> store, void buildRemote(std::shared_ptr<nix::StoreAPI> store,
@ -298,7 +296,7 @@ private:
/* Acquire the global queue runner lock, or null if somebody else /* Acquire the global queue runner lock, or null if somebody else
has it. */ has it. */
std::shared_ptr<PathLocks> acquireGlobalLock(); std::shared_ptr<nix::PathLocks> acquireGlobalLock();
void dumpStatus(Connection & conn, bool log); void dumpStatus(Connection & conn, bool log);