Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
ee6c207e
Commit
ee6c207e
authored
4 years ago
by
Michael Davis
Browse files
Options
Downloads
Patches
Plain Diff
[tools] Finishes cta-send-event
parent
f8c9f915
Branches
314-remove-grpc-client-code-from-cta-frontend-2
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmdline/CtaSendEvent.cpp
+26
-17
26 additions, 17 deletions
cmdline/CtaSendEvent.cpp
cmdline/cta-inject-af.sh
+5
-1
5 additions, 1 deletion
cmdline/cta-inject-af.sh
with
31 additions
and
18 deletions
cmdline/CtaSendEvent.cpp
+
26
−
17
View file @
ee6c207e
...
...
@@ -46,7 +46,7 @@ void RequestCallback<cta::xrd::Alert>::operator()(const cta::xrd::Alert &alert)
typedef
std
::
map
<
std
::
string
,
std
::
string
>
AttrMap
;
// Usage exception
const
std
::
runtime_error
Usage
(
"Usage: eos --json fileinfo /eos/path | cta-send-event CLOSEW|PREPARE|ABORT_PREPARE"
);
const
std
::
runtime_error
Usage
(
"Usage: eos --json fileinfo /eos/path | cta-send-event
[eos_hostname:port]
CLOSEW|PREPARE|ABORT_PREPARE"
);
// remove leading spaces and quotes
void
ltrim
(
std
::
string
&
s
)
{
...
...
@@ -106,12 +106,16 @@ void parseFileInfo(std::istream &in, AttrMap &attr, AttrMap &xattr)
*/
void
fillNotification
(
cta
::
eos
::
Notification
&
notification
,
int
argc
,
const
char
*
const
*
const
argv
)
{
// First argument must be a valid command specifying which workflow action to execute
std
::
string
eos_endpoint
=
"localhost:1095"
;
if
(
argc
!=
2
)
throw
Usage
;
const
std
::
string
wf_command
(
argv
[
1
]);
if
(
argc
==
3
)
{
eos_endpoint
=
argv
[
1
];
}
else
if
(
argc
!=
2
)
{
throw
Usage
;
}
// Set the event type
const
std
::
string
wf_command
(
argv
[
argc
-
1
]);
if
(
wf_command
==
"CLOSEW"
)
{
notification
.
mutable_wf
()
->
set_event
(
cta
::
eos
::
Workflow
::
CLOSEW
);
...
...
@@ -124,23 +128,28 @@ void fillNotification(cta::eos::Notification ¬ification, int argc, const char
{
notification
.
mutable_wf
()
->
set_event
(
cta
::
eos
::
Workflow
::
ABORT_PREPARE
);
}
#if 0
else if(wf_command == "DELETE")
{
notification.mutable_wf()->set_event(cta::eos::Workflow::DELETE);
else
{
throw
Usage
;
}
#endif
else
throw
Usage
;
// Parse the JSON input on stdin
AttrMap
attr
;
AttrMap
xattrs
;
parseFileInfo
(
std
::
cin
,
attr
,
xattrs
);
std
::
string
accessUrl
=
"root://"
+
eos_endpoint
+
"/"
+
attr
[
"path"
]
+
"?eos.lfn=fxid:"
+
attr
[
"fxid"
];
std
::
string
reportUrl
=
"eosQuery://"
+
eos_endpoint
+
"//eos/wfe/passwd?mgm.pcmd=event&mgm.fid="
+
attr
[
"fxid"
]
+
"&mgm.logid=cta&mgm.event=sync::archived&mgm.workflow=default&mgm.path=/dummy_path&mgm.ruid=0&mgm.rgid=0&cta_archive_file_id="
+
xattrs
[
"sys.archive.file_id"
];
std
::
string
errorReportUrl
=
"eosQuery://"
+
eos_endpoint
+
"//eos/wfe/passwd?mgm.pcmd=event&mgm.fid="
+
attr
[
"fxid"
]
+
"&mgm.logid=cta&mgm.event=sync::archive_failed&mgm.workflow=default&mgm.path=/dummy_path&mgm.ruid=0&mgm.rgid=0&cta_archive_file_id="
+
xattrs
[
"sys.archive.file_id"
]
+
"&mgm.errmsg="
;
std
::
string
destUrl
=
"TO DO"
;
// TO DO: required only for retrieve workflow
// WF
notification
.
mutable_wf
()
->
mutable_instance
()
->
set_name
(
attr
[
"geotag"
]);
notification
.
mutable_wf
()
->
mutable_instance
()
->
set_url
(
"root://ctadevmichael.cern.ch:1094//eos/test/motd.1?eos.lfn=fxid:100000010"
);
notification
.
mutable_wf
()
->
set_requester_instance
(
"
myhost:fs
t"
);
notification
.
mutable_wf
()
->
mutable_instance
()
->
set_url
(
accessUrl
);
notification
.
mutable_wf
()
->
set_requester_instance
(
"
cta-send-even
t"
);
// CLI
notification
.
mutable_cli
()
->
mutable_user
()
->
set_username
(
"mdavis"
);
...
...
@@ -148,11 +157,11 @@ void fillNotification(cta::eos::Notification ¬ification, int argc, const char
// Transport
if
(
wf_command
==
"CLOSEW"
)
{
notification
.
mutable_transport
()
->
set_report_url
(
"eosQuery://ctadevmichael.cern.ch:1094//eos/wfe/passwd?mgm.pcmd=event&mgm.fid=100000010&mgm.logid=cta&mgm.event=sync::archived&mgm.workflow=default&mgm.path=/dummy_path&mgm.ruid=0&mgm.rgid=0&cta_archive_file_id=4294967296"
);
notification
.
mutable_transport
()
->
set_report_url
(
reportUrl
);
}
else
if
(
wf_command
==
"PREPARE"
)
{
notification
.
mutable_transport
()
->
set_dst_url
(
"not set"
);
// for retrieve WF
notification
.
mutable_transport
()
->
set_dst_url
(
destUrl
);
}
notification
.
mutable_transport
()
->
set_error_report_url
(
"eosQuery://ctadevmichael.cern.ch:1094//eos/wfe/passwd?mgm.pcmd=event&mgm.fid=100000010&mgm.logid=cta&mgm.event=sync::archive_failed&mgm.workflow=default&mgm.path=/dummy_path&mgm.ruid=0&mgm.rgid=0&cta_archive_file_id=4294967296&mgm.errmsg="
);
notification
.
mutable_transport
()
->
set_error_report_url
(
errorReportUrl
);
// File
notification
.
mutable_file
()
->
set_fid
(
std
::
strtoul
(
attr
[
"id"
].
c_str
(),
nullptr
,
0
));
...
...
@@ -163,7 +172,7 @@ void fillNotification(cta::eos::Notification ¬ification, int argc, const char
// In principle it's possible to set the full checksum blob with multiple checksums of different types.
// For now we support only one checksum which is always of type ADLER32.
auto
cs
=
notification
.
mutable_file
()
->
mutable_csb
()
->
add_cs
();
if
(
attr
[
"checksumtype"
]
==
"
ADLER32
"
)
{
if
(
attr
[
"checksumtype"
]
==
"
adler
"
)
{
cs
->
set_type
(
cta
::
common
::
ChecksumBlob
::
Checksum
::
ADLER32
);
}
cs
->
set_value
(
cta
::
checksum
::
ChecksumBlob
::
HexToByteArray
(
attr
[
"checksumvalue"
]));
...
...
This diff is collapsed.
Click to expand it.
cmdline/cta-inject-af.sh
+
5
−
1
View file @
ee6c207e
...
...
@@ -2,6 +2,9 @@
#
# Send a CLOSEW event to the CTA Frontend in order to retry a failed archive request
CTA_SEND_EVENT
=
/usr/bin/cta-send-event
EOS_HOST
=
localhost:1094
error
()
{
echo
"
$*
"
>
&2
...
...
@@ -15,8 +18,9 @@ get_eos_md()
}
[
$#
-gt
0
]
||
error
"Usage:
$(
basename
$0
)
/eos/path [/eos/path...]"
[
-x
${
CTA_SEND_EVENT
}
]
||
error
"Cannot execute
${
CTA_SEND_EVENT
}
"
for
FILENAME
in
$*
do
get_eos_md
$FILENAME
|
~/
CTA_
build/cmdline/cta-send-event
CLOSEW
get_eos_md
$FILENAME
|
${
CTA_
SEND_EVENT
}
${
EOS_HOST
}
CLOSEW
done
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment