Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
data_importer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IA2
data_importer
Commits
8000709c
Commit
8000709c
authored
11 years ago
by
Marco De Marco
Browse files
Options
Downloads
Patches
Plain Diff
Before protocol manager refactoring
parent
290b5392
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/Client.cpp
+4
-2
4 additions, 2 deletions
src/Client.cpp
src/Client.h
+1
-1
1 addition, 1 deletion
src/Client.h
src/ProtocolManager.cpp
+55
-11
55 additions, 11 deletions
src/ProtocolManager.cpp
src/ProtocolManager.h
+4
-1
4 additions, 1 deletion
src/ProtocolManager.h
with
64 additions
and
15 deletions
src/Client.cpp
+
4
−
2
View file @
8000709c
...
@@ -38,7 +38,7 @@ Client::~Client()
...
@@ -38,7 +38,7 @@ Client::~Client()
if
(
m_thread_sp
)
if
(
m_thread_sp
)
{
{
m_thread_sp
->
interrupt
();
//
m_thread_sp->interrupt();
m_thread_sp
->
join
();
m_thread_sp
->
join
();
}
}
...
@@ -82,7 +82,7 @@ void Client::stop()
...
@@ -82,7 +82,7 @@ void Client::stop()
if
(
m_thread_sp
)
if
(
m_thread_sp
)
{
{
m_thread_sp
->
interrupt
();
//
m_thread_sp->interrupt();
m_thread_sp
->
join
();
m_thread_sp
->
join
();
}
}
...
@@ -411,6 +411,8 @@ void Client::handleReadData(FileWrapper::SP fileWrapper_sp, std::size_t recvByte
...
@@ -411,6 +411,8 @@ void Client::handleReadData(FileWrapper::SP fileWrapper_sp, std::size_t recvByte
{
{
WARN_STREAM
<<
"Client::handleReadData() bad I/O"
<<
endl
;
WARN_STREAM
<<
"Client::handleReadData() bad I/O"
<<
endl
;
fileWrapper_sp
->
cleanUp
();
onTransferFailed
();
onTransferFailed
();
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/Client.h
+
1
−
1
View file @
8000709c
...
@@ -117,7 +117,7 @@ protected:
...
@@ -117,7 +117,7 @@ protected:
const
boost
::
system
::
error_code
&
);
const
boost
::
system
::
error_code
&
);
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// [Protected]
T
ransfer result methods
// [Protected]
Protocol and t
ransfer result
handler
methods
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
onTransferCompleted
(
FileWrapper
::
SP
);
void
onTransferCompleted
(
FileWrapper
::
SP
);
...
...
This diff is collapsed.
Click to expand it.
src/ProtocolManager.cpp
+
55
−
11
View file @
8000709c
...
@@ -80,24 +80,36 @@ bool ProtocolManager::hasNextFile()
...
@@ -80,24 +80,36 @@ bool ProtocolManager::hasNextFile()
m_recoveryMode
=
false
;
m_recoveryMode
=
false
;
return
true
;
return
true
;
}
}
else
if
(
m_failedFileRowset_sp
&&
if
(
m_failedFileRowset_sp
&&
m_failedFileRowsetIt
!=
m_failedFileRowset_sp
->
end
())
m_failedFileRowsetIt
!=
m_failedFileRowset_sp
->
end
())
{
{
DEBUG_STREAM
<<
"ProtocolManager::hasNextFile() from failed list"
<<
endl
;
boost
::
posix_time
::
ptime
now
(
boost
::
posix_time
::
second_clock
::
local_time
());
if
(
m_recoveryModeTime
.
is_not_a_date_time
())
m_recoveryModeTime
=
now
;
//FIXME: inhibition of retry for n seconds
boost
::
posix_time
::
time_duration
diff
=
now
-
m_recoveryModeTime
;
if
(
diff
.
total_seconds
()
>
30
)
{
DEBUG_STREAM
<<
"ProtocolManager::hasNextFile() from failed list"
<<
endl
;
m_recoveryModeTime
=
now
;
m_recoveryMode
=
true
;
m_recoveryMode
=
true
;
return
true
;
return
true
;
}
}
else
else
{
{
DEBUG_STREAM
<<
"ProtocolManager::hasNextFile() "
<<
"wait from failed list"
<<
endl
;
}
}
DEBUG_STREAM
<<
"ProtocolManager::hasNextFile() lists empty"
<<
endl
;
DEBUG_STREAM
<<
"ProtocolManager::hasNextFile() lists empty"
<<
endl
;
m_recoveryMode
=
false
;
m_recoveryMode
=
false
;
return
false
;
return
false
;
}
}
}
//==============================================================================
//==============================================================================
// ProtocolManager::createRequest()
// ProtocolManager::createRequest()
...
@@ -280,6 +292,7 @@ void ProtocolManager::setFileTransfered(FileWrapper::SP fileWrapper_sp)
...
@@ -280,6 +292,7 @@ void ProtocolManager::setFileTransfered(FileWrapper::SP fileWrapper_sp)
throw
std
::
invalid_argument
(
"Empty file name found on failed list"
);
throw
std
::
invalid_argument
(
"Empty file name found on failed list"
);
string
fileName
=
m_failedFileRowsetIt
->
get
<
1
>
().
get
();
string
fileName
=
m_failedFileRowsetIt
->
get
<
1
>
().
get
();
//FIXME: not incremented in case of exception!!!
++
m_failedFileRowsetIt
;
++
m_failedFileRowsetIt
;
DBManager
::
TransactionSP
auxTransaction_sp
=
m_dBManager_sp
->
getAuxTransaction
();
DBManager
::
TransactionSP
auxTransaction_sp
=
m_dBManager_sp
->
getAuxTransaction
();
...
@@ -315,9 +328,40 @@ void ProtocolManager::setFileFailed() throw(std::logic_error, std::runtime_error
...
@@ -315,9 +328,40 @@ void ProtocolManager::setFileFailed() throw(std::logic_error, std::runtime_error
throw
std
::
invalid_argument
(
"Empty file name found on new list"
);
throw
std
::
invalid_argument
(
"Empty file name found on new list"
);
string
fileName
=
m_newFileRowsetIt
->
get
<
1
>
().
get
();
string
fileName
=
m_newFileRowsetIt
->
get
<
1
>
().
get
();
if
(
!
m_newFileRowsetIt
->
get
<
2
>
())
throw
std
::
invalid_argument
(
"Empty update time found on new list"
);
std
::
tm
currentTm
=
m_newFileRowsetIt
->
get
<
2
>
().
get
();
INFO_STREAM
<<
"ProtocolManager::setFileFailed() file "
<<
fileName
<<
" version "
<<
fileVersion
<<
" transfered"
<<
endl
;
boost
::
posix_time
::
ptime
currentPtime
=
boost
::
posix_time
::
ptime_from_tm
(
currentTm
);
boost
::
posix_time
::
ptime
nextPtime
(
boost
::
posix_time
::
pos_infin
);
//FIXME: not incremented in case of exception!!!
++
m_newFileRowsetIt
;
++
m_newFileRowsetIt
;
if
(
m_newFileRowsetIt
!=
m_newFileRowset_sp
->
end
())
{
if
(
!
m_newFileRowsetIt
->
get
<
2
>
())
throw
std
::
invalid_argument
(
"Empty next update time found on new list"
);
std
::
tm
nextTm
=
m_newFileRowsetIt
->
get
<
2
>
().
get
();
nextPtime
=
boost
::
posix_time
::
ptime_from_tm
(
nextTm
);
}
DBManager
::
TransactionSP
auxTransaction_sp
=
m_dBManager_sp
->
getAuxTransaction
();
DBManager
::
TransactionSP
mainTransaction_sp
=
m_dBManager_sp
->
getMainTransaction
();
if
(
nextPtime
>
currentPtime
)
m_dBManager_sp
->
persistLastTimestamp
(
currentPtime
);
m_dBManager_sp
->
addFailedFile
(
fileVersion
,
fileName
);
m_dBManager_sp
->
addFailedFile
(
fileVersion
,
fileName
);
auxTransaction_sp
->
commit
();
mainTransaction_sp
->
commit
();
}
}
else
else
{
{
...
...
This diff is collapsed.
Click to expand it.
src/ProtocolManager.h
+
4
−
1
View file @
8000709c
...
@@ -97,9 +97,12 @@ protected:
...
@@ -97,9 +97,12 @@ protected:
//Address and port of remote endpoint
//Address and port of remote endpoint
std
::
string
m_remoteEndpoint
;
std
::
string
m_remoteEndpoint
;
//Processing file from
recovery
list
//Processing file from
failed
list
bool
m_recoveryMode
;
bool
m_recoveryMode
;
//Processing file from failed list last timestamp
boost
::
posix_time
::
ptime
m_recoveryModeTime
;
//New file list shared pointer
//New file list shared pointer
DBManager
::
NewFileRowsetSP
m_newFileRowset_sp
;
DBManager
::
NewFileRowsetSP
m_newFileRowset_sp
;
...
...
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