RootEntry.hpp 3.62 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
20
21
22
#pragma once

#include "objectstore/cta.pb.h"

23
#include "Backend.hpp"
24
#include "ObjectOps.hpp"
25
#include "EntryLog.hpp"
26
#include "UserIdentity.hpp"
27
#include "common/MountControl.hpp"
28
#include <list>
29

30
31
namespace cta { namespace objectstore {

32
class Agent;
33
class GenericObject;
34
  
35
class RootEntry: public ObjectOps<serializers::RootEntry, serializers::RootEntry_t> {
36
public:
37
  // Constructor
38
  RootEntry(Backend & os);
39
  RootEntry(GenericObject & go);
40
  
41
  CTA_GENERATE_EXCEPTION_CLASS(NotAllocated);
Eric Cano's avatar
Eric Cano committed
42
  CTA_GENERATE_EXCEPTION_CLASS(NotEmpty);
43
  
44
45
46
  // In memory initialiser
  void initialize();
  
Eric Cano's avatar
Eric Cano committed
47
48
49
50
51
52
  // Emptyness checker
  bool isEmpty();
  
  // Safe remover
  void removeIfEmpty();
  
53
  // ArchiveQueue Manipulations =====================================================
54
55
  CTA_GENERATE_EXCEPTION_CLASS(ArchivelQueueNotEmpty);
  CTA_GENERATE_EXCEPTION_CLASS(WrongArchiveQueue);
56
57
  /** This function implicitly creates the tape pool structure and updates 
   * the pointer to it. It needs to implicitly commit the object to the store. */
58
  std::string addOrGetArchiveQueueAndCommit(const std::string & tapePool, Agent & agent);
59
60
61
  /** This function implicitly deletes the tape pool structure. 
   * Fails if it not empty*/
  CTA_GENERATE_EXCEPTION_CLASS(NoSuchTapePoolQueue);
Eric Cano's avatar
Eric Cano committed
62
  void removeArchiveQueueAndCommit(const std::string & tapePool);
63
  void removeArchiveQueueIfAddressMatchesAndCommit(const std::string & tapePool, const std::string & archiveQueueAddress);
Eric Cano's avatar
Eric Cano committed
64
  std::string getArchiveQueueAddress(const std::string & tapePool);
65
  class ArchiveQueueDump {
66
67
68
69
  public:
    std::string tapePool;
    std::string address;
  };
70
  std::list<ArchiveQueueDump> dumpArchiveQueues();
71
  
72
  // Drive register manipulations ==============================================
Eric Cano's avatar
Eric Cano committed
73
74
  CTA_GENERATE_EXCEPTION_CLASS(DriveRegisterNotEmpty);
  std::string getDriveRegisterAddress();  
75
  std::string addOrGetDriveRegisterPointerAndCommit(Agent & agent, const EntryLog & log);
Eric Cano's avatar
Eric Cano committed
76
  void removeDriveRegisterAndCommit();
77
  
78
  // Agent register manipulations ==============================================
79
80
  CTA_GENERATE_EXCEPTION_CLASS(AgentRegisterNotEmpty);
  std::string getAgentRegisterAddress();
81
82
  /** We do pass the agent here even if there is no agent register yet, as it
   * is used to generate the object name. We have the dedicated agent intent
83
84
85
   * log for tracking objects being created. We already use an agent here for
   * object name generation, but not yet tracking. */
  std::string addOrGetAgentRegisterPointerAndCommit(Agent & agent,
86
    const EntryLog & log);
Eric Cano's avatar
Eric Cano committed
87
  void removeAgentRegisterAndCommit();
88

89
90
  // Agent register manipulations ==============================================
  std::string getSchedulerGlobalLock();
91
  std::string addOrGetSchedulerGlobalLockAndCommit(Agent & agent, const EntryLog & log);
92
93
  void removeSchedulerGlobalLockAndCommit();
  
94
private:
95
  void addIntendedAgentRegistry(const std::string & address);
96
  
97
public:
98
  // Dump the root entry
99
  std::string dump ();
100
101
};

102
103
}}

104