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
551868b6
Commit
551868b6
authored
Feb 18, 2016
by
Daniele Kruse
Browse files
More work on the CLI, added new utility functions
parent
94d3f36b
Changes
15
Hide whitespace changes
Inline
Side-by-side
common/CMakeLists.txt
View file @
551868b6
...
...
@@ -11,13 +11,17 @@ set (COMMON_LIB_SRC_FILES
dataStructures/ArchiveRoute.cpp
dataStructures/CancelRetrieveRequest.cpp
dataStructures/Dedication.cpp
dataStructures/DedicationType.cpp
dataStructures/DeleteArchiveRequest.cpp
dataStructures/DRData.cpp
dataStructures/DriveState.cpp
dataStructures/DriveStatus.cpp
dataStructures/EntryLog.cpp
dataStructures/ListStorageClassRequest.cpp
dataStructures/MountType.cpp
dataStructures/ReadTestResult.cpp
dataStructures/RepackInfo.cpp
dataStructures/RepackType.cpp
dataStructures/Requester.cpp
dataStructures/RetrieveJob.cpp
dataStructures/RetrieveMount.cpp
...
...
@@ -28,6 +32,7 @@ set (COMMON_LIB_SRC_FILES
dataStructures/TapeFileLocation.cpp
dataStructures/TapeMount.cpp
dataStructures/TapePool.cpp
dataStructures/TestSourceType.cpp
dataStructures/UpdateFileInfoRequest.cpp
dataStructures/User.cpp
dataStructures/UserGroup.cpp
...
...
common/dataStructures/DedicationType.cpp
0 → 100644
View file @
551868b6
/*
* 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/>.
*/
#include
"common/dataStructures/DedicationType.hpp"
std
::
string
cta
::
common
::
dataStructures
::
toString
(
cta
::
common
::
dataStructures
::
DedicationType
type
)
{
switch
(
type
)
{
case
cta
::
common
::
dataStructures
::
DedicationType
::
readonly
:
return
"readonly"
;
case
cta
::
common
::
dataStructures
::
DedicationType
::
writeonly
:
return
"writeonly"
;
case
cta
::
common
::
dataStructures
::
DedicationType
::
readwrite
:
return
"readwrite"
;
default:
return
"UNKNOWN"
;
}
}
\ No newline at end of file
common/dataStructures/DedicationType.hpp
View file @
551868b6
...
...
@@ -18,6 +18,8 @@
#pragma once
#include
<string>
namespace
cta
{
namespace
common
{
namespace
dataStructures
{
...
...
@@ -26,6 +28,8 @@ enum DedicationType {
writeonly
,
readwrite
};
std
::
string
toString
(
DedicationType
type
);
}
// namespace dataStructures
}
// namespace common
}
// namespace cta
...
...
common/dataStructures/DriveState.cpp
View file @
551868b6
...
...
@@ -32,6 +32,7 @@ cta::common::dataStructures::DriveState::DriveState() {
m_logicalLibrarySet
=
false
;
m_mountTypeSet
=
false
;
m_nameSet
=
false
;
m_hostSet
=
false
;
m_sessionIdSet
=
false
;
m_sessionStartTimeSet
=
false
;
m_statusSet
=
false
;
...
...
@@ -56,6 +57,7 @@ bool cta::common::dataStructures::DriveState::allFieldsSet() const {
&&
m_logicalLibrarySet
&&
m_mountTypeSet
&&
m_nameSet
&&
m_hostSet
&&
m_sessionIdSet
&&
m_sessionStartTimeSet
&&
m_statusSet
;
...
...
@@ -223,6 +225,24 @@ std::string cta::common::dataStructures::DriveState::getName() const {
return
m_name
;
}
//------------------------------------------------------------------------------
// setHost
//------------------------------------------------------------------------------
void
cta
::
common
::
dataStructures
::
DriveState
::
setHost
(
const
std
::
string
&
host
)
{
m_host
=
host
;
m_hostSet
=
true
;
}
//------------------------------------------------------------------------------
// getHost
//------------------------------------------------------------------------------
std
::
string
cta
::
common
::
dataStructures
::
DriveState
::
getHost
()
const
{
if
(
!
allFieldsSet
())
{
throw
cta
::
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" Error: not all fields of the DriveState have been set!"
);
}
return
m_host
;
}
//------------------------------------------------------------------------------
// setSessionId
//------------------------------------------------------------------------------
...
...
common/dataStructures/DriveState.hpp
View file @
551868b6
...
...
@@ -71,6 +71,9 @@ public:
void
setName
(
const
std
::
string
&
name
);
std
::
string
getName
()
const
;
void
setHost
(
const
std
::
string
&
host
);
std
::
string
getHost
()
const
;
void
setSessionId
(
const
uint64_t
sessionId
);
uint64_t
getSessionId
()
const
;
...
...
@@ -115,6 +118,9 @@ private:
std
::
string
m_name
;
bool
m_nameSet
;
std
::
string
m_host
;
bool
m_hostSet
;
uint64_t
m_sessionId
;
bool
m_sessionIdSet
;
...
...
common/dataStructures/DriveStatus.cpp
0 → 100644
View file @
551868b6
/*
* 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/>.
*/
#include
"common/dataStructures/DriveStatus.hpp"
std
::
string
cta
::
common
::
dataStructures
::
toString
(
cta
::
common
::
dataStructures
::
DriveStatus
type
)
{
switch
(
type
)
{
case
cta
::
common
::
dataStructures
::
DriveStatus
::
Down
:
return
"Down"
;
case
cta
::
common
::
dataStructures
::
DriveStatus
::
Up
:
return
"Up"
;
case
cta
::
common
::
dataStructures
::
DriveStatus
::
Starting
:
return
"Starting"
;
case
cta
::
common
::
dataStructures
::
DriveStatus
::
Mounting
:
return
"Mounting"
;
case
cta
::
common
::
dataStructures
::
DriveStatus
::
Transfering
:
return
"Transfering"
;
case
cta
::
common
::
dataStructures
::
DriveStatus
::
Unloading
:
return
"Unloading"
;
case
cta
::
common
::
dataStructures
::
DriveStatus
::
Unmounting
:
return
"Unmounting"
;
case
cta
::
common
::
dataStructures
::
DriveStatus
::
DrainingToDisk
:
return
"DrainingToDisk"
;
case
cta
::
common
::
dataStructures
::
DriveStatus
::
CleaningUp
:
return
"CleaningUp"
;
default:
return
"UNKNOWN"
;
}
}
common/dataStructures/DriveStatus.hpp
View file @
551868b6
...
...
@@ -18,6 +18,8 @@
#pragma once
#include
<string>
namespace
cta
{
namespace
common
{
namespace
dataStructures
{
...
...
@@ -32,6 +34,8 @@ enum DriveStatus {
DrainingToDisk
,
CleaningUp
};
std
::
string
toString
(
DriveStatus
type
);
}
// namespace dataStructures
}
// namespace common
}
// namespace cta
...
...
common/dataStructures/MountType.cpp
0 → 100644
View file @
551868b6
/*
* 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/>.
*/
#include
"common/dataStructures/MountType.hpp"
std
::
string
cta
::
common
::
dataStructures
::
toString
(
cta
::
common
::
dataStructures
::
MountType
type
)
{
switch
(
type
)
{
case
cta
::
common
::
dataStructures
::
MountType
::
archive
:
return
"archive"
;
case
cta
::
common
::
dataStructures
::
MountType
::
retrieve
:
return
"retrieve"
;
case
cta
::
common
::
dataStructures
::
MountType
::
none
:
return
"none"
;
default:
return
"UNKNOWN"
;
}
}
common/dataStructures/MountType.hpp
View file @
551868b6
...
...
@@ -18,6 +18,8 @@
#pragma once
#include
<string>
namespace
cta
{
namespace
common
{
namespace
dataStructures
{
...
...
@@ -26,6 +28,8 @@ enum MountType {
retrieve
,
none
};
std
::
string
toString
(
MountType
type
);
}
// namespace dataStructures
}
// namespace common
}
// namespace cta
common/dataStructures/RepackType.cpp
0 → 100644
View file @
551868b6
/*
* 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/>.
*/
#include
"common/dataStructures/RepackType.hpp"
std
::
string
cta
::
common
::
dataStructures
::
toString
(
cta
::
common
::
dataStructures
::
RepackType
type
)
{
switch
(
type
)
{
case
cta
::
common
::
dataStructures
::
RepackType
::
expandandrepack
:
return
"expandandrepack"
;
case
cta
::
common
::
dataStructures
::
RepackType
::
justexpand
:
return
"justexpand"
;
case
cta
::
common
::
dataStructures
::
RepackType
::
justrepack
:
return
"justrepack"
;
default:
return
"UNKNOWN"
;
}
}
common/dataStructures/RepackType.hpp
View file @
551868b6
...
...
@@ -18,6 +18,8 @@
#pragma once
#include
<string>
namespace
cta
{
namespace
common
{
namespace
dataStructures
{
...
...
@@ -26,6 +28,8 @@ enum RepackType {
justexpand
,
justrepack
};
std
::
string
toString
(
RepackType
type
);
}
// namespace dataStructures
}
// namespace common
}
// namespace cta
common/dataStructures/TestSourceType.cpp
0 → 100644
View file @
551868b6
/*
* 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/>.
*/
#include
"common/dataStructures/TestSourceType.hpp"
std
::
string
cta
::
common
::
dataStructures
::
toString
(
cta
::
common
::
dataStructures
::
TestSourceType
type
)
{
switch
(
type
)
{
case
cta
::
common
::
dataStructures
::
TestSourceType
::
devzero
:
return
"devzero"
;
case
cta
::
common
::
dataStructures
::
TestSourceType
::
devurandom
:
return
"devurandom"
;
default:
return
"UNKNOWN"
;
}
}
common/dataStructures/TestSourceType.hpp
View file @
551868b6
...
...
@@ -18,6 +18,7 @@
#pragma once
#include
<string>
namespace
cta
{
namespace
common
{
namespace
dataStructures
{
...
...
@@ -25,6 +26,8 @@ enum TestSourceType {
devzero
,
devurandom
};
std
::
string
toString
(
TestSourceType
type
);
}
// namespace dataStructures
}
// namespace common
}
// namespace cta
...
...
xroot_plugins/XrdCtaFile.cpp
View file @
551868b6
...
...
@@ -347,6 +347,15 @@ bool XrdProFile::hasOption(const std::vector<std::string> &tokens, const std::st
return
false
;
}
//------------------------------------------------------------------------------
// timeToString
//------------------------------------------------------------------------------
std
::
string
XrdProFile
::
timeToString
(
const
time_t
&
time
)
{
std
::
string
timeString
(
ctime
(
&
time
));
timeString
=
timeString
.
substr
(
0
,
timeString
.
size
()
-
1
);
//remove newline
return
timeString
;
}
//------------------------------------------------------------------------------
// formatResponse
//------------------------------------------------------------------------------
...
...
@@ -380,20 +389,14 @@ std::string XrdProFile::formatResponse(const std::vector<std::vector<std::string
// addLogInfoToResponseRow
//------------------------------------------------------------------------------
void
XrdProFile
::
addLogInfoToResponseRow
(
std
::
vector
<
std
::
string
>
&
responseRow
,
const
cta
::
common
::
dataStructures
::
EntryLog
&
creationLog
,
const
cta
::
common
::
dataStructures
::
EntryLog
&
lastModificationLog
)
{
time_t
creationTime
=
creationLog
.
getTime
();
time_t
lastModificationTime
=
lastModificationLog
.
getTime
();
std
::
string
creationTimeString
(
ctime
(
&
creationTime
));
std
::
string
lastModificationTimeString
(
ctime
(
&
lastModificationTime
));
creationTimeString
=
creationTimeString
.
substr
(
0
,
24
);
//remove the newline
lastModificationTimeString
=
lastModificationTimeString
.
substr
(
0
,
24
);
//remove the newline
responseRow
.
push_back
(
std
::
to_string
((
unsigned
long
long
)
creationLog
.
getUser
().
getUid
()));
responseRow
.
push_back
(
std
::
to_string
((
unsigned
long
long
)
creationLog
.
getUser
().
getGid
()));
responseRow
.
push_back
(
creationLog
.
getHost
());
responseRow
.
push_back
(
creationTimeString
);
responseRow
.
push_back
(
timeToString
(
creationLog
.
getTime
())
);
responseRow
.
push_back
(
std
::
to_string
((
unsigned
long
long
)
lastModificationLog
.
getUser
().
getUid
()));
responseRow
.
push_back
(
std
::
to_string
((
unsigned
long
long
)
lastModificationLog
.
getUser
().
getGid
()));
responseRow
.
push_back
(
lastModificationLog
.
getHost
());
responseRow
.
push_back
(
lastModification
TimeString
);
responseRow
.
push_back
(
timeToString
(
lastModification
Log
.
getTime
())
);
}
//------------------------------------------------------------------------------
...
...
@@ -1271,20 +1274,14 @@ void XrdProFile::xCom_dedication(const std::vector<std::string> &tokens, const c
default:
type_s
=
"readwrite"
;
break
;
}
time_t
fromTime
=
it
->
getFromTimestamp
();
time_t
untilTime
=
it
->
getUntilTimestamp
();
std
::
string
fromTimeString
(
ctime
(
&
fromTime
));
std
::
string
untilTimeString
(
ctime
(
&
untilTime
));
fromTimeString
=
fromTimeString
.
substr
(
0
,
24
);
//remove the newline
untilTimeString
=
untilTimeString
.
substr
(
0
,
24
);
//remove the newline
}
currentRow
.
push_back
(
it
->
getDriveName
());
currentRow
.
push_back
(
type_s
);
currentRow
.
push_back
(
it
->
getVid
());
currentRow
.
push_back
(
it
->
getUserGroup
());
currentRow
.
push_back
(
it
->
getTag
());
currentRow
.
push_back
(
fromT
imeString
);
currentRow
.
push_back
(
untilTimeString
);
currentRow
.
push_back
(
t
ime
To
String
(
it
->
getFromTimestamp
())
);
currentRow
.
push_back
(
timeToString
(
it
->
getUntilTimestamp
())
);
addLogInfoToResponseRow
(
currentRow
,
it
->
getCreationLog
(),
it
->
getLastModificationLog
());
currentRow
.
push_back
(
it
->
getComment
());
responseTable
.
push_back
(
currentRow
);
...
...
@@ -1375,9 +1372,6 @@ void XrdProFile::xCom_repack(const std::vector<std::string> &tokens, const cta::
type_s
=
"justrepack"
;
break
;
}
time_t
creationTime
=
it
->
getCreationLog
().
getTime
();
std
::
string
creationTimeString
(
ctime
(
&
creationTime
));
creationTimeString
=
creationTimeString
.
substr
(
0
,
24
);
//remove the newline
std
::
vector
<
std
::
string
>
currentRow
;
currentRow
.
push_back
(
it
->
getVid
());
currentRow
.
push_back
(
std
::
to_string
((
unsigned
long
long
)
it
->
getTotalFiles
()));
...
...
@@ -1392,7 +1386,7 @@ void XrdProFile::xCom_repack(const std::vector<std::string> &tokens, const cta::
currentRow
.
push_back
(
std
::
to_string
((
unsigned
long
long
)
it
->
getCreationLog
().
getUser
().
getUid
()));
currentRow
.
push_back
(
std
::
to_string
((
unsigned
long
long
)
it
->
getCreationLog
().
getUser
().
getGid
()));
currentRow
.
push_back
(
it
->
getCreationLog
().
getHost
());
currentRow
.
push_back
(
creationTimeString
);
currentRow
.
push_back
(
timeToString
(
it
->
getCreationLog
().
getTime
())
);
responseTable
.
push_back
(
currentRow
);
}
m_data
=
formatResponse
(
responseTable
);
...
...
@@ -1482,9 +1476,6 @@ void XrdProFile::xCom_verify(const std::vector<std::string> &tokens, const cta::
std
::
vector
<
std
::
string
>
header
=
{
"vid"
,
"files"
,
"size"
,
"tag"
,
"to verify"
,
"failed"
,
"verified"
,
"status"
,
"uid"
,
"gid"
,
"host"
,
"time"
};
responseTable
.
push_back
(
header
);
for
(
auto
it
=
list
.
cbegin
();
it
!=
list
.
cend
();
it
++
)
{
time_t
creationTime
=
it
->
getCreationLog
().
getTime
();
std
::
string
creationTimeString
(
ctime
(
&
creationTime
));
creationTimeString
=
creationTimeString
.
substr
(
0
,
24
);
//remove the newline
std
::
vector
<
std
::
string
>
currentRow
;
currentRow
.
push_back
(
it
->
getVid
());
currentRow
.
push_back
(
std
::
to_string
((
unsigned
long
long
)
it
->
getTotalFiles
()));
...
...
@@ -1496,8 +1487,8 @@ void XrdProFile::xCom_verify(const std::vector<std::string> &tokens, const cta::
currentRow
.
push_back
(
it
->
getVerifyStatus
());
currentRow
.
push_back
(
std
::
to_string
((
unsigned
long
long
)
it
->
getCreationLog
().
getUser
().
getUid
()));
currentRow
.
push_back
(
std
::
to_string
((
unsigned
long
long
)
it
->
getCreationLog
().
getUser
().
getGid
()));
currentRow
.
push_back
(
it
->
getCreationLog
().
getHost
());
currentRow
.
push_back
(
creationTimeString
);
currentRow
.
push_back
(
it
->
getCreationLog
().
getHost
());
currentRow
.
push_back
(
timeToString
(
it
->
getCreationLog
().
getTime
())
);
responseTable
.
push_back
(
currentRow
);
}
m_data
=
formatResponse
(
responseTable
);
...
...
@@ -1875,6 +1866,30 @@ void XrdProFile::xCom_listpendingretrieves(const std::vector<std::string> &token
void
XrdProFile
::
xCom_listdrivestates
(
const
std
::
vector
<
std
::
string
>
&
tokens
,
const
cta
::
common
::
dataStructures
::
SecurityIdentity
&
requester
)
{
std
::
stringstream
help
;
help
<<
tokens
[
0
]
<<
" lds/listdrivestates"
<<
std
::
endl
;
std
::
list
<
cta
::
common
::
dataStructures
::
DriveState
>
result
=
m_scheduler
->
getDriveStates
(
requester
);
if
(
result
.
size
()
>
0
)
{
std
::
vector
<
std
::
vector
<
std
::
string
>>
responseTable
;
std
::
vector
<
std
::
string
>
header
=
{
"vid"
,
"id"
,
"copy no."
,
"fseq"
,
"block id"
,
"size"
,
"user"
,
"group"
,
"instance"
,
"path"
,
"diskpool"
,
"diskpool throughput"
};
responseTable
.
push_back
(
header
);
for
(
auto
it
=
result
.
cbegin
();
it
!=
result
.
cend
();
it
++
)
{
std
::
vector
<
std
::
string
>
currentRow
;
currentRow
.
push_back
(
it
->
getLogicalLibrary
());
currentRow
.
push_back
(
it
->
getHost
());
currentRow
.
push_back
(
it
->
getName
());
currentRow
.
push_back
(
cta
::
common
::
dataStructures
::
toString
(
it
->
getStatus
()));
currentRow
.
push_back
(
std
::
to_string
((
unsigned
long
long
)(
time
(
NULL
)
-
it
->
getCurrentStateStartTime
())));
currentRow
.
push_back
(
cta
::
common
::
dataStructures
::
toString
(
it
->
getMountType
()));
currentRow
.
push_back
(
it
->
getCurrentVid
());
currentRow
.
push_back
(
it
->
getCurrentTapePool
());
currentRow
.
push_back
(
std
::
to_string
((
unsigned
long
long
)
it
->
getSessionId
()));
currentRow
.
push_back
(
std
::
to_string
((
unsigned
long
long
)(
time
(
NULL
)
-
it
->
getSessionStartTime
())));
currentRow
.
push_back
(
std
::
to_string
((
unsigned
long
long
)
it
->
getFilesTransferedInSession
()));
currentRow
.
push_back
(
std
::
to_string
((
unsigned
long
long
)
it
->
getBytesTransferedInSession
()));
currentRow
.
push_back
(
std
::
to_string
((
long
double
)
it
->
getLatestBandwidth
()));
responseTable
.
push_back
(
currentRow
);
}
m_data
=
formatResponse
(
responseTable
);
}
}
//------------------------------------------------------------------------------
...
...
xroot_plugins/XrdCtaFile.hpp
View file @
551868b6
...
...
@@ -153,6 +153,14 @@ protected:
*/
std
::
string
formatResponse
(
const
std
::
vector
<
std
::
vector
<
std
::
string
>>
&
responseTable
);
/**
* Returns a string representation of the time
*
* @param time The input time
* @return a string representation of the time
*/
std
::
string
timeToString
(
const
time_t
&
time
);
/**
* Adds the creation log and the last modification log to the current response row
*
...
...
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