summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api/execution_service
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-08-05 12:40:04 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-08-07 14:43:19 +0200
commited6f31f4c9939d6cc8d4d317d561a94545750b0b (patch)
tree122e2a01c4a56b0fc25d94236d459101ffb80f65 /src/buildtool/execution_api/execution_service
parent4989605b096701fee6f1049bdad0827f81d9fb00 (diff)
downloadjustbuild-ed6f31f4c9939d6cc8d4d317d561a94545750b0b.tar.gz
Replace classic C boolean operators with keywords
! => not; && => and, || => or
Diffstat (limited to 'src/buildtool/execution_api/execution_service')
-rw-r--r--src/buildtool/execution_api/execution_service/ac_server.cpp4
-rw-r--r--src/buildtool/execution_api/execution_service/bytestream_server.cpp16
-rw-r--r--src/buildtool/execution_api/execution_service/capabilities_server.cpp2
-rw-r--r--src/buildtool/execution_api/execution_service/cas_server.cpp18
-rw-r--r--src/buildtool/execution_api/execution_service/execution_server.cpp30
-rw-r--r--src/buildtool/execution_api/execution_service/operations_server.cpp2
-rw-r--r--src/buildtool/execution_api/execution_service/server_implementation.cpp12
7 files changed, 42 insertions, 42 deletions
diff --git a/src/buildtool/execution_api/execution_service/ac_server.cpp b/src/buildtool/execution_api/execution_service/ac_server.cpp
index 83b95c7f..0d85596e 100644
--- a/src/buildtool/execution_api/execution_service/ac_server.cpp
+++ b/src/buildtool/execution_api/execution_service/ac_server.cpp
@@ -31,13 +31,13 @@ auto ActionCacheServiceImpl::GetActionResult(
"GetActionResult: {}",
request->action_digest().hash());
auto lock = GarbageCollector::SharedLock(storage_config_);
- if (!lock) {
+ if (not lock) {
auto str = fmt::format("Could not acquire SharedLock");
logger_.Emit(LogLevel::Error, str);
return grpc::Status{grpc::StatusCode::INTERNAL, str};
}
auto x = storage_.ActionCache().CachedResult(request->action_digest());
- if (!x) {
+ if (not x) {
return grpc::Status{
grpc::StatusCode::NOT_FOUND,
fmt::format("{} missing from AC", request->action_digest().hash())};
diff --git a/src/buildtool/execution_api/execution_service/bytestream_server.cpp b/src/buildtool/execution_api/execution_service/bytestream_server.cpp
index cc49591b..fd169fd8 100644
--- a/src/buildtool/execution_api/execution_service/bytestream_server.cpp
+++ b/src/buildtool/execution_api/execution_service/bytestream_server.cpp
@@ -50,7 +50,7 @@ auto BytestreamServiceImpl::Read(
// remote-execution/blobs/62f408d64bca5de775c4b1dbc3288fc03afd6b19eb/0
std::istringstream iss{request->resource_name()};
auto hash = ParseResourceName(request->resource_name());
- if (!hash) {
+ if (not hash) {
auto str = fmt::format("could not parse {}", request->resource_name());
logger_.Emit(LogLevel::Error, "{}", str);
return ::grpc::Status{::grpc::StatusCode::INVALID_ARGUMENT, str};
@@ -62,7 +62,7 @@ auto BytestreamServiceImpl::Read(
}
auto lock = GarbageCollector::SharedLock(storage_config_);
- if (!lock) {
+ if (not lock) {
auto str = fmt::format("Could not acquire SharedLock");
logger_.Emit(LogLevel::Error, str);
return grpc::Status{grpc::StatusCode::INTERNAL, str};
@@ -79,7 +79,7 @@ auto BytestreamServiceImpl::Read(
path =
storage_.CAS().BlobPath(static_cast<bazel_re::Digest>(dgst), false);
}
- if (!path) {
+ if (not path) {
auto str = fmt::format("could not find {}", *hash);
logger_.Emit(LogLevel::Error, "{}", str);
return ::grpc::Status{::grpc::StatusCode::NOT_FOUND, str};
@@ -90,7 +90,7 @@ auto BytestreamServiceImpl::Read(
std::string buffer(kChunkSize, '\0');
bool done = false;
blob.seekg(request->read_offset());
- while (!done) {
+ while (not done) {
blob.read(buffer.data(), kChunkSize);
if (blob.eof()) {
// do not send random bytes
@@ -111,7 +111,7 @@ auto BytestreamServiceImpl::Write(
reader->Read(&request);
logger_.Emit(LogLevel::Debug, "write {}", request.resource_name());
auto hash = ParseResourceName(request.resource_name());
- if (!hash) {
+ if (not hash) {
auto str = fmt::format("could not parse {}", request.resource_name());
logger_.Emit(LogLevel::Error, "{}", str);
return ::grpc::Status{::grpc::StatusCode::INVALID_ARGUMENT, str};
@@ -126,13 +126,13 @@ auto BytestreamServiceImpl::Write(
request.write_offset(),
request.finish_write());
auto lock = GarbageCollector::SharedLock(storage_config_);
- if (!lock) {
+ if (not lock) {
auto str = fmt::format("Could not acquire SharedLock");
logger_.Emit(LogLevel::Error, str);
return grpc::Status{grpc::StatusCode::INTERNAL, str};
}
auto tmp_dir = storage_config_.CreateTypedTmpDir("execution-service");
- if (!tmp_dir) {
+ if (not tmp_dir) {
return ::grpc::Status{::grpc::StatusCode::INTERNAL,
"could not create TmpDir"};
}
@@ -142,7 +142,7 @@ auto BytestreamServiceImpl::Write(
of.write(request.data().data(),
static_cast<std::streamsize>(request.data().size()));
}
- while (!request.finish_write() && reader->Read(&request)) {
+ while (not request.finish_write() and reader->Read(&request)) {
std::ofstream of{tmp, std::ios::binary | std::ios::app};
of.write(request.data().data(),
static_cast<std::streamsize>(request.data().size()));
diff --git a/src/buildtool/execution_api/execution_service/capabilities_server.cpp b/src/buildtool/execution_api/execution_service/capabilities_server.cpp
index 71a1361f..d8ba4279 100644
--- a/src/buildtool/execution_api/execution_service/capabilities_server.cpp
+++ b/src/buildtool/execution_api/execution_service/capabilities_server.cpp
@@ -25,7 +25,7 @@ auto CapabilitiesServiceImpl::GetCapabilities(
const ::bazel_re::GetCapabilitiesRequest*
/*request*/,
::bazel_re::ServerCapabilities* response) -> ::grpc::Status {
- if (!Compatibility::IsCompatible()) {
+ if (not Compatibility::IsCompatible()) {
auto const* str = "GetCapabilities not implemented";
Logger::Log(LogLevel::Error, str);
return ::grpc::Status{grpc::StatusCode::UNIMPLEMENTED, str};
diff --git a/src/buildtool/execution_api/execution_service/cas_server.cpp b/src/buildtool/execution_api/execution_service/cas_server.cpp
index 67437be6..3ab31fc8 100644
--- a/src/buildtool/execution_api/execution_service/cas_server.cpp
+++ b/src/buildtool/execution_api/execution_service/cas_server.cpp
@@ -36,7 +36,7 @@ static constexpr std::size_t kSHA256Length = 64;
static auto IsValidHash(std::string const& x) -> bool {
auto error_msg = IsAHash(x);
auto const& length = x.size();
- return !error_msg and
+ return not error_msg and
((Compatibility::IsCompatible() and length == kSHA256Length) or
length == kGitSHA1Length);
}
@@ -63,7 +63,7 @@ auto CASServiceImpl::FindMissingBlobs(
const ::bazel_re::FindMissingBlobsRequest* request,
::bazel_re::FindMissingBlobsResponse* response) -> ::grpc::Status {
auto lock = GarbageCollector::SharedLock(storage_config_);
- if (!lock) {
+ if (not lock) {
auto str =
fmt::format("FindMissingBlobs: could not acquire SharedLock");
logger_.Emit(LogLevel::Error, str);
@@ -72,7 +72,7 @@ auto CASServiceImpl::FindMissingBlobs(
for (auto const& x : request->blob_digests()) {
auto const& hash = x.hash();
- if (!IsValidHash(hash)) {
+ if (not IsValidHash(hash)) {
logger_.Emit(LogLevel::Error,
"FindMissingBlobs: unsupported digest {}",
hash);
@@ -120,7 +120,7 @@ auto CASServiceImpl::BatchUpdateBlobs(
const ::bazel_re::BatchUpdateBlobsRequest* request,
::bazel_re::BatchUpdateBlobsResponse* response) -> ::grpc::Status {
auto lock = GarbageCollector::SharedLock(storage_config_);
- if (!lock) {
+ if (not lock) {
auto str =
fmt::format("BatchUpdateBlobs: could not acquire SharedLock");
logger_.Emit(LogLevel::Error, str);
@@ -129,7 +129,7 @@ auto CASServiceImpl::BatchUpdateBlobs(
for (auto const& x : request->requests()) {
auto const& hash = x.digest().hash();
logger_.Emit(LogLevel::Trace, "BatchUpdateBlobs: {}", hash);
- if (!IsValidHash(hash)) {
+ if (not IsValidHash(hash)) {
auto const& str =
fmt::format("BatchUpdateBlobs: unsupported digest {}", hash);
logger_.Emit(LogLevel::Error, "{}", str);
@@ -149,7 +149,7 @@ auto CASServiceImpl::BatchUpdateBlobs(
str};
}
auto const& dgst = storage_.CAS().StoreTree(x.data());
- if (!dgst) {
+ if (not dgst) {
auto const& str = fmt::format(
"BatchUpdateBlobs: could not upload tree {}", hash);
logger_.Emit(LogLevel::Error, "{}", str);
@@ -163,7 +163,7 @@ auto CASServiceImpl::BatchUpdateBlobs(
}
else {
auto const& dgst = storage_.CAS().StoreBlob(x.data(), false);
- if (!dgst) {
+ if (not dgst) {
auto const& str = fmt::format(
"BatchUpdateBlobs: could not upload blob {}", hash);
logger_.Emit(LogLevel::Error, "{}", str);
@@ -184,7 +184,7 @@ auto CASServiceImpl::BatchReadBlobs(
const ::bazel_re::BatchReadBlobsRequest* request,
::bazel_re::BatchReadBlobsResponse* response) -> ::grpc::Status {
auto lock = GarbageCollector::SharedLock(storage_config_);
- if (!lock) {
+ if (not lock) {
auto str = fmt::format("BatchReadBlobs: Could not acquire SharedLock");
logger_.Emit(LogLevel::Error, "{}", str);
return grpc::Status{grpc::StatusCode::INTERNAL, str};
@@ -199,7 +199,7 @@ auto CASServiceImpl::BatchReadBlobs(
else {
path = storage_.CAS().BlobPath(digest, false);
}
- if (!path) {
+ if (not path) {
google::rpc::Status status;
status.set_code(grpc::StatusCode::NOT_FOUND);
r->mutable_status()->CopyFrom(status);
diff --git a/src/buildtool/execution_api/execution_service/execution_server.cpp b/src/buildtool/execution_api/execution_service/execution_server.cpp
index 2e56bd04..132a812f 100644
--- a/src/buildtool/execution_api/execution_service/execution_server.cpp
+++ b/src/buildtool/execution_api/execution_service/execution_server.cpp
@@ -46,7 +46,7 @@ auto ExecutionServiceImpl::GetAction(::bazel_re::ExecuteRequest const* request)
return {std::nullopt, *error_msg};
}
auto path = storage_.CAS().BlobPath(request->action_digest(), false);
- if (!path) {
+ if (not path) {
auto str = fmt::format("could not retrieve blob {} from cas",
request->action_digest().hash());
logger_.Emit(LogLevel::Error, "{}", str);
@@ -55,7 +55,7 @@ auto ExecutionServiceImpl::GetAction(::bazel_re::ExecuteRequest const* request)
::bazel_re::Action action{};
{
std::ifstream f(*path);
- if (!action.ParseFromIstream(&f)) {
+ if (not action.ParseFromIstream(&f)) {
auto str = fmt::format("failed to parse action from blob {}",
request->action_digest().hash());
logger_.Emit(LogLevel::Error, "{}", str);
@@ -71,7 +71,7 @@ auto ExecutionServiceImpl::GetAction(::bazel_re::ExecuteRequest const* request)
? storage_.CAS().BlobPath(action.input_root_digest(), false)
: storage_.CAS().TreePath(action.input_root_digest());
- if (!path) {
+ if (not path) {
auto str = fmt::format("could not retrieve input root {} from cas",
action.input_root_digest().hash());
logger_.Emit(LogLevel::Error, "{}", str);
@@ -88,7 +88,7 @@ auto ExecutionServiceImpl::GetCommand(::bazel_re::Action const& action)
return {std::nullopt, *error_msg};
}
auto path = storage_.CAS().BlobPath(action.command_digest(), false);
- if (!path) {
+ if (not path) {
auto str = fmt::format("could not retrieve blob {} from cas",
action.command_digest().hash());
logger_.Emit(LogLevel::Error, "{}", str);
@@ -98,7 +98,7 @@ auto ExecutionServiceImpl::GetCommand(::bazel_re::Action const& action)
::bazel_re::Command c{};
{
std::ifstream f(*path);
- if (!c.ParseFromIstream(&f)) {
+ if (not c.ParseFromIstream(&f)) {
auto str = fmt::format("failed to parse command from blob {}",
action.command_digest().hash());
logger_.Emit(LogLevel::Error, "{}", str);
@@ -127,7 +127,7 @@ auto ExecutionServiceImpl::GetIExecutionAction(
std::optional<std::string>> {
auto [c, msg_c] = GetCommand(action);
- if (!c) {
+ if (not c) {
return {std::nullopt, *msg_c};
}
@@ -141,7 +141,7 @@ auto ExecutionServiceImpl::GetIExecutionAction(
{c->output_directories().begin(), c->output_directories().end()},
env_vars,
{});
- if (!i_execution_action) {
+ if (not i_execution_action) {
auto str = fmt::format("could not create action from {}",
request->action_digest().hash());
logger_.Emit(LogLevel::Error, "{}", str);
@@ -366,7 +366,7 @@ auto ExecutionServiceImpl::AddResult(
if (i_execution_response->HasStdErr()) {
auto dgst = storage_.CAS().StoreBlob(i_execution_response->StdErr(),
/*is_executable=*/false);
- if (!dgst) {
+ if (not dgst) {
auto str =
fmt::format("Could not store stderr of action {}", action_hash);
logger_.Emit(LogLevel::Error, "{}", str);
@@ -377,7 +377,7 @@ auto ExecutionServiceImpl::AddResult(
if (i_execution_response->HasStdOut()) {
auto dgst = storage_.CAS().StoreBlob(i_execution_response->StdOut(),
/*is_executable=*/false);
- if (!dgst) {
+ if (not dgst) {
auto str =
fmt::format("Could not store stdout of action {}", action_hash);
logger_.Emit(LogLevel::Error, "{}", str);
@@ -448,18 +448,18 @@ auto ExecutionServiceImpl::Execute(
::grpc::ServerWriter<::google::longrunning::Operation>* writer)
-> ::grpc::Status {
auto lock = GarbageCollector::SharedLock(storage_config_);
- if (!lock) {
+ if (not lock) {
auto str = fmt::format("Could not acquire SharedLock");
logger_.Emit(LogLevel::Error, str);
return grpc::Status{grpc::StatusCode::INTERNAL, str};
}
auto [action, msg_a] = GetAction(request);
- if (!action) {
+ if (not action) {
return ::grpc::Status{grpc::StatusCode::INTERNAL, *msg_a};
}
auto [i_execution_action, msg] = GetIExecutionAction(request, *action);
- if (!i_execution_action) {
+ if (not i_execution_action) {
return ::grpc::Status{grpc::StatusCode::INTERNAL, *msg};
}
@@ -482,7 +482,7 @@ auto ExecutionServiceImpl::Execute(
std::chrono::duration_cast<std::chrono::seconds>(t1 - t0).count());
auto [execute_response, msg_r] = GetResponse(request, i_execution_response);
- if (!execute_response) {
+ if (not execute_response) {
return ::grpc::Status{grpc::StatusCode::INTERNAL, *msg_r};
}
@@ -509,14 +509,14 @@ auto ExecutionServiceImpl::WaitExecution(
std::optional<::google::longrunning::Operation> op;
do {
op = op_cache_.Query(hash);
- if (!op) {
+ if (not op) {
auto const& str = fmt::format(
"Executing action {} not found in internal cache.", hash);
logger_.Emit(LogLevel::Error, "{}", str);
return ::grpc::Status{grpc::StatusCode::INTERNAL, str};
}
std::this_thread::sleep_for(std::chrono::seconds(1));
- } while (!op->done());
+ } while (not op->done());
writer->Write(*op);
logger_.Emit(LogLevel::Trace, "Finished WaitExecution {}", hash);
return ::grpc::Status::OK;
diff --git a/src/buildtool/execution_api/execution_service/operations_server.cpp b/src/buildtool/execution_api/execution_service/operations_server.cpp
index 23023c7d..0654a5ff 100644
--- a/src/buildtool/execution_api/execution_service/operations_server.cpp
+++ b/src/buildtool/execution_api/execution_service/operations_server.cpp
@@ -30,7 +30,7 @@ auto OperarationsServiceImpl::GetOperation(
logger_.Emit(LogLevel::Trace, "GetOperation: {}", hash);
std::optional<::google::longrunning::Operation> op;
op = op_cache_.Query(hash);
- if (!op) {
+ if (not op) {
auto const& str = fmt::format(
"Executing action {} not found in internal cache.", hash);
logger_.Emit(LogLevel::Error, "{}", str);
diff --git a/src/buildtool/execution_api/execution_service/server_implementation.cpp b/src/buildtool/execution_api/execution_service/server_implementation.cpp
index 43edd6aa..988d22a7 100644
--- a/src/buildtool/execution_api/execution_service/server_implementation.cpp
+++ b/src/buildtool/execution_api/execution_service/server_implementation.cpp
@@ -41,7 +41,7 @@ namespace {
template <typename T>
auto TryWrite(std::string const& file, T const& content) noexcept -> bool {
std::ofstream of{file};
- if (!of.good()) {
+ if (not of.good()) {
Logger::Log(LogLevel::Error,
"Could not open {}. Make sure to have write permissions",
file);
@@ -123,7 +123,7 @@ auto ServerImpl::Run(gsl::not_null<LocalContext const*> const& local_context,
fmt::format("{}:{}", interface_, port_), creds, &port_);
auto server = builder.BuildAndStart();
- if (!server) {
+ if (not server) {
Logger::Log(LogLevel::Error, "Could not start execution service");
return false;
}
@@ -133,8 +133,8 @@ auto ServerImpl::Run(gsl::not_null<LocalContext const*> const& local_context,
nlohmann::json const& info = {
{"interface", interface_}, {"port", port_}, {"pid", pid}};
- if (!pid_file_.empty()) {
- if (!TryWrite(pid_file_, pid)) {
+ if (not pid_file_.empty()) {
+ if (not TryWrite(pid_file_, pid)) {
server->Shutdown();
return false;
}
@@ -146,8 +146,8 @@ auto ServerImpl::Run(gsl::not_null<LocalContext const*> const& local_context,
Compatibility::IsCompatible() ? "compatible " : "",
info_str));
- if (!info_file_.empty()) {
- if (!TryWrite(info_file_, info_str)) {
+ if (not info_file_.empty()) {
+ if (not TryWrite(info_file_, info_str)) {
server->Shutdown();
return false;
}