Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dm-docs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hammonds
dm-docs
Commits
6f639ea8
Commit
6f639ea8
authored
9 years ago
by
sveseli
Browse files
Options
Downloads
Patches
Plain Diff
convert storage manager to use threading utility synchronization
parent
038b8fb0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/python/dm/ds_web_service/service/impl/storageManager.py
+21
-31
21 additions, 31 deletions
src/python/dm/ds_web_service/service/impl/storageManager.py
with
21 additions
and
31 deletions
src/python/dm/ds_web_service/service/impl/storageManager.py
+
21
−
31
View file @
6f639ea8
...
@@ -8,6 +8,7 @@ from dm.common.utility.loggingManager import LoggingManager
...
@@ -8,6 +8,7 @@ from dm.common.utility.loggingManager import LoggingManager
from
dm.common.utility.configurationManager
import
ConfigurationManager
from
dm.common.utility.configurationManager
import
ConfigurationManager
from
dm.common.utility.singleton
import
Singleton
from
dm.common.utility.singleton
import
Singleton
from
dm.common.utility.osUtility
import
OsUtility
from
dm.common.utility.osUtility
import
OsUtility
from
dm.common.utility.threadingUtility
import
ThreadingUtility
class
StorageManager
(
Singleton
):
class
StorageManager
(
Singleton
):
...
@@ -47,44 +48,33 @@ class StorageManager(Singleton):
...
@@ -47,44 +48,33 @@ class StorageManager(Singleton):
storageDirectory
=
os
.
path
.
normpath
(
storageDirectory
)
storageDirectory
=
os
.
path
.
normpath
(
storageDirectory
)
return
storageDirectory
return
storageDirectory
@ThreadingUtility.synchronize
def
updateExperimentWithStorageDataDirectory
(
self
,
experiment
):
def
updateExperimentWithStorageDataDirectory
(
self
,
experiment
):
self
.
lock
.
acquire
()
storageDirectory
=
self
.
__getExperimentStorageDataDirectory
(
experiment
)
try
:
if
os
.
path
.
exists
(
storageDirectory
):
storageDirectory
=
self
.
__getExperimentStorageDataDirectory
(
experiment
)
experiment
[
'
storageDirectory
'
]
=
storageDirectory
if
os
.
path
.
exists
(
storageDirectory
):
experiment
[
'
storageHost
'
]
=
ConfigurationManager
.
getInstance
().
getHost
()
experiment
[
'
storageDirectory
'
]
=
storageDirectory
return
storageDirectory
experiment
[
'
storageHost
'
]
=
ConfigurationManager
.
getInstance
().
getHost
()
return
storageDirectory
finally
:
self
.
lock
.
release
()
@ThreadingUtility.synchronize
def
createExperimentDataDirectory
(
self
,
experiment
):
def
createExperimentDataDirectory
(
self
,
experiment
):
self
.
lock
.
acquire
()
experimentName
=
experiment
.
get
(
'
name
'
)
try
:
storageDirectory
=
self
.
__getExperimentStorageDataDirectory
(
experiment
)
experimentName
=
experiment
.
get
(
'
name
'
)
if
os
.
path
.
exists
(
storageDirectory
):
storageDirectory
=
self
.
__getExperimentStorageDataDirectory
(
experiment
)
self
.
logger
.
debug
(
'
Data directory %s for experiment %s already exists
'
%
(
storageDirectory
,
experimentName
))
if
os
.
path
.
exists
(
storageDirectory
):
else
:
self
.
logger
.
debug
(
'
Data directory %s for experiment %s already exists
'
%
(
storageDirectory
,
experimentName
))
self
.
logger
.
debug
(
'
Creating data directory for experiment %s: %s
'
%
(
experimentName
,
storageDirectory
))
else
:
OsUtility
.
createDir
(
storageDirectory
)
self
.
logger
.
debug
(
'
Creating data directory for experiment %s: %s
'
%
(
experimentName
,
storageDirectory
))
experiment
[
'
storageDirectory
'
]
=
storageDirectory
OsUtility
.
createDir
(
storageDirectory
)
experiment
[
'
storageHost
'
]
=
ConfigurationManager
.
getInstance
().
getHost
()
experiment
[
'
storageDirectory
'
]
=
storageDirectory
finally
:
self
.
lock
.
release
()
@ThreadingUtility.synchronize
def
start
(
self
):
def
start
(
self
):
self
.
lock
.
acquire
()
self
.
logger
.
debug
(
'
Started storage manager
'
)
try
:
self
.
logger
.
debug
(
'
Started storage manager
'
)
finally
:
self
.
lock
.
release
()
@ThreadingUtility.synchronize
def
stop
(
self
):
def
stop
(
self
):
self
.
lock
.
acquire
()
self
.
logger
.
debug
(
'
Stopped storage manager
'
)
try
:
self
.
logger
.
debug
(
'
Stopped storage manager
'
)
finally
:
self
.
lock
.
release
()
####################################################################
####################################################################
# Testing
# Testing
...
...
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