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
b8cdfa88
Commit
b8cdfa88
authored
9 years ago
by
sveseli
Browse files
Options
Downloads
Patches
Plain Diff
optimized detection of existing files
parent
56efec33
No related branches found
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/python/dm/common/processing/plugins/gridftpFileTransferPlugin.py
+25
-20
25 additions, 20 deletions
...dm/common/processing/plugins/gridftpFileTransferPlugin.py
src/python/dm/common/utility/ftpUtility.py
+3
-0
3 additions, 0 deletions
src/python/dm/common/utility/ftpUtility.py
with
28 additions
and
20 deletions
src/python/dm/common/processing/plugins/gridftpFileTransferPlugin.py
+
25
−
20
View file @
b8cdfa88
#!/usr/bin/env python
#!/usr/bin/env python
import
os
import
os
import
copy
from
fileTransferPlugin
import
FileTransferPlugin
from
fileTransferPlugin
import
FileTransferPlugin
from
dm.common.utility.fileUtility
import
FileUtility
from
dm.common.utility.fileUtility
import
FileUtility
from
dm.common.utility.ftpUtility
import
FtpUtility
from
dm.common.utility.ftpUtility
import
FtpUtility
...
@@ -48,27 +49,31 @@ class GridftpFileTransferPlugin(FileTransferPlugin):
...
@@ -48,27 +49,31 @@ class GridftpFileTransferPlugin(FileTransferPlugin):
(
scheme
,
host
,
port
,
replacementDirPath
)
=
FtpUtility
.
parseFtpUrl
(
dataDirectory
)
(
scheme
,
host
,
port
,
replacementDirPath
)
=
FtpUtility
.
parseFtpUrl
(
dataDirectory
)
ftpUtility
=
SftpUtility
(
storageHost
)
ftpUtility
=
SftpUtility
(
storageHost
)
storageFilePathsDict
=
ftpUtility
.
getFiles
(
storageDirectory
,
{},
replacementDirPath
)
storageFilePathsDict
=
ftpUtility
.
getFiles
(
storageDirectory
,
{},
replacementDirPath
)
pluginFilePathsDict
=
{}
pluginFilePathsDict
=
copy
.
copy
(
filePathsDict
)
filePaths
=
filePathsDict
.
keys
()
# Remove file from plugin dict if we do not need to transfer it
for
filePath
in
filePaths
:
for
(
filePath
,
storageFilePathDict
)
in
storageFilePathsDict
.
items
()
:
filePathDict
=
filePathsDict
.
get
(
filePath
)
filePathDict
=
filePathsDict
.
get
(
filePath
)
storageFilePathDict
=
storageFilePathsDict
.
get
(
filePath
)
if
filePathDict
is
None
:
# We are not attempting to transfer this file
if
not
storageFilePathDict
:
# No need to change plugin file dict
# remote directory does not have the file
continue
pluginFilePathsDict
[
filePath
]
=
filePathDict
else
:
# Check size
fSize
=
filePathDict
.
get
(
'
fileSize
'
)
fSize
=
filePathDict
.
get
(
'
fileSize
'
)
sfSize
=
storageFilePathDict
.
get
(
'
fileSize
'
)
sfSize
=
storageFilePathDict
.
get
(
'
fileSize
'
)
# check size
if
not
fSize
or
not
sfSize
or
fSize
!=
sfSize
:
if
not
fSize
or
not
sfSize
or
fSize
!=
sfSize
:
# Sizes differ, need to transfer file
pluginFilePathsDict
[
filePath
]
=
filePathDict
continue
else
:
# sizes are the same, check modify time
# Sizes are the same, check modify time
mTime
=
filePathDict
.
get
(
'
fileModificationTime
'
)
mTime
=
filePathDict
.
get
(
'
fileModificationTime
'
)
smTime
=
storageFilePathDict
.
get
(
'
fileModificationTime
'
)
smTime
=
storageFilePathDict
.
get
(
'
fileModificationTime
'
)
if
not
mTime
or
not
smTime
or
mTime
>
smTime
:
if
not
mTime
or
not
smTime
or
mTime
>
smTime
:
pluginFilePathsDict
[
filePath
]
=
filePathDict
# Source time is later than storage time, need to transfer file
continue
# No need to transfer file
del
pluginFilePathsDict
[
filePath
]
self
.
logger
.
debug
(
'
Number of original files: %s, number of plugin files: %s
'
,
len
(
filePathsDict
),
len
(
pluginFilePathsDict
))
self
.
logger
.
debug
(
'
Number of original files: %s, number of plugin files: %s
'
,
len
(
filePathsDict
),
len
(
pluginFilePathsDict
))
return
pluginFilePathsDict
return
pluginFilePathsDict
...
...
This diff is collapsed.
Click to expand it.
src/python/dm/common/utility/ftpUtility.py
+
3
−
0
View file @
b8cdfa88
...
@@ -143,3 +143,6 @@ if __name__ == '__main__':
...
@@ -143,3 +143,6 @@ if __name__ == '__main__':
print
files
print
files
print
ftpUtility
.
getMd5Sum
(
'
/export/8-id-i/test/testfile01
'
)
print
ftpUtility
.
getMd5Sum
(
'
/export/8-id-i/test/testfile01
'
)
print
ftpUtility
.
statFile
(
'
/export/8-id-i/test/testfile01
'
)
print
ftpUtility
.
statFile
(
'
/export/8-id-i/test/testfile01
'
)
#ftpUtility = FtpUtility('xstor-devel', 22)
#files = ftpUtility.getFiles('/data/testing')
#print files
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