Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
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
RadioObservatory
LOFAR
Commits
a3f0b26f
Commit
a3f0b26f
authored
6 years ago
by
Thomas Jürges
Browse files
Options
Downloads
Patches
Plain Diff
Task
SW-533
: Add client function to stop data writers
parent
63a21729
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitattributes
+1
-0
1 addition, 0 deletions
.gitattributes
MAC/Services/TBB/TBBClient/bin/tbb_stop_datawriters
+31
-0
31 additions, 0 deletions
MAC/Services/TBB/TBBClient/bin/tbb_stop_datawriters
MAC/Services/TBB/TBBClient/lib/__init__.py
+26
-16
26 additions, 16 deletions
MAC/Services/TBB/TBBClient/lib/__init__.py
with
58 additions
and
16 deletions
.gitattributes
+
1
−
0
View file @
a3f0b26f
...
@@ -3663,6 +3663,7 @@ MAC/Services/TBB/CMakeLists.txt -text
...
@@ -3663,6 +3663,7 @@ MAC/Services/TBB/CMakeLists.txt -text
MAC/Services/TBB/TBBClient/CMakeLists.txt -text
MAC/Services/TBB/TBBClient/CMakeLists.txt -text
MAC/Services/TBB/TBBClient/bin/CMakeLists.txt -text
MAC/Services/TBB/TBBClient/bin/CMakeLists.txt -text
MAC/Services/TBB/TBBClient/bin/tbb_start_datawriters -text
MAC/Services/TBB/TBBClient/bin/tbb_start_datawriters -text
MAC/Services/TBB/TBBClient/bin/tbb_stop_datawriters -text
MAC/Services/TBB/TBBClient/lib/CMakeLists.txt -text
MAC/Services/TBB/TBBClient/lib/CMakeLists.txt -text
MAC/Services/TBB/TBBClient/lib/__init__.py -text
MAC/Services/TBB/TBBClient/lib/__init__.py -text
MAC/Services/TBB/TBBClient/lib/tbbbuslistener.py -text
MAC/Services/TBB/TBBClient/lib/tbbbuslistener.py -text
...
...
This diff is collapsed.
Click to expand it.
MAC/Services/TBB/TBBClient/bin/tbb_stop_datawriters
0 → 100755
+
31
−
0
View file @
a3f0b26f
#!/usr/bin/python
import
logging
from
optparse
import
OptionParser
from
lofar.mac.tbbservice.config
import
DEFAULT_TBB_BUSNAME
,
DEFAULT_TBB_SERVICENAME
,
DEFAULT_BROKER
from
lofar.mac.tbbservice.config
import
DEFAULT_TBB_NOTIFICATION_BUSNAME
from
lofar.mac.tbbservice.client
import
stop_datawriters_and_wait_until_finished
if
__name__
==
'
__main__
'
:
logging
.
basicConfig
(
format
=
'
%(asctime)s %(levelname)s %(message)s
'
,
level
=
logging
.
INFO
)
# Check the invocation arguments
parser
=
OptionParser
(
'
%prog [options]
'
,
description
=
'
issue a command to the tbb service to stop the datawriters, and wait until they are done.
'
)
parser
.
add_option
(
'
-q
'
,
'
--broker
'
,
dest
=
'
broker
'
,
type
=
'
string
'
,
default
=
DEFAULT_BROKER
,
help
=
'
Address of the qpid broker, default: %default
'
)
parser
.
add_option
(
"
-b
"
,
"
--tbb_service_busname
"
,
dest
=
"
tbb_service_busname
"
,
type
=
"
string
"
,
default
=
DEFAULT_TBB_BUSNAME
,
help
=
"
Name of the bus on which the tbb service listens. [default: %default]
"
)
parser
.
add_option
(
"
-s
"
,
"
--tbb_service_name
"
,
dest
=
"
tbb_service_name
"
,
type
=
"
string
"
,
default
=
DEFAULT_TBB_SERVICENAME
,
help
=
"
Name of the tbb service. [default: %default]
"
)
parser
.
add_option
(
"
-n
"
,
"
--tbb_notification_busname
"
,
dest
=
"
tbb_notification_busname
"
,
type
=
"
string
"
,
default
=
DEFAULT_TBB_NOTIFICATION_BUSNAME
,
help
=
'
Name of the notification bus exchange on the qpid broker on which the tbb notifications are published, default: %default
'
)
(
options
,
args
)
=
parser
.
parse_args
()
stop_datawriters_and_wait_until_finished
(
service_busname
=
options
.
tbb_service_busname
,
service_name
=
options
.
tbb_service_name
,
notification_busname
=
options
.
tbb_notification_busname
,
broker
=
options
.
broker
)
This diff is collapsed.
Click to expand it.
MAC/Services/TBB/TBBClient/lib/__init__.py
+
26
−
16
View file @
a3f0b26f
...
@@ -10,6 +10,21 @@ from lofar.mac.tbb.config import DEFAULT_TBB_NOTIFICATION_BUSNAME
...
@@ -10,6 +10,21 @@ from lofar.mac.tbb.config import DEFAULT_TBB_NOTIFICATION_BUSNAME
from
lofar.mac.tbb.client.rpc
import
TBBRPC
from
lofar.mac.tbb.client.rpc
import
TBBRPC
from
lofar.mac.tbb.client.tbbbuslistener
import
TBBBusListener
from
lofar.mac.tbb.client.tbbbuslistener
import
TBBBusListener
class
Waiter
(
TBBBusListener
):
'''
Helper class which overrides TBBBusListener.onDataWritersFinished
and waits for synchronization using threading Events
'''
def
__init__
(
self
,
busname
=
notification_busname
,
broker
=
broker
,
**
kwargs
):
self
.
wait_event
=
Event
()
super
(
Waiter
,
self
).
__init__
(
busname
=
busname
,
broker
=
broker
,
**
kwargs
)
def
onDataWritersFinished
(
self
,
msg_content
):
# signal that we're done waiting
self
.
wait_event
.
set
()
def
wait
(
self
,
timeout
=
24
*
3600
):
# wait until onDataWritersFinished
self
.
wait_event
.
wait
(
timeout
)
def
start_datawriters_and_wait_until_finished
(
service_busname
=
DEFAULT_TBB_BUSNAME
,
def
start_datawriters_and_wait_until_finished
(
service_busname
=
DEFAULT_TBB_BUSNAME
,
service_name
=
DEFAULT_TBB_SERVICENAME
,
service_name
=
DEFAULT_TBB_SERVICENAME
,
notification_busname
=
DEFAULT_TBB_NOTIFICATION_BUSNAME
,
notification_busname
=
DEFAULT_TBB_NOTIFICATION_BUSNAME
,
...
@@ -17,24 +32,19 @@ def start_datawriters_and_wait_until_finished(service_busname=DEFAULT_TBB_BUSNAM
...
@@ -17,24 +32,19 @@ def start_datawriters_and_wait_until_finished(service_busname=DEFAULT_TBB_BUSNAM
'''
'''
convenience method which issues a start_datawriters command to the tbbservice, and waits until all writers are done
convenience method which issues a start_datawriters command to the tbbservice, and waits until all writers are done
'''
'''
class
Waiter
(
TBBBusListener
):
'''
Helper class which overrides TBBBusListener.onDataWritersFinished
and waits for synchronization using threading Events
'''
def
__init__
(
self
,
busname
=
notification_busname
,
broker
=
broker
,
**
kwargs
):
self
.
wait_event
=
Event
()
super
(
Waiter
,
self
).
__init__
(
busname
=
busname
,
broker
=
broker
,
**
kwargs
)
def
onDataWritersFinished
(
self
,
msg_content
):
# signal that we're done waiting
self
.
wait_event
.
set
()
def
wait
(
self
,
timeout
=
24
*
3600
):
# wait until onDataWritersFinished
self
.
wait_event
.
wait
(
timeout
)
with
Waiter
()
as
waiter
:
with
Waiter
()
as
waiter
:
with
TBBRPC
(
busname
=
service_busname
,
servicename
=
service_name
,
broker
=
broker
)
as
rpc
:
with
TBBRPC
(
busname
=
service_busname
,
servicename
=
service_name
,
broker
=
broker
)
as
rpc
:
rpc
.
start_datawriters
()
rpc
.
start_datawriters
()
waiter
.
wait
()
waiter
.
wait
()
def
stop_datawriters_and_wait_until_finished
(
service_busname
=
DEFAULT_TBB_BUSNAME
,
service_name
=
DEFAULT_TBB_SERVICENAME
,
notification_busname
=
DEFAULT_TBB_NOTIFICATION_BUSNAME
,
broker
=
DEFAULT_BROKER
):
'''
convenience method which issues a stop_datawriters command to the tbbservice, and waits until all writers are done
'''
with
Waiter
()
as
waiter
:
with
TBBRPC
(
busname
=
service_busname
,
servicename
=
service_name
,
broker
=
broker
)
as
rpc
:
rpc
.
stop_datawriters
()
waiter
.
wait
()
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