RootEntry.hpp 4.37 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 "EntryLogSerDeser.hpp"
26
#include "UserIdentity.hpp"
27
#include "common/MountControl.hpp"
28
#include <list>
29

30
31
namespace cta { namespace objectstore {

32
class AgentReference;
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 handling  ====================================================
54
55
  CTA_GENERATE_EXCEPTION_CLASS(ArchivelQueueNotEmpty);
  CTA_GENERATE_EXCEPTION_CLASS(WrongArchiveQueue);
56
57
  /** This function implicitly creates the archive queue structure and updates 
   * the pointer to it. It will implicitly commit the object to the store. */
58
  std::string addOrGetArchiveQueueAndCommit(const std::string & tapePool, AgentReference & agentRef);
59
60
  /** This function implicitly deletes the tape pool structure. 
   * Fails if it not empty*/
61
  CTA_GENERATE_EXCEPTION_CLASS(NoSuchArchiveQueue);
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
  struct ArchiveQueueDump {
66
67
68
    std::string tapePool;
    std::string address;
  };
69
  std::list<ArchiveQueueDump> dumpArchiveQueues();
70
  
71
  // RetrieveQueue handling ====================================================
72
  CTA_GENERATE_EXCEPTION_CLASS(RetrieveQueueNotEmpty);
73
74
  /** This function implicitly creates the retrieve queue structure and updates 
   * the pointer to it. It will implicitly commit the object to the store. */
75
  std::string addOrGetRetrieveQueueAndCommit(const std::string & vid, AgentReference & agentRef);
76
  CTA_GENERATE_EXCEPTION_CLASS(NoSuchRetrieveQueue);
77
  void removeRetrieveQueueAndCommit(const std::string & vid);
78
  std::string getRetrieveQueue(const std::string & vid);
79
80
81
82
83
  struct RetrieveQueueDump {
    std::string vid;
    std::string address;
  };
  std::list<RetrieveQueueDump> dumpRetrieveQueues();
84
  
85
  // Drive register manipulations ==============================================
Eric Cano's avatar
Eric Cano committed
86
87
  CTA_GENERATE_EXCEPTION_CLASS(DriveRegisterNotEmpty);
  std::string getDriveRegisterAddress();  
88
  std::string addOrGetDriveRegisterPointerAndCommit(AgentReference & agentRef, const EntryLogSerDeser & log);
Eric Cano's avatar
Eric Cano committed
89
  void removeDriveRegisterAndCommit();
90
  
91
  // Agent register manipulations ==============================================
92
93
  CTA_GENERATE_EXCEPTION_CLASS(AgentRegisterNotEmpty);
  std::string getAgentRegisterAddress();
94
95
  /** 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
96
97
   * log for tracking objects being created. We already use an agent here for
   * object name generation, but not yet tracking. */
98
  std::string addOrGetAgentRegisterPointerAndCommit(AgentReference & agentRef,
99
    const EntryLogSerDeser & log);
Eric Cano's avatar
Eric Cano committed
100
  void removeAgentRegisterAndCommit();
101

102
103
  // Agent register manipulations ==============================================
  std::string getSchedulerGlobalLock();
104
  std::string addOrGetSchedulerGlobalLockAndCommit(AgentReference & agentRef, const EntryLogSerDeser & log);
105
106
  void removeSchedulerGlobalLockAndCommit();
  
107
private:
108
  void addIntendedAgentRegistry(const std::string & address);
109
  
110
public:
111
  // Dump the root entry
112
  std::string dump ();
113
114
};

115
116
}}

117