Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hidra
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
Container Registry
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
steinbac
hidra
Commits
5f5f58d1
Commit
5f5f58d1
authored
9 years ago
by
Manuela Kuhn
Browse files
Options
Downloads
Patches
Plain Diff
Moved/Removed file after sending
parent
fad7de0f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sender/DataDispatcher.py
+57
-27
57 additions, 27 deletions
src/sender/DataDispatcher.py
src/sender/TaskProvider.py
+3
-1
3 additions, 1 deletion
src/sender/TaskProvider.py
with
60 additions
and
28 deletions
src/sender/DataDispatcher.py
+
57
−
27
View file @
5f5f58d1
...
...
@@ -96,49 +96,76 @@ class DataDispatcher():
while
True
:
# Get workload from router, until finished
self
.
log
.
debug
(
"
DataDispatcher-
"
+
str
(
self
.
id
)
+
"
: waiting for new job
"
)
message
=
self
.
routerSocket
.
recv
()
message
=
self
.
routerSocket
.
recv
_multipart
()
self
.
log
.
debug
(
"
DataDispatcher-
"
+
str
(
self
.
id
)
+
"
: new job received
"
)
finished
=
workload
==
b
"
EXIT
"
if
finished
:
self
.
log
.
debug
(
"
Router requested to shutdown DataDispatcher-
"
+
str
(
self
.
id
)
+
"
.
"
)
break
workload
=
message
[
0
]
targets
=
message
[
1
:]
if
len
(
message
)
>=
2
:
workload
=
message
[
0
]
targets
=
message
[
1
:]
else
:
workload
=
message
targets
=
None
finished
=
workload
==
b
"
EXIT
"
if
finished
:
self
.
log
.
debug
(
"
Router requested to shutdown DataDispatcher-
"
+
str
(
self
.
id
)
+
"
.
"
)
break
# get metadata of the file
try
:
self
.
log
.
debug
(
"
Getting file metadata
"
)
source
PathFull
,
metadata
=
self
.
getMetadata
(
workload
)
source
File
,
metadata
=
self
.
getMetadata
(
workload
)
except
Exception
as
e
:
self
.
log
.
error
(
"
Building of metadata dictionary failed for file:
"
+
str
(
source
PathFull
)
+
"
.
"
)
self
.
log
.
error
(
"
Building of metadata dictionary failed for file:
"
+
str
(
source
File
)
+
"
.
"
)
self
.
log
.
debug
(
"
Error was:
"
+
str
(
e
))
#skip all further instructions and continue with next iteration
continue
# send data
try
:
self
.
sendData
(
targets
,
sourcePathFull
,
metadataDict
)
except
Exception
as
e
:
self
.
log
.
debug
(
"
DataDispatcher-
"
+
str
(
self
.
id
)
+
"
: Passing new file to data Stream...failed.
"
)
self
.
log
.
debug
(
"
Error was:
"
+
str
(
e
))
if
targets
:
try
:
self
.
sendData
(
targets
,
sourceFile
,
metadata
)
except
Exception
as
e
:
self
.
log
.
debug
(
"
DataDispatcher-
"
+
str
(
self
.
id
)
+
"
: Passing new file to data Stream...failed.
"
)
self
.
log
.
debug
(
"
Error was:
"
+
str
(
e
))
# remove file
try
:
os
.
remove
(
sourceFile
)
self
.
log
.
info
(
"
Removing file
'"
+
str
(
sourceFile
)
+
"'
...success.
"
)
except
IOError
:
self
.
log
.
debug
(
"
IOError:
"
+
str
(
sourceFile
))
except
Exception
,
e
:
trace
=
traceback
.
format_exc
()
self
.
log
.
debug
(
"
Unable to remove file {FILE}.
"
.
format
(
FILE
=
str
(
sourceFile
))
self
.
log
.
debug
(
"
trace=
"
+
str
(
trace
))
else
:
# move file
try
:
shutil
.
move
(
sourceFile
,
targetFile
)
self
.
log
.
info
(
"
Moving file
'"
+
str
(
sourceFile
)
+
"'
...success.
"
)
except
IOError
:
self
.
log
.
debug
(
"
IOError:
"
+
str
(
sourceFile
))
except
Exception
,
e
:
trace
=
traceback
.
format_exc
()
self
.
log
.
debug
(
"
Unable to move file {FILE}.
"
.
format
(
FILE
=
str
(
sourceFile
))
self
.
log
.
debug
(
"
trace=
"
+
str
(
trace
))
# send file to cleaner pipe
try
:
#sending to pipe
self
.
log
.
debug
(
"
send file-event for file to cleaner-pipe...
"
)
self
.
log
.
debug
(
"
metadata
Dict
=
"
+
str
(
metadata
Dict
))
self
.
cleanerSocket
.
send
(
json
.
dumps
(
metadata
Dict
))
self
.
log
.
debug
(
"
send file-event for file to cleaner-pipe...success.
"
)
#TODO: remember workload. append to list?
# can be used to verify files which have been processed twice or more
except
Exception
,
e
:
self
.
log
.
error
(
"
Unable to notify Cleaner-pipe to handle file:
"
+
str
(
workload
))
#
try:
#
#sending to pipe
#
self.log.debug("send file-event for file to cleaner-pipe...")
#
self.log.debug("metadata = " + str(metadata))
#
self.cleanerSocket.send(json.dumps(metadata))
#
self.log.debug("send file-event for file to cleaner-pipe...success.")
#
#
#TODO: remember workload. append to list?
#
# can be used to verify files which have been processed twice or more
#
except Exception, e:
#
self.log.error("Unable to notify Cleaner-pipe to handle file: " + str(workload))
#
def
getMetadata
(
self
,
workload
):
...
...
@@ -326,3 +353,6 @@ class DataDispatcher():
def
__del__
(
self
):
self
.
stop
()
if
__name__
==
'
__main__
'
:
pass
This diff is collapsed.
Click to expand it.
src/sender/TaskProvider.py
+
3
−
1
View file @
5f5f58d1
...
...
@@ -152,7 +152,9 @@ class TaskProvider():
# send the file to the fileMover
try
:
self
.
log
.
debug
(
"
Sending message...
"
)
message
=
[
messageDict
]
+
requests
message
=
[
messageDict
]
if
requests
!=
[
"
None
"
]:
message
+=
requests
self
.
log
.
debug
(
str
(
message
))
self
.
routerSocket
.
send_multipart
(
message
)
self
.
log
.
debug
(
"
Sending message...done.
"
)
...
...
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