Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
c5dd0f7f
Commit
c5dd0f7f
authored
Sep 24, 2017
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(LogDB): добавил настройку размера буфера для чтения сообщений от логсервера.
parent
c25abb47
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
5 deletions
+15
-5
LogDB.cc
extensions/LogDB/LogDB.cc
+13
-3
LogDB.h
extensions/LogDB/LogDB.h
+2
-2
No files found.
extensions/LogDB/LogDB.cc
View file @
c5dd0f7f
...
...
@@ -89,6 +89,8 @@ LogDB::LogDB( const string& name, int argc, const char* const* argv, const strin
double
checkConnection_sec
=
atof
(
uniset
::
getArg2Param
(
"--"
+
prefix
+
"check-connection-sec"
,
argc
,
argv
,
it
.
getProp
(
"checkConnectionSec"
),
"5"
).
c_str
());
int
bufSize
=
uniset
::
getArgPInt
(
"--"
+
prefix
+
"read-buffer-size"
,
argc
,
argv
,
it
.
getProp
(
"readBufferSize"
),
10001
);
std
::
string
s_overflow
=
uniset
::
getArg2Param
(
"--"
+
prefix
+
"overflow-factor"
,
argc
,
argv
,
it
.
getProp
(
"overflowFactor"
),
"1.3"
);
float
ovf
=
atof
(
s_overflow
.
c_str
());
...
...
@@ -127,6 +129,8 @@ LogDB::LogDB( const string& name, int argc, const char* const* argv, const strin
l
->
cmd
=
sit
.
getProp
(
"cmd"
);
l
->
description
=
sit
.
getProp
(
"description"
);
l
->
setReadBufSize
(
bufSize
);
l
->
setCheckConnectionTime
(
checkConnection_sec
);
if
(
l
->
name
.
empty
()
)
...
...
@@ -368,7 +372,8 @@ void LogDB::help_print()
cout
<<
"--prefix-max-records sz - Максимальное количество записей в БД. При превышении, старые удаляются. 0 - не удалять"
<<
endl
;
cout
<<
"--prefix-overflow-factor float - Коэффициент переполнения, после которого запускается удаление старых записей. По умолчанию: 1.3"
<<
endl
;
cout
<<
"--prefix-max-websockets num - Максимальное количество websocket-ов"
<<
endl
;
cout
<<
"--prefix-check-connection-sec sec - Период проверки соединения с logserver-ом"
<<
endl
;
cout
<<
"--prefix-check-connection-sec sec - Период проверки соединения с логсервером"
<<
endl
;
cout
<<
"--prefix-read-buffer-size num - Размер буфера для чтения сообщений от логсервера. Deault: 10001"
<<
endl
;
cout
<<
"--prefix-db-disable - Отключить запись в БД"
<<
endl
;
...
...
@@ -558,6 +563,11 @@ void LogDB::Log::setCheckConnectionTime( double sec )
checkConnection_sec
=
sec
;
}
// -----------------------------------------------------------------------------
void
LogDB
::
Log
::
setReadBufSize
(
size_t
sz
)
{
buf
.
resize
(
sz
);
}
// -----------------------------------------------------------------------------
void
LogDB
::
Log
::
read
(
ev
::
io
&
watcher
)
{
if
(
!
tcp
)
...
...
@@ -565,11 +575,11 @@ void LogDB::Log::read( ev::io& watcher )
int
n
=
tcp
->
available
();
n
=
std
::
min
(
n
,
bufsize
);
n
=
std
::
min
(
n
,
(
int
)
buf
.
size
()
);
if
(
n
>
0
)
{
tcp
->
receiveBytes
(
buf
,
n
);
tcp
->
receiveBytes
(
buf
.
data
()
,
n
);
// нарезаем на строки
for
(
int
i
=
0
;
i
<
n
;
i
++
)
...
...
extensions/LogDB/LogDB.h
View file @
c5dd0f7f
...
...
@@ -277,6 +277,7 @@ namespace uniset
void
setCheckConnectionTime
(
double
sec
);
void
setReadBufSize
(
size_t
sz
);
protected
:
void
ioprepare
();
...
...
@@ -290,8 +291,7 @@ namespace uniset
double
checkConnection_sec
=
{
5
.
0
};
std
::
shared_ptr
<
UTCPStream
>
tcp
;
static
const
int
bufsize
=
{
10001
};
char
buf
[
bufsize
];
// буфер для чтения сообщений
std
::
vector
<
char
>
buf
;
// буфер для чтения сообщений
static
const
size_t
reservsize
=
{
1000
};
std
::
string
text
;
...
...
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