ArchiveJob.cpp 3.16 KB
Newer Older
1
/*
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 * 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/>.
 */

19
#include "scheduler/ArchiveJob.hpp"
20
#include <limits>
21
22
23
24

//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
25
cta::ArchiveJob::~ArchiveJob() throw() {
26
27
}

28
29
30
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
31
32
cta::ArchiveJob::ArchiveJob(ArchiveMount &mount,
  NameServer & ns,
33
34
  const ArchiveFile &archiveFile,
  const RemotePathAndStatus &remotePathAndStatus,
35
36
  const NameServerTapeFile &nsTapeFile):
  m_mount(mount), m_ns(ns),
37
  archiveFile(archiveFile),
38
  remotePathAndStatus(remotePathAndStatus),
39
  nameServerTapeFile(nsTapeFile) {}
Steven Murray's avatar
Steven Murray committed
40

41
42
43
//------------------------------------------------------------------------------
// complete
//------------------------------------------------------------------------------
44
void cta::ArchiveJob::complete() {
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  // First check that the block Id for the file has been set.
  if (nameServerTapeFile.tapeFileLocation.blockId ==
      std::numeric_limits<decltype(nameServerTapeFile.tapeFileLocation.blockId)>::max())
    throw BlockIdNotSet("In cta::ArchiveJob::complete(): Block ID not set");
  // Also check the checksum has been set
  if (nameServerTapeFile.checksum.getType() == Checksum::CHECKSUMTYPE_NONE)
    throw ChecksumNotSet("In cta::ArchiveJob::complete(): checksum not set");
  // We are good to go to record the data in the persistent storage.
  // First make the file safe on tape.
  m_dbJob->bumpUpTapeFileCount(nameServerTapeFile.tapeFileLocation.vid,
      nameServerTapeFile.tapeFileLocation.fSeq);
  // Now record the data in the archiveNS
  m_ns.addTapeFile(SecurityIdentity(UserIdentity(std::numeric_limits<uint32_t>::max(), 
    std::numeric_limits<uint32_t>::max()), ""), archiveFile.path, nameServerTapeFile);
  // We can now record the success for the job in the database
  m_dbJob->succeed();
61
62
63
64
65
}
  
//------------------------------------------------------------------------------
// failed
//------------------------------------------------------------------------------
66
void cta::ArchiveJob::failed(const cta::exception::Exception &ex) {
67
  throw NotImplemented("");
68
69
70
71
72
73
}
  
//------------------------------------------------------------------------------
// retry
//------------------------------------------------------------------------------
void cta::ArchiveJob::retry() {
74
  throw NotImplemented("");
75
}