Skip to content

Commit e0a4bed

Browse files
authored
[CORE-4489 ]Snappy compression enabled to reduce Network usage by mongodump support version above and including 4.2.0 (#10)
- Mongo Consistent Backup will now use --compressor option snappy by default for version above and including 4.2.0 - using mongodump 100.6.1 - improved version comparison using looseversion library rather using tuple
1 parent 4adb3cd commit e0a4bed

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

Diff for: .circleci/config.yml

+2-8
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,12 @@ jobs:
2727

2828
environment:
2929
PYTHON_BIN: /usr/local/bin/python2.7
30+
3031
working_directory: ~/repo
3132

3233
steps:
3334
- checkout
34-
35-
# Download and cache dependencies
36-
- restore_cache:
37-
keys:
38-
- v1-dependencies-{{ checksum "requirements.txt" }}
39-
# fallback to using the latest cache if no exact match is found
40-
- v1-dependencies-
41-
35+
4236
- run:
4337
name: set version and build the rpm
4438
command: |

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ tmp
44
*.pyc
55
.idea
66
*.iml
7+
.history*
8+
venv*
9+
.local*

Diff for: VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.1
1+
1.4.2

Diff for: mongodb_consistent_backup/Backup/Mongodump/MongodumpThread.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import logging
44
import sys
5+
from distutils.version import LooseVersion
56

67
from multiprocessing import Process
78
from select import select
@@ -73,7 +74,7 @@ def do_ssl_insecure(self):
7374

7475
def is_version_gte(self, compare):
7576
if os.path.isfile(self.binary) and os.access(self.binary, os.X_OK):
76-
if tuple(compare.split(".")) <= tuple(self.version.split(".")):
77+
if LooseVersion(compare) <= LooseVersion(self.version):
7778
return True
7879
return False
7980

@@ -168,6 +169,12 @@ def mongodump_cmd(self):
168169
mongodump_flags.extend([
169170
"--out=%s/dump" % self.backup_dir
170171
])
172+
if self.is_version_gte("4.2.0"):
173+
logging.info("MongoDump Version higher that 4.2.0 found extending mongodump with snppy compressor flag")
174+
## https://www.mongodb.com/docs/drivers/node/v4.4/fundamentals/connection/network-compression/
175+
mongodump_flags.extend([
176+
"--compressors=%s" % "snappy,zlib,zstd"
177+
])
171178

172179
# --numParallelCollections
173180
if self.threads > 0:
@@ -222,6 +229,7 @@ def mongodump_cmd(self):
222229
sys.exit(1)
223230

224231
mongodump_cmd.extend(mongodump_flags)
232+
logging.info("-----mongodump_cmd: %s" % mongodump_cmd)
225233
return mongodump_cmd
226234

227235
def run(self):

Diff for: scripts/build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ if [ -d ${srcdir} ]; then
109109
exit 1
110110
fi
111111

112-
# build fails on Pex 1.5+
113-
${venvdir}/bin/python2.7 ${venvdir}/bin/pip install ${pip_flags} "pex<=1.4"
112+
# build work with pex<=2.1.120 as of 23 feb 2023
113+
${venvdir}/bin/python2.7 ${venvdir}/bin/pip install ${pip_flags} "pex<=2.1.120"
114114
if [ $? -gt 0 ]; then
115115
echo "Failed to install pex utility for building!"
116116
exit 1

0 commit comments

Comments
 (0)