Skip to content
Snippets Groups Projects
  • Steven Murray's avatar
    03133fa0
    CTA front-end now logs duplicate tape copy numbers · 03133fa0
    Steven Murray authored
    If the "cta af ls" command is executed and the listing
    encounters duplicate tape copy numbers then the listing
    continues with "workaround" number displayed in place
    of the duplicates and inow with this commit a log
    message is alseo written to
    
        /var/log/cta/cta-frontent.log
    
    An example log:
    
    2017-07-12T18:04:40.691236+02:00 itdssbuild01 cta-frontend: LVL="Warn" PID="9423" TID="9436" MSG="Found a duplicate tape copy number when listing archive files" archiveFileID="5" duplicateCopyNb="1" workaroundCopyNb="2" vid="V41001" fSeq="5" blockId="41"
    03133fa0
    History
    CTA front-end now logs duplicate tape copy numbers
    Steven Murray authored
    If the "cta af ls" command is executed and the listing
    encounters duplicate tape copy numbers then the listing
    continues with "workaround" number displayed in place
    of the duplicates and inow with this commit a log
    message is alseo written to
    
        /var/log/cta/cta-frontent.log
    
    An example log:
    
    2017-07-12T18:04:40.691236+02:00 itdssbuild01 cta-frontend: LVL="Warn" PID="9423" TID="9436" MSG="Found a duplicate tape copy number when listing archive files" archiveFileID="5" duplicateCopyNb="1" workaroundCopyNb="2" vid="V41001" fSeq="5" blockId="41"
ArchiveFileBuilder.hpp 3.20 KiB
/*
 * The CERN Tape Archive (CTA) project
 * Copyright (C) 2015  CERN
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include "common/dataStructures/ArchiveFile.hpp"
#include "common/log/Logger.hpp"

#include <memory>

namespace cta {
namespace catalogue {

/**
 * Builds ArchiveFile objects from a stream of tape files ordered by archive ID
 * and then copy number.
 */
class ArchiveFileBuilder {
public:

  /**
   * Constructor.
   *
   * @param log Object representing the API to the CTA logging system.
   */
  ArchiveFileBuilder(log::Logger &log);

  /**
   * Appends the specified tape file to the ArchiveFile object currently
   * construction.
   *
   * If this append method is called with the tape file of the next ArchiveFile
   * to be constructed then this means the current ArchiveFile under
   * construction is complete and this method will therefore return the current
   * and complete ArchiveFile object.  The appened tape file will be remembered
   * by this builder object and used to start the construction of the next
   * ArchiveFile object.
   *
   * If this append method is called with an ArchiveFile with no tape files at
   * all then this means the current ArchiveFile under
   * construction is complete and this method will therefore return the current
   * and complete ArchiveFile object.  The appened tape file will be remembered
   * by this builder object and used to start the construction of the next
   * ArchiveFile object.
   *
   * If the call to this append does not complete the ArchiveFile object
   * currently under construction then this method will returns an empty unique
   * pointer.
   *
   * @param tapeFile The tape file to be appended or an archive file with no
   * tape files at all.
   */
  std::unique_ptr<common::dataStructures::ArchiveFile> append(const common::dataStructures::ArchiveFile &tapeFile);

  /**
   * Returns a pointer to the ArchiveFile object currently under construction.
   * A return value of nullptr means there there is no ArchiveFile object
   * currently under construction.
   *
   * @return The ArchiveFile object currently under construction or nullptr
   * if there isn't one.
   */
  common::dataStructures::ArchiveFile *getArchiveFile();

  /**
   * If there is an ArchiveFile under construction then it is forgotten.
   */
  void clear();

private:

  /**
   * Object representing the API to the CTA logging system.
   */
  log::Logger &m_log;

  /**
   * The Archivefile object currently under construction.
   */
  std::unique_ptr<common::dataStructures::ArchiveFile> m_archiveFile;

}; // class ArchiveFileBuilder

} // namespace catalogue
} // namespace cta