Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
91031518
Commit
91031518
authored
Dec 01, 2015
by
Eric Cano
Browse files
Created a new command line program to dump individual objects.
Partial implementation of per object type dump.
parent
f50734f3
Changes
11
Hide whitespace changes
Inline
Side-by-side
objectstore/Agent.cpp
View file @
91031518
...
...
@@ -19,6 +19,7 @@
#include
"Agent.hpp"
#include
"AgentRegister.hpp"
#include
"RootEntry.hpp"
#include
"GenericObject.hpp"
#include
"common/exception/Errnum.hpp"
#include
"ProtocolBuffersAlgorithms.hpp"
#include
<string>
...
...
@@ -28,10 +29,19 @@
#include
<ctime>
#include
<cxxabi.h>
#include
<unistd.h>
#include
<json/json.h>
cta
::
objectstore
::
Agent
::
Agent
(
Backend
&
os
)
:
ObjectOps
<
serializers
::
Agent
>
(
os
),
m_nextId
(
0
)
{}
cta
::
objectstore
::
Agent
::
Agent
(
GenericObject
&
go
)
:
ObjectOps
<
serializers
::
Agent
>
(
go
.
objectStore
())
{
// Here we transplant the generic object into the new object
go
.
transplantHeader
(
*
this
);
// And interpret the header.
getPayloadFromHeader
();
}
cta
::
objectstore
::
Agent
::
Agent
(
const
std
::
string
&
name
,
Backend
&
os
)
:
ObjectOps
<
serializers
::
Agent
>
(
os
,
name
),
m_nextId
(
0
)
{}
...
...
@@ -199,3 +209,23 @@ void cta::objectstore::Agent::setTimeout_us(uint64_t timeout) {
m_payload
.
set_timeout_us
(
timeout
);
}
std
::
string
cta
::
objectstore
::
Agent
::
dump
()
{
checkPayloadReadable
();
std
::
stringstream
ret
;
ret
<<
"Agent"
<<
std
::
endl
;
struct
json_object
*
jo
=
json_object_new_object
();
// Array for owned objects
json_object
*
joo
=
json_object_new_array
();
auto
&
ool
=
m_payload
.
ownedobjects
();
for
(
auto
oo
=
ool
.
begin
();
oo
!=
ool
.
end
();
oo
++
)
{
json_object_array_add
(
joo
,
json_object_new_string
(
oo
->
c_str
()));
}
json_object_object_add
(
jo
,
"ownedObjects"
,
joo
);
json_object_object_add
(
jo
,
"description"
,
json_object_new_string
(
m_payload
.
description
().
c_str
()));
json_object_object_add
(
jo
,
"heartbeat"
,
json_object_new_int64
(
m_payload
.
heartbeat
()));
json_object_object_add
(
jo
,
"timeout_us"
,
json_object_new_int64
(
m_payload
.
timeout_us
()));
ret
<<
json_object_to_json_string_ext
(
jo
,
JSON_C_TO_STRING_PRETTY
)
<<
std
::
endl
;
return
ret
.
str
();
}
objectstore/Agent.hpp
View file @
91031518
...
...
@@ -25,6 +25,8 @@
#include
<list>
namespace
cta
{
namespace
objectstore
{
class
GenericObject
;
/**
* Class containing agent information and managing the update of the
...
...
@@ -39,6 +41,7 @@ class Agent: public ObjectOps<serializers::Agent> {
public:
CTA_GENERATE_EXCEPTION_CLASS
(
AgentStillOwnsObjects
);
Agent
(
Backend
&
os
);
Agent
(
GenericObject
&
go
);
Agent
(
const
std
::
string
&
name
,
Backend
&
os
);
...
...
objectstore/AgentRegister.cpp
View file @
91031518
...
...
@@ -19,6 +19,7 @@
#include
"AgentRegister.hpp"
#include
"ProtocolBuffersAlgorithms.hpp"
#include
"GenericObject.hpp"
#include
<json/json_object.h>
cta
::
objectstore
::
AgentRegister
::
AgentRegister
(
Backend
&
os
)
:
ObjectOps
<
serializers
::
AgentRegister
>
(
os
)
{}
...
...
@@ -113,15 +114,20 @@ std::list<std::string> cta::objectstore::AgentRegister::getUntrackedAgents() {
std
::
string
cta
::
objectstore
::
AgentRegister
::
dump
()
{
checkPayloadReadable
();
std
::
stringstream
ret
;
ret
<<
"<<<< AgentRegister "
<<
getAddressIfSet
()
<<
" dump start"
<<
std
::
endl
<<
"Agents array size="
<<
m_payload
.
agents_size
()
<<
std
::
endl
;
ret
<<
"AgentRegister"
<<
std
::
endl
;
struct
json_object
*
jo
;
jo
=
json_object_new_object
();
json_object
*
jal
=
json_object_new_array
();
for
(
int
i
=
0
;
i
<
m_payload
.
agents_size
();
i
++
)
{
ret
<<
"element["
<<
i
<<
"]="
<<
m_payload
.
agents
(
i
)
<<
std
::
endl
;
json_object_array_add
(
jal
,
json_object_new_string
(
m_payload
.
agents
(
i
)
.
c_str
()))
;
}
ret
<<
"Untracked agents array size="
<<
m_payload
.
untrackedagents_size
()
<<
std
::
endl
;
json_object_object_add
(
jo
,
"agents"
,
jal
);
json_object
*
jual
=
json_object_new_array
();
for
(
int
i
=
0
;
i
<
m_payload
.
untrackedagents_size
();
i
++
)
{
ret
<<
"intendedElement["
<<
i
<<
"]="
<<
m_payload
.
untrackedagents
(
i
)
<<
std
::
endl
;
json_object_array_add
(
jual
,
json_object_new_string
(
m_payload
.
untrackedagents
(
i
)
.
c_str
()))
;
}
ret
<<
">>>> AgentRegister "
<<
getAddressIfSet
()
<<
" dump end"
<<
std
::
endl
;
json_object_object_add
(
jo
,
"untrackedAgents"
,
jual
);
ret
<<
json_object_to_json_string_ext
(
jo
,
JSON_C_TO_STRING_PRETTY
)
<<
std
::
endl
;
free
(
jo
);
return
ret
.
str
();
}
\ No newline at end of file
objectstore/ArchiveToFileRequest.hpp
View file @
91031518
...
...
@@ -84,6 +84,7 @@ public:
};
std
::
list
<
JobDump
>
dumpJobs
();
void
garbageCollect
(
const
std
::
string
&
presumedOwner
);
std
::
string
dump
();
};
}}
objectstore/CMakeLists.txt
View file @
91031518
...
...
@@ -50,7 +50,7 @@ add_library (ctaobjectstore SHARED
GenericObject.cpp
GarbageCollector.cpp
SchedulerGlobalLock.cpp
)
target_link_libraries
(
ctaobjectstore Utils rados
)
target_link_libraries
(
ctaobjectstore Utils rados
json
)
set_source_files_properties
(
BackendRados.cpp PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations
)
install
(
TARGETS ctaobjectstore DESTINATION usr/
${
CMAKE_INSTALL_LIBDIR
}
)
...
...
objectstore/GenericObject.cpp
View file @
91031518
...
...
@@ -18,7 +18,14 @@
#include
"GenericObject.hpp"
#include
"AgentRegister.hpp"
#include
"Agent.hpp"
#include
"ArchiveToFileRequest.hpp"
#include
"DriveRegister.hpp"
#include
"RetrieveToFileRequest.hpp"
#include
"RootEntry.hpp"
#include
"SchedulerGlobalLock.hpp"
#include
"TapePool.hpp"
#include
"Tape.hpp"
#include
"DriveRegister.hpp"
#include
<stdexcept>
...
...
@@ -123,8 +130,24 @@ namespace {
std
::
string
GenericObject
::
dump
(
ScopedSharedLock
&
lock
)
{
checkHeaderReadable
();
switch
(
m_header
.
type
())
{
case
serializers
::
RootEntry_t
:
return
dumpWithType
<
RootEntry
>
(
this
,
lock
);
case
serializers
::
AgentRegister_t
:
return
dumpWithType
<
AgentRegister
>
(
this
,
lock
);
case
serializers
::
Agent_t
:
return
dumpWithType
<
Agent
>
(
this
,
lock
);
case
serializers
::
TapePool_t
:
return
dumpWithType
<
TapePool
>
(
this
,
lock
);
case
serializers
::
DriveRegister_t
:
return
dumpWithType
<
DriveRegister
>
(
this
,
lock
);
case
serializers
::
Tape_t
:
return
dumpWithType
<
cta
::
objectstore
::
Tape
>
(
this
,
lock
);
case
serializers
::
ArchiveToFileRequest_t
:
return
dumpWithType
<
ArchiveToFileRequest
>
(
this
,
lock
);
case
serializers
::
RetrieveToFileRequest_t
:
return
dumpWithType
<
RetrieveToFileRequest
>
(
this
,
lock
);
case
serializers
::
SchedulerGlobalLock_t
:
return
dumpWithType
<
SchedulerGlobalLock
>
(
this
,
lock
);
default:
std
::
stringstream
err
;
err
<<
"Unsupported type: "
<<
m_header
.
type
();
...
...
objectstore/RetrieveToFileRequest.hpp
View file @
91031518
...
...
@@ -85,6 +85,7 @@ public:
void
setSize
(
uint64_t
size
);
uint64_t
getSize
();
std
::
list
<
JobDump
>
dumpJobs
();
std
::
string
dump
();
};
}}
objectstore/RootEntry.cpp
View file @
91031518
...
...
@@ -21,6 +21,7 @@
#include
"Agent.hpp"
#include
"TapePool.hpp"
#include
"DriveRegister.hpp"
#include
"GenericObject.hpp"
#include
"SchedulerGlobalLock.hpp"
#include
<cxxabi.h>
#include
"ProtocolBuffersAlgorithms.hpp"
...
...
@@ -30,6 +31,14 @@
cta
::
objectstore
::
RootEntry
::
RootEntry
(
Backend
&
os
)
:
ObjectOps
<
serializers
::
RootEntry
>
(
os
,
"root"
)
{}
cta
::
objectstore
::
RootEntry
::
RootEntry
(
GenericObject
&
go
)
:
ObjectOps
<
serializers
::
RootEntry
>
(
go
.
objectStore
())
{
// Here we transplant the generic object into the new object
go
.
transplantHeader
(
*
this
);
// And interpret the header.
getPayloadFromHeader
();
}
// Initialiser. This uses the base object's initialiser and sets the defaults
// of payload.
void
cta
::
objectstore
::
RootEntry
::
initialize
()
{
...
...
objectstore/RootEntry.hpp
View file @
91031518
...
...
@@ -30,11 +30,13 @@
namespace
cta
{
namespace
objectstore
{
class
Agent
;
class
GenericObject
;
class
RootEntry
:
public
ObjectOps
<
serializers
::
RootEntry
>
{
public:
// Constructor
RootEntry
(
Backend
&
os
);
RootEntry
(
GenericObject
&
go
);
CTA_GENERATE_EXCEPTION_CLASS
(
NotAllocated
);
CTA_GENERATE_EXCEPTION_CLASS
(
NotEmpty
);
...
...
objectstore/SchedulerGlobalLock.hpp
View file @
91031518
...
...
@@ -39,6 +39,7 @@ public:
// Mount id management =======================================================
void
setNextMountId
(
uint64_t
nextId
);
uint64_t
getIncreaseCommitMountId
();
std
::
string
dump
();
};
}}
objectstore/TapePool.hpp
View file @
91031518
...
...
@@ -130,6 +130,8 @@ public:
CTA_GENERATE_EXCEPTION_CLASS
(
NotEmpty
);
// Garbage collection
void
garbageCollect
(
const
std
::
string
&
presumedOwner
);
std
::
string
dump
();
};
}}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment