#include <XrdHttpTapeApiStore.hh>
Definition at line 21 of file XrdHttpTapeApiStore.hh.
◆ XrdHttpTapeApiStore()
| XrdHttpTapeApiStore::XrdHttpTapeApiStore |
( |
std::filesystem::path |
root | ) |
|
|
explicit |
Definition at line 60 of file XrdHttpTapeApiStore.cc.
61 : m_root(std::move(root)),
62 m_archiveRoot(m_root /
"archive"),
63 m_diskRoot(m_root /
"disk"),
64 m_requestsRoot(m_root /
"requests")
◆ ArchiveInfo()
Definition at line 381 of file XrdHttpTapeApiStore.cc.
384 std::lock_guard<std::mutex> lock(m_mutex);
385 response = Json::array();
386 for(
const auto &path : paths)
389 std::string normalized;
390 fs::path archivePath;
391 Status status = ResolvePath(m_archiveRoot, path.get<std::string>(),
392 normalized, archivePath);
393 item[
"path"] = status ? normalized : path.get<std::string>();
396 if(status) status = ResolvePath(m_diskRoot, normalized,
397 normalized, diskPath);
398 bool archived =
false;
399 if(status && !IsRegularFile(archivePath, archived))
401 status =
Error(500,
"could not inspect the archived file");
404 if(status && !IsRegularFile(diskPath, onDisk))
406 status =
Error(500,
"could not inspect the disk file");
411 item[
"error"] = status.message;
413 else if(archived && onDisk)
415 item[
"locality"] =
"DISK_AND_TAPE";
419 item[
"locality"] =
"TAPE";
423 item[
"locality"] =
"DISK";
427 item[
"error"] =
"file does not exist";
429 response.push_back(std::move(item));
References Error, and XrdHttpTapeApiStore::Status::message.
◆ CancelStage()
Definition at line 329 of file XrdHttpTapeApiStore.cc.
332 std::lock_guard<std::mutex> lock(m_mutex);
334 Status status = ReadRequest(requestId, request);
335 if(!status)
return status;
336 std::vector<std::string> normalized;
337 return ValidateRequestPaths(request, paths, normalized);
◆ CreateStage()
Definition at line 219 of file XrdHttpTapeApiStore.cc.
222 std::lock_guard<std::mutex> lock(m_mutex);
223 requestId = GenerateRequestId();
224 const std::uint64_t createdAt = Now();
227 {
"createdAt", createdAt},
228 {
"startedAt", createdAt},
229 {
"files", Json::array()}
232 for(
const auto &input : files)
235 std::string normalized;
236 fs::path archivePath;
237 Status status = ResolvePath(m_archiveRoot,
238 input.at(
"path").get<std::string>(),
239 normalized, archivePath);
240 file[
"path"] = normalized;
241 file[
"startedAt"] = createdAt;
244 if(status) status = ResolvePath(m_diskRoot, normalized,
245 normalized, diskPath);
246 bool archived =
false;
247 if(status && !IsRegularFile(archivePath, archived))
249 status =
Error(500,
"could not inspect the archived file");
251 std::error_code error;
252 if(status && archived && fs::file_size(archivePath, error) == 0)
254 status =
Error(400,
"zero-length files cannot be staged from tape");
256 if(error) status =
Error(500,
"could not inspect the archived file");
259 if(status && !IsRegularFile(diskPath, onDisk))
261 status =
Error(500,
"could not inspect the disk file");
263 if(status && archived && !onDisk)
266 fs::create_directories(diskPath.parent_path(), error);
269 fs::copy_file(archivePath, diskPath, fs::copy_options::overwrite_existing,
272 if(error) status =
Error(500,
"could not stage the archived file");
274 file[
"finishedAt"] = Now();
275 if(status && archived)
277 file[
"state"] =
"COMPLETED";
281 file[
"state"] =
"FAILED";
282 file[
"error"] = status ?
"file is not stored on tape" : status.message;
284 request[
"files"].push_back(std::move(file));
287 request[
"completedAt"] = Now();
288 return WriteRequest(request);
References Error, and XrdHttpTapeApiStore::Status::message.
◆ DeleteStage()
Definition at line 340 of file XrdHttpTapeApiStore.cc.
343 std::lock_guard<std::mutex> lock(m_mutex);
345 Status status = ReadRequest(requestId, request);
346 if(!status)
return status;
348 std::error_code error;
349 if(!fs::remove(m_requestsRoot / (requestId +
".json"), error) || error)
351 return Error(500,
"could not delete the stage request");
References Error.
◆ GetStage()
Definition at line 291 of file XrdHttpTapeApiStore.cc.
294 std::lock_guard<std::mutex> lock(m_mutex);
296 const Status status = ReadRequest(requestId, request);
297 if(!status)
return status;
298 response = StatusResponse(request);
◆ Initialize()
Definition at line 68 of file XrdHttpTapeApiStore.cc.
70 std::error_code error;
71 fs::create_directories(m_archiveRoot, error);
72 if(error)
return Error(500,
"could not create the tape archive directory");
73 fs::create_directories(m_diskRoot, error);
74 if(error)
return Error(500,
"could not create the disk directory");
75 fs::create_directories(m_requestsRoot, error);
76 if(error)
return Error(500,
"could not create the request directory");
78 m_root = fs::weakly_canonical(m_root, error);
79 if(error)
return Error(500,
"could not resolve the Tape API directory");
80 m_archiveRoot = m_root /
"archive";
81 m_diskRoot = m_root /
"disk";
82 m_requestsRoot = m_root /
"requests";
References Error.
◆ Release()
Definition at line 356 of file XrdHttpTapeApiStore.cc.
359 std::lock_guard<std::mutex> lock(m_mutex);
361 Status status = ReadRequest(requestId, request);
362 if(!status)
return status;
364 std::vector<std::string> normalized;
365 status = ValidateRequestPaths(request, paths, normalized);
366 if(!status)
return status;
368 for(
const auto &path : normalized)
372 status = ResolvePath(m_diskRoot, path, ignored, diskPath);
373 if(!status)
return status;
374 std::error_code error;
375 fs::remove(diskPath, error);
376 if(error)
return Error(500,
"could not release the disk replica");
References Error.
The documentation for this class was generated from the following files: