Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
bb9d9bf8
Commit
bb9d9bf8
authored
Nov 07, 2013
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sev event storage, check that event is not already stored added
parent
943d2968
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
24 deletions
+59
-24
sev/exe/sev_server/src/sev_server.cpp
sev/exe/sev_server/src/sev_server.cpp
+0
-5
sev/lib/sev/src/sev_dbms.cpp
sev/lib/sev/src/sev_dbms.cpp
+59
-3
src/exe/rt_sevhistmon/src/rt_sevhistmon.cpp
src/exe/rt_sevhistmon/src/rt_sevhistmon.cpp
+0
-16
No files found.
sev/exe/sev_server/src/sev_server.cpp
View file @
bb9d9bf8
...
...
@@ -489,7 +489,6 @@ int sev_server::mainloop()
m_stat
.
dataget_msg_cnt
++
;
break
;
case
sev_eMsgType_EventsStore
:
printf
(
"sev_server Events received
\n
"
);
receive_events
(
(
sev_sMsgEventsStore
*
)
mp
,
get
.
size
);
m_stat
.
eventstore_msg_cnt
++
;
break
;
...
...
@@ -704,7 +703,6 @@ int sev_server::check_histitems( sev_sMsgHistItems *msg, unsigned int size)
}
else
{
// SevHistEvents item
printf
(
"Event item received
\n
"
);
if
(
!
m_db
->
check_item
(
&
m_sts
,
msg
->
Items
[
i
].
oid
,
msg
->
Items
[
i
].
oname
,
(
char
*
)
"Events"
,
storagetime
,
(
pwr_eType
)
0
,
0
,
...
...
@@ -718,7 +716,6 @@ int sev_server::check_histitems( sev_sMsgHistItems *msg, unsigned int size)
}
}
}
printf
(
"---- Node up (%d) ----
\n
"
,
nid
);
return
1
;
}
...
...
@@ -902,8 +899,6 @@ int sev_server::receive_events( sev_sMsgEventsStore *msg, unsigned int size)
for
(
unsigned
int
i
=
0
;
i
<
msg
->
NumEvents
;
i
++
)
{
sev_event
ev
;
printf
(
"Event Type %d Id %d text
\"
%s
\"\n
"
,
ep
->
type
,
ep
->
eventid_idx
,
ep
->
eventtext
);
ev
.
type
=
ep
->
type
;
ev
.
eventprio
=
ep
->
eventprio
;
ev
.
eventid
.
Nix
=
ep
->
eventid_nix
;
...
...
sev/lib/sev/src/sev_dbms.cpp
View file @
bb9d9bf8
...
...
@@ -1814,12 +1814,68 @@ int sev_dbms::store_event( pwr_tStatus *sts, int item_idx, sev_event *ep)
{
char
query
[
400
];
char
timstr
[
40
];
int
rc
;
*
sts
=
time_AtoAscii
(
&
ep
->
time
,
time_eFormat_NumDateAndTime
,
timstr
,
sizeof
(
timstr
));
if
(
EVEN
(
*
sts
))
return
0
;
timstr
[
19
]
=
0
;
// Check if event already exist
if
(
m_items
[
item_idx
].
options
&
pwr_mSevOptionsMask_PosixTime
)
{
if
(
m_items
[
item_idx
].
options
&
pwr_mSevOptionsMask_HighTimeResolution
)
// Posix time, high resolution
sprintf
(
query
,
"select eventid_nix,eventid_idx,ntime from %s where time = %ld"
,
m_items
[
item_idx
].
tablename
,
(
long
int
)
ep
->
time
.
tv_sec
);
else
// Posix time, low resolution
sprintf
(
query
,
"select eventid_nix,eventid_idx from %s where time = %ld"
,
m_items
[
item_idx
].
tablename
,
(
long
int
)
ep
->
time
.
tv_sec
);
}
else
{
if
(
m_items
[
item_idx
].
options
&
pwr_mSevOptionsMask_HighTimeResolution
)
// Sql time, high resolution
sprintf
(
query
,
"select eventid_nix,eventid_idx,ntime from %s where time = '%s'"
,
m_items
[
item_idx
].
tablename
,
timstr
);
else
// Sql time, low resolution
sprintf
(
query
,
"select eventid_nix,eventid_idx from %s where time = '%s'"
,
m_items
[
item_idx
].
tablename
,
timstr
);
}
rc
=
mysql_query
(
m_env
->
con
(),
query
);
if
(
rc
)
{
printf
(
"In %s row %d:
\n
"
,
__FILE__
,
__LINE__
);
printf
(
"%s: %s
\n
"
,
__FUNCTION__
,
mysql_error
(
m_env
->
con
()));
}
MYSQL_RES
*
result
=
mysql_store_result
(
m_env
->
con
());
if
(
!
result
)
{
printf
(
"In %s row %d:
\n
"
,
__FILE__
,
__LINE__
);
printf
(
"%s Result Error
\n
"
,
__FUNCTION__
);
}
int
rows
=
mysql_num_rows
(
result
);
int
found
=
0
;
unsigned
int
idx
,
nix
,
ntime
;
for
(
int
i
=
0
;
i
<
rows
;
i
++
)
{
MYSQL_ROW
row
;
ntime
=
0
;
row
=
mysql_fetch_row
(
result
);
if
(
row
[
0
]
!=
NULL
)
{
nix
=
strtoul
(
row
[
0
],
0
,
10
);
idx
=
strtoul
(
row
[
1
],
0
,
10
);
if
(
m_items
[
item_idx
].
options
&
pwr_mSevOptionsMask_HighTimeResolution
)
ntime
=
strtoul
(
row
[
2
],
0
,
10
);
}
if
(
ep
->
eventid
.
Nix
==
nix
&&
ep
->
eventid
.
Idx
==
idx
)
{
if
(
m_items
[
item_idx
].
options
&
pwr_mSevOptionsMask_HighTimeResolution
)
{
if
(
ntime
==
ep
->
time
.
tv_nsec
)
found
=
1
;
}
else
found
=
1
;
break
;
}
}
mysql_free_result
(
result
);
if
(
found
)
return
1
;
if
(
m_items
[
item_idx
].
options
&
pwr_mSevOptionsMask_PosixTime
)
{
if
(
m_items
[
item_idx
].
options
&
pwr_mSevOptionsMask_HighTimeResolution
)
{
// Posix time, high resolution
...
...
@@ -1846,7 +1902,7 @@ int sev_dbms::store_event( pwr_tStatus *sts, int item_idx, sev_event *ep)
sprintf
(
query
,
"insert into %s (time, ntime, eventtype, eventprio, eventid_nix, eventid_birthtime,"
"eventid_idx, eventtext, eventname) values ('%s',%ld,%d,%d,%d,%d,%d,'%s','%s')"
,
m_items
[
item_idx
].
tablename
,
timstr
,
(
long
int
)
ep
->
time
.
tv_sec
,
timstr
,
(
long
int
)
ep
->
time
.
tv_
n
sec
,
ep
->
type
,
ep
->
eventprio
,
ep
->
eventid
.
Nix
,
ep
->
eventid
.
BirthTime
.
tv_sec
,
ep
->
eventid
.
Idx
,
ep
->
eventtext
,
ep
->
eventname
);
}
...
...
@@ -1861,7 +1917,7 @@ int sev_dbms::store_event( pwr_tStatus *sts, int item_idx, sev_event *ep)
}
}
int
rc
=
mysql_query
(
m_env
->
con
(),
query
);
rc
=
mysql_query
(
m_env
->
con
(),
query
);
if
(
rc
)
{
// printf( "Store value: %s \"%s\"\n", mysql_error(m_env->con()), query);
*
sts
=
SEV__DBERROR
;
...
...
src/exe/rt_sevhistmon/src/rt_sevhistmon.cpp
View file @
bb9d9bf8
...
...
@@ -1088,7 +1088,6 @@ pwr_tStatus rt_sevhistmon::mh_ack_bc( mh_sAck *msg)
if
(
shm
->
m_sevhistevents
)
shm
->
m_sevhistevents
->
evbuf_insert
(
&
ed
);
printf
(
"Ack
\n
"
);
return
1
;
}
...
...
@@ -1108,7 +1107,6 @@ pwr_tStatus rt_sevhistmon::mh_return_bc( mh_sReturn *msg)
if
(
shm
->
m_sevhistevents
)
shm
->
m_sevhistevents
->
evbuf_insert
(
&
ed
);
printf
(
"Return
\n
"
);
return
1
;
}
...
...
@@ -1128,7 +1126,6 @@ pwr_tStatus rt_sevhistmon::mh_alarm_bc( mh_sMessage *msg)
if
(
shm
->
m_sevhistevents
)
shm
->
m_sevhistevents
->
evbuf_insert
(
&
ed
);
printf
(
"Alarm
\n
"
);
return
1
;
}
...
...
@@ -1148,7 +1145,6 @@ pwr_tStatus rt_sevhistmon::mh_block_bc( mh_sBlock *msg)
if
(
shm
->
m_sevhistevents
)
shm
->
m_sevhistevents
->
evbuf_insert
(
&
ed
);
printf
(
"Block
\n
"
);
return
1
;
}
...
...
@@ -1168,7 +1164,6 @@ pwr_tStatus rt_sevhistmon::mh_cancel_bc( mh_sReturn *msg)
if
(
shm
->
m_sevhistevents
)
shm
->
m_sevhistevents
->
evbuf_insert
(
&
ed
);
printf
(
"Cancel
\n
"
);
return
1
;
}
...
...
@@ -1188,19 +1183,16 @@ pwr_tStatus rt_sevhistmon::mh_info_bc( mh_sMessage *msg)
if
(
shm
->
m_sevhistevents
)
shm
->
m_sevhistevents
->
evbuf_insert
(
&
ed
);
printf
(
"Info
\n
"
);
return
1
;
}
pwr_tStatus
rt_sevhistmon
::
mh_clear_alarmlist_bc
(
pwr_tNodeIndex
nix
)
{
printf
(
"Clearalarmlist
\n
"
);
return
1
;
}
pwr_tStatus
rt_sevhistmon
::
mh_clear_blocklist_bc
(
pwr_tNodeIndex
nix
)
{
printf
(
"Clearblocklist
\n
"
);
return
1
;
}
...
...
@@ -1212,8 +1204,6 @@ void sev_sevhistevents::evbuf_insert( sev_sEvent *ev)
if
(
event_buffer
[
idx
].
eventid_idx
==
ev
->
eventid_idx
&&
event_buffer
[
idx
].
eventid_nix
==
ev
->
eventid_nix
&&
event_buffer
[
idx
].
eventid_birthtime
==
ev
->
eventid_birthtime
)
{
printf
(
"Rejected type %d id %d
\"
%s
\"\n
"
,
ev
->
type
,
ev
->
eventid_idx
,
ev
->
eventtext
);
return
;
}
if
(
idx
==
evbuf_oldest
)
...
...
@@ -1241,8 +1231,6 @@ void sev_sevhistevents::evbuf_insert( sev_sEvent *ev)
}
memcpy
(
&
event_buffer
[
evbuf_last
],
ev
,
sizeof
(
event_buffer
[
0
]));
}
printf
(
"Insert last %d oldest %d type %d id %d
\"
%s
\"\n
"
,
evbuf_last
,
evbuf_oldest
,
event_buffer
[
evbuf_last
].
type
,
event_buffer
[
evbuf_last
].
eventid_idx
,
event_buffer
[
evbuf_last
].
eventtext
);
}
void
sev_sevhistevents
::
evbuf_send
()
...
...
@@ -1280,7 +1268,6 @@ void sev_sevhistevents::evbuf_send()
unsigned
int
ev_cnt
=
0
;
if
(
evbuf_sent
==
ev_cInit
)
{
for
(
unsigned
int
idx
=
evbuf_oldest
;;)
{
printf
(
"Send idx %d id %d
\n
"
,
idx
,
event_buffer
[
idx
].
eventid_idx
);
memcpy
(
&
((
sev_sMsgEventsStore
*
)
put
.
data
)
->
Events
[
ev_cnt
],
&
event_buffer
[
idx
],
sizeof
(
sev_sEvent
));
ev_cnt
++
;
evbuf_sent
=
idx
;
...
...
@@ -1293,7 +1280,6 @@ void sev_sevhistevents::evbuf_send()
unsigned
int
start_idx
=
evbuf_sent
;
evbuf_next_idx
(
start_idx
);
for
(
unsigned
int
idx
=
start_idx
;;)
{
printf
(
"Send idx %d id %d
\n
"
,
idx
,
event_buffer
[
idx
].
eventid_idx
);
memcpy
(
&
((
sev_sMsgEventsStore
*
)
put
.
data
)
->
Events
[
ev_cnt
],
&
event_buffer
[
idx
],
sizeof
(
sev_sEvent
));
ev_cnt
++
;
evbuf_sent
=
idx
;
...
...
@@ -1302,7 +1288,6 @@ void sev_sevhistevents::evbuf_send()
evbuf_next_idx
(
idx
);
}
}
printf
(
"Send num: %d cnt: %d
\n
"
,
num
,
ev_cnt
);
tgt
.
nid
=
monitor
->
m_hs
[
event_thread_idx
].
nid
;
tgt
.
qix
=
sev_eProcSevServer
;
...
...
@@ -1445,7 +1430,6 @@ int rt_sevhistmon::mainloop()
send_itemlist
(
get
.
sender
.
nid
);
break
;
case
sev_eMsgType_HistItemsRequest
:
printf
(
"rt_sevhistmon: HistitemsRequest received
\n
"
);
send_itemlist
(
get
.
sender
.
nid
);
break
;
case
sev_eMsgType_ServerStatus
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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