Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
scdaq
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
scouting-demonstrator
scdaq
Commits
956c3bee
Commit
956c3bee
authored
1 year ago
by
Giovanna Lazzari Miotto
Browse files
Options
Downloads
Patches
Plain Diff
fix: Rename origin path
parent
7443e7b3
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/OutputByOrbit.cc
+5
-2
5 additions, 2 deletions
src/OutputByOrbit.cc
src/OutputFile.h
+11
-3
11 additions, 3 deletions
src/OutputFile.h
src/OutputFileHandler.cc
+17
-7
17 additions, 7 deletions
src/OutputFileHandler.cc
src/OutputFileHandler.h
+1
-1
1 addition, 1 deletion
src/OutputFileHandler.h
with
34 additions
and
13 deletions
src/OutputByOrbit.cc
+
5
−
2
View file @
956c3bee
...
@@ -28,7 +28,8 @@ OutputByOrbitStream::OutputByOrbitStream(ctrl &control, const ConfigView &conf_v
...
@@ -28,7 +28,8 @@ OutputByOrbitStream::OutputByOrbitStream(ctrl &control, const ConfigView &conf_v
void
OutputByOrbitStream
::
OutputFixedOrbits
(
Slice
&
out
)
{
void
OutputByOrbitStream
::
OutputFixedOrbits
(
Slice
&
out
)
{
uint32_t
orbitN
=
out
.
get_firstOrbitN
();
uint32_t
orbitN
=
out
.
get_firstOrbitN
();
auto
index
=
uint32_t
(
orbitN
/
conf_
.
num_orbits_per_file_
);
auto
index
=
uint32_t
(
orbitN
/
conf_
.
num_orbits_per_file_
);
size_t
n
=
0
;
// LOG(FATAL) << "This is orbit index=" << index << ", N=" << orbitN << " out of "
// << conf_.num_orbits_per_file_;
if
((
out
.
get_counts
()
!=
0
)
||
conf_
.
support_cmssw_headers_
)
{
if
((
out
.
get_counts
()
!=
0
)
||
conf_
.
support_cmssw_headers_
)
{
if
(
control_
.
running
.
load
(
std
::
memory_order_acquire
)
||
if
(
control_
.
running
.
load
(
std
::
memory_order_acquire
)
||
...
@@ -36,8 +37,10 @@ void OutputByOrbitStream::OutputFixedOrbits(Slice &out) {
...
@@ -36,8 +37,10 @@ void OutputByOrbitStream::OutputFixedOrbits(Slice &out) {
if
(
!
out
.
isInitialized
())
{
if
(
!
out
.
isInitialized
())
{
return
;
return
;
}
}
// LOG(FATAL) << "Getting file handle and writing " << out.size() << " bytes";
n
=
output_file_handler_
.
getFile
(
control_
.
run_number
,
index
).
Write
(
out
.
begin
(),
out
.
size
());
auto
file
=
output_file_handler_
.
getFile
(
control_
.
run_number
,
index
);
size_t
n
=
file
->
Write
(
out
.
begin
(),
out
.
size
());
// n = fwrite(out.begin(), 1, out.size(),
// n = fwrite(out.begin(), 1, out.size(),
// output_file_handler_.getFile(control_.run_number, index).getFilePtr());
// output_file_handler_.getFile(control_.run_number, index).getFilePtr());
output_file_handler_
.
upFileSize
(
n
);
output_file_handler_
.
upFileSize
(
n
);
...
...
This diff is collapsed.
Click to expand it.
src/OutputFile.h
+
11
−
3
View file @
956c3bee
...
@@ -43,7 +43,11 @@ class OutputFile {
...
@@ -43,7 +43,11 @@ class OutputFile {
lumisection_
(
num_lumisection
),
lumisection_
(
num_lumisection
),
index_
(
file_index
)
{
index_
(
file_index
)
{
try
{
try
{
file_
.
open
(
filepath_
,
std
::
fstream
::
in
|
std
::
fstream
::
out
|
std
::
fstream
::
binary
);
LOG
(
FATAL
)
<<
"Attempting open file: '"
<<
filepath_
<<
"'"
;
file_
.
open
(
filepath_
,
std
::
ios_base
::
out
|
std
::
ios_base
::
binary
);
if
(
!
file_
.
is_open
())
{
LOG
(
FATAL
)
<<
"Could not open file: '"
<<
filepath_
<<
"'"
;
}
}
catch
(
std
::
exception
&
e
)
{
}
catch
(
std
::
exception
&
e
)
{
LOG
(
FATAL
)
<<
"Could not open file: '"
<<
filepath_
<<
"', exception: "
<<
e
.
what
();
LOG
(
FATAL
)
<<
"Could not open file: '"
<<
filepath_
<<
"', exception: "
<<
e
.
what
();
}
}
...
@@ -92,17 +96,21 @@ class OutputFile {
...
@@ -92,17 +96,21 @@ class OutputFile {
bool
exists
()
{
return
file_
.
is_open
();
}
bool
exists
()
{
return
file_
.
is_open
();
}
std
::
string
GetFullPath
()
const
{
return
f
s
::
path
(
rundir_
)
/
filepath_
/
fileName
_
;
}
std
::
string
GetFullPath
()
const
{
return
f
ilepath
_
;
}
void
Rename
(
const
std
::
string
&
new_path
)
const
{
void
Rename
(
const
std
::
string
&
new_path
)
{
fs
::
path
from
=
GetFullPath
();
fs
::
path
from
=
GetFullPath
();
fs
::
path
to
=
new_path
;
fs
::
path
to
=
new_path
;
LOG
(
FATAL
)
<<
"Renaming from '"
<<
from
<<
"' to '"
<<
to
<<
"' now."
;
try
{
try
{
fs
::
rename
(
from
,
to
);
fs
::
rename
(
from
,
to
);
}
catch
(
fs
::
filesystem_error
&
err
)
{
}
catch
(
fs
::
filesystem_error
&
err
)
{
LOG
(
FATAL
)
<<
"Error renaming file: "
<<
err
.
what
();
LOG
(
FATAL
)
<<
"Error renaming file: "
<<
err
.
what
();
}
}
filepath_
=
new_path
;
}
}
size_t
Write
(
char
*
buf
,
size_t
size
)
{
size_t
Write
(
char
*
buf
,
size_t
size
)
{
...
...
This diff is collapsed.
Click to expand it.
src/OutputFileHandler.cc
+
17
−
7
View file @
956c3bee
...
@@ -19,6 +19,11 @@ tbb::concurrent_bounded_queue<std::shared_ptr<OutputFile>> OutputFileHandler::fi
...
@@ -19,6 +19,11 @@ tbb::concurrent_bounded_queue<std::shared_ptr<OutputFile>> OutputFileHandler::fi
std
::
atomic
<
bool
>
OutputFileHandler
::
file_handler_running_
{
true
};
std
::
atomic
<
bool
>
OutputFileHandler
::
file_handler_running_
{
true
};
void
OutputFileHandler
::
enqueue_current_file_for_close_and_move_maybe
()
{
void
OutputFileHandler
::
enqueue_current_file_for_close_and_move_maybe
()
{
LOG
(
FATAL
)
<<
"____ Enqueue called."
;
LOG
(
FATAL
)
<<
"____ Is outputFile? "
<<
(
outputFile_
!=
nullptr
);
if
(
outputFile_
)
LOG
(
FATAL
)
<<
"____ Does outputFile exist()? "
<<
(
outputFile_
->
exists
());
if
(
outputFile_
&&
outputFile_
->
exists
())
{
if
(
outputFile_
&&
outputFile_
->
exists
())
{
LOG
(
TRACE
)
<<
"queueing file: "
<<
outputFile_
->
getFileName
()
<<
" for closing, queue size now "
LOG
(
TRACE
)
<<
"queueing file: "
<<
outputFile_
->
getFileName
()
<<
" for closing, queue size now "
<<
files_to_close_
.
size
();
<<
files_to_close_
.
size
();
...
@@ -46,7 +51,7 @@ void OutputFileHandler::enqueue_current_file_for_close_and_move_maybe() {
...
@@ -46,7 +51,7 @@ void OutputFileHandler::enqueue_current_file_for_close_and_move_maybe() {
}
}
}
}
OutputFile
&
OutputFileHandler
::
getFile
(
uint32_t
run
,
uint32_t
index
)
{
std
::
shared_ptr
<
OutputFile
>
&
OutputFileHandler
::
getFile
(
uint32_t
run
,
uint32_t
index
)
{
bool
is_new_run
=
(
current_run_number_
!=
static_cast
<
int
>
(
run
));
bool
is_new_run
=
(
current_run_number_
!=
static_cast
<
int
>
(
run
));
bool
is_new_index
=
(
current_index_
!=
static_cast
<
int
>
(
index
));
bool
is_new_index
=
(
current_index_
!=
static_cast
<
int
>
(
index
));
...
@@ -59,10 +64,10 @@ OutputFile& OutputFileHandler::getFile(uint32_t run, uint32_t index) {
...
@@ -59,10 +64,10 @@ OutputFile& OutputFileHandler::getFile(uint32_t run, uint32_t index) {
enqueue_current_file_for_close_and_move_maybe
();
enqueue_current_file_for_close_and_move_maybe
();
if
(
is_new_run
)
{
if
(
is_new_run
)
{
run_NOrbits_
=
0
;
run_NOrbits_
=
0
;
LOG
(
TRACE
)
<<
"Previous run: "
<<
current_run_number_
<<
" | New run: "
<<
run
;
LOG
(
FATAL
)
<<
"Previous run: "
<<
current_run_number_
<<
" | New run: "
<<
run
;
}
}
if
(
is_new_index
)
{
if
(
is_new_index
)
{
LOG
(
TRACE
)
<<
"Previous index: "
<<
current_index_
<<
" | New index: "
<<
index
;
LOG
(
FATAL
)
<<
"Previous index: "
<<
current_index_
<<
" | New index: "
<<
index
;
}
}
current_index_
=
static_cast
<
int
>
(
index
);
current_index_
=
static_cast
<
int
>
(
index
);
...
@@ -74,7 +79,7 @@ OutputFile& OutputFileHandler::getFile(uint32_t run, uint32_t index) {
...
@@ -74,7 +79,7 @@ OutputFile& OutputFileHandler::getFile(uint32_t run, uint32_t index) {
working_files_base_path_
=
path_ss
.
str
();
working_files_base_path_
=
path_ss
.
str
();
open_new_file
();
open_new_file
();
}
}
return
std
::
ref
(
*
outputFile_
)
;
return
outputFile_
;
}
}
FRDFileHeader_v2
OutputFileHandler
::
createFileHeader
(
uint32_t
ls
)
{
// file header for CMSSW input
FRDFileHeader_v2
OutputFileHandler
::
createFileHeader
(
uint32_t
ls
)
{
// file header for CMSSW input
...
@@ -88,6 +93,7 @@ FRDFileHeader_v2 OutputFileHandler::createFileHeader(uint32_t ls) { // file hea
...
@@ -88,6 +93,7 @@ FRDFileHeader_v2 OutputFileHandler::createFileHeader(uint32_t ls) { // file hea
}
}
void
OutputFileHandler
::
create_output_directory_maybe
(
std
::
string
&
output_directory
)
{
void
OutputFileHandler
::
create_output_directory_maybe
(
std
::
string
&
output_directory
)
{
LOG
(
FATAL
)
<<
"Called Create_output_dir"
;
struct
stat
sb
;
struct
stat
sb
;
LOG
(
TRACE
)
<<
"checking if working directory "
<<
output_directory
<<
" exists "
;
LOG
(
TRACE
)
<<
"checking if working directory "
<<
output_directory
<<
" exists "
;
/* check if path exists and is a directory */
/* check if path exists and is a directory */
...
@@ -101,6 +107,8 @@ void OutputFileHandler::create_output_directory_maybe(std::string& output_direct
...
@@ -101,6 +107,8 @@ void OutputFileHandler::create_output_directory_maybe(std::string& output_direct
throw
std
::
runtime_error
(
err
);
throw
std
::
runtime_error
(
err
);
}
}
LOG
(
FATAL
)
<<
"Attempt create "
<<
output_directory
<<
" directory."
;
if
(
!
tools
::
filesystem
::
create_directories
(
output_directory
))
{
if
(
!
tools
::
filesystem
::
create_directories
(
output_directory
))
{
std
::
string
err
=
std
::
string
err
=
tools
::
strerror
(
"ERROR when creating the output directory '"
+
output_directory
+
"'"
);
tools
::
strerror
(
"ERROR when creating the output directory '"
+
output_directory
+
"'"
);
...
@@ -112,11 +120,12 @@ void OutputFileHandler::create_output_directory_maybe(std::string& output_direct
...
@@ -112,11 +120,12 @@ void OutputFileHandler::create_output_directory_maybe(std::string& output_direct
void
OutputFileHandler
::
open_new_file
()
{
void
OutputFileHandler
::
open_new_file
()
{
// Create a new file
// Create a new file
LOG
(
FATAL
)
<<
"Called Open_new_file"
;
uint32_t
ls
=
1
+
static_cast
<
uint32_t
>
(
current_index_
/
(
max_index_per_ls_
+
1
));
uint32_t
ls
=
1
+
static_cast
<
uint32_t
>
(
current_index_
/
(
max_index_per_ls_
+
1
));
create_output_directory_maybe
(
working_files_base_path_
);
create_output_directory_maybe
(
working_files_base_path_
);
std
::
string
filename
=
format_filename
(
current_run_number_
,
current_index_
,
ls
);
std
::
string
filename
=
format_filename
(
current_run_number_
,
current_index_
,
ls
);
std
::
string
full_filename
=
working_files_base_path_
+
"/"
+
filename
;
std
::
string
full_filename
=
working_files_base_path_
+
"/"
+
filename
;
LOG
(
TRACE
)
<<
"opening file with index "
<<
current_index_
<<
", in lumisection "
<<
ls
;
LOG
(
FATAL
)
<<
"opening file with index "
<<
current_index_
<<
", in lumisection "
<<
ls
;
// outputFile_ = std::make_shared<OutputFile>(fopen(full_filename.c_str(), "wbx"), filename,
// outputFile_ = std::make_shared<OutputFile>(fopen(full_filename.c_str(), "wbx"), filename,
// createFileHeader(ls), ls,
// createFileHeader(ls), ls,
// current_index_ % (max_index_per_ls_ + 1),
// current_index_ % (max_index_per_ls_ + 1),
...
@@ -156,7 +165,7 @@ std::string OutputFileHandler::format_filename(uint32_t run_number, uint32_t ind
...
@@ -156,7 +165,7 @@ std::string OutputFileHandler::format_filename(uint32_t run_number, uint32_t ind
void
OutputFileHandler
::
close_and_rename
::
operator
()()
const
{
void
OutputFileHandler
::
close_and_rename
::
operator
()()
const
{
std
::
shared_ptr
<
OutputFile
>
outputFile
;
std
::
shared_ptr
<
OutputFile
>
outputFile
;
while
(
file_handler_running_
&&
(
files_to_close_
.
size
()
>
0
))
{
while
(
file_handler_running_
||
(
files_to_close_
.
size
()
>
0
))
{
LOG
(
TRACE
)
<<
"try pop now. queue size now "
<<
files_to_close_
.
size
();
LOG
(
TRACE
)
<<
"try pop now. queue size now "
<<
files_to_close_
.
size
();
try
{
try
{
files_to_close_
.
pop
(
outputFile
);
files_to_close_
.
pop
(
outputFile
);
...
@@ -171,7 +180,8 @@ void OutputFileHandler::close_and_rename::operator()() const {
...
@@ -171,7 +180,8 @@ void OutputFileHandler::close_and_rename::operator()() const {
LOG
(
ERROR
)
<<
tools
::
strerror
(
"File close failed"
);
LOG
(
ERROR
)
<<
tools
::
strerror
(
"File close failed"
);
}
}
outputFile
->
Rename
(
outputFile
->
getRunDir
()
+
"/"
+
outputFile
->
getFileName
());
std
::
string
permanent_path
(
outputFile
->
getRunDir
()
+
"/"
+
outputFile
->
getFileName
());
outputFile
->
Rename
(
permanent_path
);
// std::string from = outputFile->getRunDir() + "/" + working_dir_ + "/" +
// std::string from = outputFile->getRunDir() + "/" + working_dir_ + "/" +
// outputFile.getFileName(); std::string to = outputFile->getRunDir() + "/" +
// outputFile.getFileName(); std::string to = outputFile->getRunDir() + "/" +
// outputFile.getFileName(); if (rename(from.c_str(), to.c_str()) != 0) {
// outputFile.getFileName(); if (rename(from.c_str(), to.c_str()) != 0) {
...
...
This diff is collapsed.
Click to expand it.
src/OutputFileHandler.h
+
1
−
1
View file @
956c3bee
...
@@ -53,7 +53,7 @@ class OutputFileHandler {
...
@@ -53,7 +53,7 @@ class OutputFileHandler {
void
enqueue_current_file_for_close_and_move_maybe
();
void
enqueue_current_file_for_close_and_move_maybe
();
OutputFile
&
getFile
(
uint32_t
run
,
uint32_t
index
);
std
::
shared_ptr
<
OutputFile
>
&
getFile
(
uint32_t
run
,
uint32_t
index
);
bool
hasFile
()
{
return
outputFile_
->
exists
();
}
bool
hasFile
()
{
return
outputFile_
->
exists
();
}
...
...
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