Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Redis Receiver
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
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
BIAS
Receivers
Redis Receiver
Commits
0cea3445
Commit
0cea3445
authored
1 year ago
by
Valerio Pastore
Browse files
Options
Downloads
Patches
Plain Diff
update for log
parent
c8731f14
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
deps/Base-DAQ
+1
-1
1 addition, 1 deletion
deps/Base-DAQ
src/Redis_Receiver.cpp
+34
-13
34 additions, 13 deletions
src/Redis_Receiver.cpp
with
35 additions
and
14 deletions
Base-DAQ
@
f8149d28
Compare
ce99aaa2
...
f8149d28
Subproject commit
ce99aaa20706cca85200a375cee63d7414cebb74
Subproject commit
f8149d2831d10e7f467d96ee11335f01bfad81b5
This diff is collapsed.
Click to expand it.
src/Redis_Receiver.cpp
+
34
−
13
View file @
0cea3445
...
...
@@ -11,6 +11,8 @@
#include
<iostream>
// std::cout, std::endl
#include
<thread>
// std::this_thread::sleep_for
#include
<chrono>
// std::chrono::seconds
#include
<ctime>
#include
<iomanip>
using
namespace
inaf
::
oasbo
::
ConnectionProtocols
;
...
...
@@ -34,11 +36,16 @@ int RedisReceiver::connectToClient() {
context
=
redisConnect
(
ip
.
c_str
(),
port
);
if
(
context
==
nullptr
||
context
->
err
)
{
if
(
context
)
{
std
::
cout
<<
"Redis Receiver Error: "
<<
context
->
errstr
<<
std
::
endl
;
time_t
now
=
time
(
nullptr
);
std
::
cerr
<<
"["
<<
std
::
put_time
(
localtime
(
&
now
),
"%Y-%m-%d %H:%M:%S"
)
<<
"]
\t
[Redis Receiver]
\t
"
<<
context
->
errstr
<<
std
::
endl
;
}
else
{
std
::
cout
<<
"Redis Receiver Error: Can't allocate Redis context"
<<
std
::
endl
;
time_t
now
=
time
(
nullptr
);
std
::
cerr
<<
"["
<<
std
::
put_time
(
localtime
(
&
now
),
"%Y-%m-%d %H:%M:%S"
)
<<
"]
\t
[Redis Receiver]
\t
"
<<
" Can't allocate Redis context"
<<
std
::
endl
;
}
return
-
1
;
}
...
...
@@ -60,10 +67,15 @@ bool RedisReceiver::isConnectedToClient() const {
int
RedisReceiver
::
receiveFromClient
(
PacketLib
::
BasePacket
&
pack
)
{
if
(
!
isConnectedToClient
())
{
if
(
context
)
{
std
::
cerr
<<
"Redis Receiver Error: "
<<
context
->
errstr
<<
std
::
endl
;
time_t
now
=
time
(
nullptr
);
std
::
cerr
<<
"["
<<
std
::
put_time
(
localtime
(
&
now
),
"%Y-%m-%d %H:%M:%S"
)
<<
"]
\t
[Redis Receiver]
\t
"
<<
context
->
errstr
<<
std
::
endl
;
}
else
{
std
::
cerr
<<
"Redis Receiver Error: Can't allocate Redis context"
time_t
now
=
time
(
nullptr
);
std
::
cerr
<<
"["
<<
std
::
put_time
(
localtime
(
&
now
),
"%Y-%m-%d %H:%M:%S"
)
<<
"]
\t
[Redis Receiver]
\t
"
<<
"Can't allocate Redis context"
<<
std
::
endl
;
}
return
-
1
;
...
...
@@ -94,9 +106,12 @@ int RedisReceiver::receiveFromClient(PacketLib::BasePacket &pack) {
+
pack
.
getTailSize
();
if
(
!
pack
.
isRecognizedHeader
()
||
size
<
(
tot_packet_size
))
{
std
::
cerr
<<
"Redis receiver error: packet not recognized: "
<<
pack
[
"type"
].
value
()
<<
" "
<<
pack
[
"subtype"
].
value
()
<<
" "
<<
pack
.
getPayloadSize
()
<<
std
::
endl
;
time_t
now
=
time
(
nullptr
);
std
::
cerr
<<
"["
<<
std
::
put_time
(
localtime
(
&
now
),
"%Y-%m-%d %H:%M:%S"
)
<<
"]
\t
[Redis Receiver]
\t
"
<<
"packet not recognized: "
<<
pack
[
"type"
].
value
()
<<
" "
<<
pack
[
"subtype"
].
value
()
<<
" "
<<
pack
.
getPayloadSize
()
<<
std
::
endl
;
freeReplyObject
(
r
);
resetPacket
(
pack
,
header_size
);
return
-
1
;
...
...
@@ -124,7 +139,9 @@ void RedisReceiver::setHost(std::string host) {
setPort
(
port
);
setKey
(
key
);
}
else
{
std
::
cerr
<<
"Redis receiver error:
\"
"
<<
host
time_t
now
=
time
(
nullptr
);
std
::
cerr
<<
"["
<<
std
::
put_time
(
localtime
(
&
now
),
"%Y-%m-%d %H:%M:%S"
)
<<
"]
\t
[Redis Receiver]
\t
"
<<
host
<<
"
\"
does not match the format: "
<<
"
\"
xxx.xxx.xxx.xxx:xxxx/xxxx
\"
"
<<
std
::
endl
;
}
...
...
@@ -137,7 +154,9 @@ void RedisReceiver::setIp(std::string ip) {
this
->
ip
=
ip
;
this
->
host
=
ip
+
":"
+
std
::
to_string
(
port
)
+
"/"
+
key
;
}
else
{
std
::
cerr
<<
"Redis Receiver Error: invalid IP address: "
<<
ip
time_t
now
=
time
(
nullptr
);
std
::
cerr
<<
"["
<<
std
::
put_time
(
localtime
(
&
now
),
"%Y-%m-%d %H:%M:%S"
)
<<
"]
\t
[Redis Receiver]
\t
"
<<
"invalid IP address: "
<<
ip
<<
std
::
endl
;
}
}
...
...
@@ -147,7 +166,9 @@ void RedisReceiver::setPort(int port) {
this
->
port
=
port
;
this
->
host
=
ip
+
":"
+
std
::
to_string
(
port
)
+
"/"
+
key
;
}
else
{
std
::
cerr
<<
"Redis Receiver Error: invalid port: "
<<
port
time_t
now
=
time
(
nullptr
);
std
::
cerr
<<
"["
<<
std
::
put_time
(
localtime
(
&
now
),
"%Y-%m-%d %H:%M:%S"
)
<<
"]
\t
[Redis Receiver]
\t
"
<<
"Invalid port : "
<<
port
<<
std
::
endl
;
}
}
...
...
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