Merge lp:~facundo/ubuntuone-client/stable-1-6--configurable-two-values into lp:ubuntuone-client/stable-1-6

Proposed by Facundo Batista
Status: Merged
Approved by: Facundo Batista
Approved revision: 963
Merged at revision: 965
Proposed branch: lp:~facundo/ubuntuone-client/stable-1-6--configurable-two-values
Merge into: lp:ubuntuone-client/stable-1-6
Diff against target: 271 lines (+117/-9)
6 files modified
data/syncdaemon.conf (+9/-0)
tests/platform/linux/eventlog/test_zg_listener.py (+5/-2)
tests/syncdaemon/test_action_queue.py (+22/-4)
tests/syncdaemon/test_config.py (+50/-0)
ubuntuone/syncdaemon/action_queue.py (+11/-3)
ubuntuone/syncdaemon/config.py (+20/-0)
To merge this branch: bzr merge lp:~facundo/ubuntuone-client/stable-1-6--configurable-two-values
Reviewer Review Type Date Requested Status
dobey (community) Approve
Lucio Torre (community) Approve
Review via email: mp+59045@code.launchpad.net

Commit message

Use "simultaneous transfers" and "maximum payload size" from configuration (LP: #767466).

Description of the change

Use "simultaneous transfers" and "maximum payload size" from configuration.

"simult_transfers" moved from a code constant to a value from configuration, and "max_payload_size" is set in the protocol also from the configuration.

Added configuration for these two values, with sensible defaults; also, methods added to get and set these values.

Tests included for everything.

To post a comment you must log in.
Revision history for this message
Lucio Torre (lucio.torre) :
review: Approve
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/syncdaemon.conf'
--- data/syncdaemon.conf 2011-04-06 13:50:33 +0000
+++ data/syncdaemon.conf 2011-04-26 11:41:40 +0000
@@ -91,6 +91,15 @@
91use_trash.help = Send the files and folders to Trash folder instead of91use_trash.help = Send the files and folders to Trash folder instead of
92 removing them permanently.92 removing them permanently.
9393
94simult_transfers.default = 10
95simult_transfers.parser = int
96simult_transfers.help = Quantity of Uploads and Downloads that will be run
97 in parallel.
98
99max_payload_size.default = 1400
100max_payload_size.parser = int
101max_payload_size.help = The maximum payload for messages sent to the server.
102
94103
95[notifications]104[notifications]
96show_all_notifications.default = True105show_all_notifications.default = True
97106
=== modified file 'tests/platform/linux/eventlog/test_zg_listener.py'
--- tests/platform/linux/eventlog/test_zg_listener.py 2011-03-22 18:16:28 +0000
+++ tests/platform/linux/eventlog/test_zg_listener.py 2011-04-26 11:41:40 +0000
@@ -74,6 +74,7 @@
74from tests.syncdaemon.test_action_queue import (74from tests.syncdaemon.test_action_queue import (
75 ConnectedBaseTestCase,75 ConnectedBaseTestCase,
76 FakeSemaphore,76 FakeSemaphore,
77 TestingProtocol,
77)78)
7879
79VOLUME = uuid.UUID('12345678-1234-1234-1234-123456789abc')80VOLUME = uuid.UUID('12345678-1234-1234-1234-123456789abc')
@@ -606,7 +607,8 @@
606 cmd.handle_success(request)607 cmd.handle_success(request)
607608
608 # create a request and fill it with succesful information609 # create a request and fill it with succesful information
609 request = client.PutContent(self.action_queue.client, self.share_id,610 aq_client = TestingProtocol()
611 request = client.PutContent(aq_client, self.share_id,
610 'node', 'prvhash', 'newhash', 'crc32',612 'node', 'prvhash', 'newhash', 'crc32',
611 'size', 'deflated', 'fd')613 'size', 'deflated', 'fd')
612 request.new_generation = 13614 request.new_generation = 13
@@ -695,7 +697,8 @@
695 self.fsm.set_node_id(path, "a_node_id")697 self.fsm.set_node_id(path, "a_node_id")
696698
697 # create a request and fill it with succesful information699 # create a request and fill it with succesful information
698 request = client.PutContent(self.action_queue.client, self.share_id,700 aq_client = TestingProtocol()
701 request = client.PutContent(aq_client, self.share_id,
699 'node', 'prvhash', 'newhash', 'crc32',702 'node', 'prvhash', 'newhash', 'crc32',
700 'size', 'deflated', 'fd')703 'size', 'deflated', 'fd')
701 request.new_generation = 13704 request.new_generation = 13
702705
=== modified file 'tests/syncdaemon/test_action_queue.py'
--- tests/syncdaemon/test_action_queue.py 2011-04-12 19:46:23 +0000
+++ tests/syncdaemon/test_action_queue.py 2011-04-26 11:41:40 +0000
@@ -55,12 +55,12 @@
55 protocol_pb2,55 protocol_pb2,
56 request,56 request,
57)57)
58from ubuntuone.syncdaemon import states, interfaces58from ubuntuone.syncdaemon import states, interfaces, config
59from ubuntuone.syncdaemon import action_queue59from ubuntuone.syncdaemon import action_queue
60from ubuntuone.syncdaemon.action_queue import (60from ubuntuone.syncdaemon.action_queue import (
61 ActionQueue, ActionQueueCommand, ChangePublicAccess, CreateUDF,61 ActionQueue, ActionQueueCommand, ChangePublicAccess, CreateUDF,
62 DeleteVolume, Download, ListVolumes, ActionQueueProtocol, ListShares,62 DeleteVolume, Download, ListVolumes, ActionQueueProtocol, ListShares,
63 RequestQueue, UploadProgressWrapper, Upload, SIMULT_TRANSFERS,63 RequestQueue, UploadProgressWrapper, Upload,
64 CreateShare, DeleteShare, GetPublicFiles, GetDelta, GetDeltaFromScratch,64 CreateShare, DeleteShare, GetPublicFiles, GetDelta, GetDeltaFromScratch,
65 TRANSFER_PROGRESS_THRESHOLD, Unlink, Move, MakeFile, MakeDir, DeltaList,65 TRANSFER_PROGRESS_THRESHOLD, Unlink, Move, MakeFile, MakeDir, DeltaList,
66 ZipQueue, DeferredMap, ThrottlingStorageClient, PathLockingTree,66 ZipQueue, DeferredMap, ThrottlingStorageClient, PathLockingTree,
@@ -199,6 +199,8 @@
199class TestingProtocol(ActionQueue.protocol):199class TestingProtocol(ActionQueue.protocol):
200 """Protocol for testing."""200 """Protocol for testing."""
201201
202 max_payload_size = 65536
203
202 def connectionMade(self):204 def connectionMade(self):
203 """connectionMade."""205 """connectionMade."""
204 ActionQueue.protocol.connectionMade(self)206 ActionQueue.protocol.connectionMade(self)
@@ -722,6 +724,13 @@
722 self.rq.unqueue(cmd2)724 self.rq.unqueue(cmd2)
723 self.assertEqual(len(self.rq), 0)725 self.assertEqual(len(self.rq), 0)
724726
727 def test_init_simult_transfers(self):
728 """Configure the transfers semaphore according to config."""
729 user_config = config.get_user_config()
730 user_config.set_simult_transfers(12345)
731 rq = RequestQueue(action_queue=None)
732 self.assertEqual(rq.transfers_semaphore.tokens, 12345)
733
725734
726class TestDeferredMap(TwistedTestCase):735class TestDeferredMap(TwistedTestCase):
727 """Test the deferred map."""736 """Test the deferred map."""
@@ -3239,7 +3248,8 @@
3239 def test_handle_success_push_event(self):3248 def test_handle_success_push_event(self):
3240 """Test AQ_UPLOAD_FINISHED is pushed on success."""3249 """Test AQ_UPLOAD_FINISHED is pushed on success."""
3241 # create a request and fill it with succesful information3250 # create a request and fill it with succesful information
3242 request = client.PutContent(self.action_queue.client, VOLUME, 'node',3251 aq_client = TestingProtocol()
3252 request = client.PutContent(aq_client, VOLUME, 'node',
3243 'prvhash', 'newhash', 'crc32', 'size',3253 'prvhash', 'newhash', 'crc32', 'size',
3244 'deflated', 'fd')3254 'deflated', 'fd')
3245 request.new_generation = 133255 request.new_generation = 13
@@ -4940,6 +4950,13 @@
4940 # check also the log4950 # check also the log
4941 self.assertTrue(self.handler.check_debug('Ping! rtt: 1.123 segs'))4951 self.assertTrue(self.handler.check_debug('Ping! rtt: 1.123 segs'))
49424952
4953 def test_init_max_payload_size(self):
4954 """Configure max_payload_size on init according to config."""
4955 user_config = config.get_user_config()
4956 user_config.set_max_payload_size(12345)
4957 aqp = ActionQueueProtocol()
4958 self.assertEqual(aqp.max_payload_size, 12345)
4959
49434960
4944class CommandCycleTestCase(BasicTestCase):4961class CommandCycleTestCase(BasicTestCase):
4945 """Test the command behaviour on run, retry, stop, etc.4962 """Test the command behaviour on run, retry, stop, etc.
@@ -5363,7 +5380,8 @@
5363 # transfer semaphore in _start5380 # transfer semaphore in _start
5364 transfers_semaphore = self.queue.transfers_semaphore5381 transfers_semaphore = self.queue.transfers_semaphore
5365 semaphores = []5382 semaphores = []
5366 for i in xrange(SIMULT_TRANSFERS):5383 user_config = config.get_user_config()
5384 for i in xrange(user_config.get_simult_transfers()):
5367 s = transfers_semaphore.acquire()5385 s = transfers_semaphore.acquire()
5368 s.addCallback(semaphores.append)5386 s.addCallback(semaphores.append)
53695387
53705388
=== modified file 'tests/syncdaemon/test_config.py'
--- tests/syncdaemon/test_config.py 2011-04-13 19:23:22 +0000
+++ tests/syncdaemon/test_config.py 2011-04-26 11:41:40 +0000
@@ -428,6 +428,45 @@
428 branch_config = os.path.join(rootdir, "data", config.CONFIG_FILE)428 branch_config = os.path.join(rootdir, "data", config.CONFIG_FILE)
429 self.assertIn(branch_config, config_files)429 self.assertIn(branch_config, config_files)
430430
431 def test_get_simult_transfers(self):
432 """Get simult transfers."""
433 conf_file = os.path.join(self.test_root, 'test_load_config.conf')
434 with open(conf_file, 'w') as fh:
435 fh.write('[__main__]\n')
436 fh.write('simult_transfers = 12345\n')
437 conf = config._Config(conf_file)
438 self.assertEqual(conf.get_simult_transfers(), 12345)
439
440 def test_set_simult_transfers(self):
441 """Set simult transfers."""
442 conf_file = os.path.join(self.test_root, 'test_load_config.conf')
443 with open(conf_file, 'w') as fh:
444 fh.write('[__main__]\n')
445 fh.write('simult_transfers = 12345\n')
446 conf = config._Config(conf_file)
447 conf.set_simult_transfers(666)
448 self.assertEqual(conf.get_simult_transfers(), 666)
449
450 def test_get_max_payload_size(self):
451 """Get the maximum payload size."""
452 conf_file = os.path.join(self.test_root, 'test_load_config.conf')
453 with open(conf_file, 'w') as fh:
454 fh.write('[__main__]\n')
455 fh.write('max_payload_size = 12345\n')
456 conf = config._Config(conf_file)
457 self.assertEqual(conf.get_max_payload_size(), 12345)
458
459 def test_set_max_payload_size(self):
460 """Set the maximum payload size."""
461 conf_file = os.path.join(self.test_root, 'test_load_config.conf')
462 with open(conf_file, 'w') as fh:
463 fh.write('[__main__]\n')
464 fh.write('max_payload_size = 12345\n')
465 conf = config._Config(conf_file)
466 conf.set_max_payload_size(666)
467 self.assertEqual(conf.get_max_payload_size(), 666)
468
469
431class ConfigglueParsersTests(BaseTwistedTestCase):470class ConfigglueParsersTests(BaseTwistedTestCase):
432 """Tests for our custom configglue parsers"""471 """Tests for our custom configglue parsers"""
433472
@@ -603,3 +642,14 @@
603 self.cp.parse_all()642 self.cp.parse_all()
604 self.assertIn(r'\A\.~lock\..*#\Z',643 self.assertIn(r'\A\.~lock\..*#\Z',
605 self.cp.get('__main__', 'ignore').value)644 self.cp.get('__main__', 'ignore').value)
645
646 def test_simult_transfers(self):
647 """Test default configuration for simultaneous transfers."""
648 self.cp.parse_all()
649 self.assertEqual(self.cp.get('__main__', 'simult_transfers').value, 10)
650
651 def test_max_payload_size(self):
652 """Test default configuration for maximum payload size."""
653 self.cp.parse_all()
654 configured = self.cp.get('__main__', 'max_payload_size').value
655 self.assertEqual(configured, 1400)
606656
=== modified file 'ubuntuone/syncdaemon/action_queue.py'
--- ubuntuone/syncdaemon/action_queue.py 2011-04-12 19:46:23 +0000
+++ ubuntuone/syncdaemon/action_queue.py 2011-04-26 11:41:40 +0000
@@ -57,6 +57,7 @@
57from ubuntuone.storageprotocol.context import get_ssl_context57from ubuntuone.storageprotocol.context import get_ssl_context
58from ubuntuone.syncdaemon.interfaces import IActionQueue, IMarker58from ubuntuone.syncdaemon.interfaces import IActionQueue, IMarker
59from ubuntuone.syncdaemon.logger import mklog, TRACE59from ubuntuone.syncdaemon.logger import mklog, TRACE
60from ubuntuone.syncdaemon import config
6061
61logger = logging.getLogger("ubuntuone.SyncDaemon.ActionQueue")62logger = logging.getLogger("ubuntuone.SyncDaemon.ActionQueue")
6263
@@ -69,8 +70,6 @@
69# progress threshold to emit a download/upload progress event: 64Kb70# progress threshold to emit a download/upload progress event: 64Kb
70TRANSFER_PROGRESS_THRESHOLD = 64*1024*102471TRANSFER_PROGRESS_THRESHOLD = 64*1024*1024
7172
72# no more than this uploads are executed simultaneously
73SIMULT_TRANSFERS = 3
7473
75def passit(func):74def passit(func):
76 """Pass the value on for the next deferred, while calling func with it."""75 """Pass the value on for the next deferred, while calling func with it."""
@@ -302,6 +301,11 @@
302 _looping_ping = None301 _looping_ping = None
303 _ping_delay = 600 # 10 minutes302 _ping_delay = 600 # 10 minutes
304303
304 def __init__(self):
305 LoggingStorageClient.__init__(self)
306 user_config = config.get_user_config()
307 self.max_payload_size = user_config.get_max_payload_size()
308
305 def connectionMade(self):309 def connectionMade(self):
306 """A new connection was made."""310 """A new connection was made."""
307 self.log.info('Connection made.')311 self.log.info('Connection made.')
@@ -458,9 +462,13 @@
458 self.waiting = []462 self.waiting = []
459 self.hashed_waiting = {}463 self.hashed_waiting = {}
460 self.active = False464 self.active = False
461 self.transfers_semaphore = defer.DeferredSemaphore(SIMULT_TRANSFERS)
462 self.active_deferred = defer.Deferred()465 self.active_deferred = defer.Deferred()
463466
467 # transfers semaphore
468 user_config = config.get_user_config()
469 simult_transfers = user_config.get_simult_transfers()
470 self.transfers_semaphore = defer.DeferredSemaphore(simult_transfers)
471
464 def __len__(self):472 def __len__(self):
465 """Return the length of the waiting queue."""473 """Return the length of the waiting queue."""
466 return len(self.waiting)474 return len(self.waiting)
467475
=== modified file 'ubuntuone/syncdaemon/config.py'
--- ubuntuone/syncdaemon/config.py 2011-04-05 19:14:18 +0000
+++ ubuntuone/syncdaemon/config.py 2011-04-26 11:41:40 +0000
@@ -374,6 +374,26 @@
374 def set_use_trash(self, enabled):374 def set_use_trash(self, enabled):
375 self.set(MAIN, 'use_trash', str(enabled))375 self.set(MAIN, 'use_trash', str(enabled))
376376
377 @requires_section(MAIN)
378 def get_simult_transfers(self):
379 """Get the simultaneous transfers value."""
380 return self.get_parsed(MAIN, 'simult_transfers')
381
382 @requires_section(MAIN)
383 def set_simult_transfers(self, value):
384 """Set the simultaneous transfers value."""
385 self.set(MAIN, 'simult_transfers', str(value))
386
387 @requires_section(MAIN)
388 def get_max_payload_size(self):
389 """Get the maximum payload size."""
390 return self.get_parsed(MAIN, 'max_payload_size')
391
392 @requires_section(MAIN)
393 def set_max_payload_size(self, value):
394 """Set the maximum payload size."""
395 self.set(MAIN, 'max_payload_size', str(value))
396
377 @requires_section(NOTIFICATIONS)397 @requires_section(NOTIFICATIONS)
378 def set_show_all_notifications(self, enabled):398 def set_show_all_notifications(self, enabled):
379 self.set(NOTIFICATIONS, 'show_all_notifications', str(enabled))399 self.set(NOTIFICATIONS, 'show_all_notifications', str(enabled))

Subscribers

People subscribed via source and target branches