Skip to content

Remove setDriveStatus() from OStoreDB

Current "set status" logic

image

Problem to be solved

There are multiple way to do the same thing. We may consider keeping only one way of reporting the drive statuses.

Suggestion

Keep Scheduler::reportDriveStatus(). It would simplify the logic and alleviate the OStoreDB class.

If we decide to do so, we will need to overload reportDriveStatus() to pass also the mount details to the TapeDrivesCatalogueState. They are needed for getNextMount() and some other internal methods to work correctly and identify existing or next mount for each drive.

Reference implementation:

void Scheduler::reportDriveStatus(const common::dataStructures::DriveInfo &driveInfo, const cta::TapeMount &tapeMount,
                                  common::dataStructures::DriveStatus status, const std::optional<std::string> &reason,
                                  log::LogContext &lc) {
  utils::Timer t;
  // We just report the drive status as instructed by the tape thread.
  // Reset the drive state.
  ReportDriveStatusInputs inputs;
  inputs.mountType = tapeMount.getMountType();
  inputs.mountSessionId = std::strtoull(tapeMount.getMountTransactionId().c_str(), nullptr, 0);
  inputs.reportTime = time(nullptr);
  inputs.status = status;
  inputs.vid = tapeMount.getVid();
  inputs.tapepool = tapeMount.getPoolName();
  inputs.vo = tapeMount.getVo();
  inputs.reason = reason;
  inputs.activity = tapeMount.getActivity();
  // TODO: statistics!
  inputs.byteTransferred = 0;
  inputs.filesTransferred = 0;
  m_tapeDrivesState->updateDriveStatus(driveInfo, inputs, lc);
  auto schedulerDbTime = t.secs();
  if (schedulerDbTime > 1) {
    log::ScopedParamContainer spc(lc);
    spc.add("drive", driveInfo.driveName)
      .add("schedulerDbTime", schedulerDbTime);
    lc.log(log::DEBUG, "In Scheduler::reportDriveStatus(): success.");
  }
}

Then we will need to let the report packers to have access to the Scheduler to use this method.