~ubuntu-branches/ubuntu/trusty/swift/trusty-updates

« back to all changes in this revision

Viewing changes to swift/obj/replicator.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-01-28 09:40:30 UTC
  • mfrom: (1.2.16)
  • Revision ID: package-import@ubuntu.com-20130128094030-aetz57x2qz9ye2d4
Tags: 1.7.6-0ubuntu1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
from swift.common.ring import Ring
34
34
from swift.common.utils import whataremyips, unlink_older_than, lock_path, \
35
35
    compute_eta, get_logger, write_pickle, renamer, dump_recon_cache, \
36
 
    rsync_ip, mkdirs, config_true_value, list_from_csv
 
36
    rsync_ip, mkdirs, config_true_value, list_from_csv, get_hub
37
37
from swift.common.bufferedhttp import http_connect
38
38
from swift.common.daemon import Daemon
39
39
from swift.common.http import HTTP_OK, HTTP_INSUFFICIENT_STORAGE
40
40
from swift.common.exceptions import PathNotDir
41
41
 
42
 
hubs.use_hub('poll')
 
42
hubs.use_hub(get_hub())
43
43
 
44
44
PICKLE_PROTOCOL = 2
45
45
ONE_WEEK = 604800
176
176
    hashed = 0
177
177
    hashes_file = join(partition_dir, HASH_FILE)
178
178
    modified = False
 
179
    force_rewrite = False
179
180
    hashes = {}
180
181
    mtime = -1
181
182
    try:
184
185
        mtime = os.path.getmtime(hashes_file)
185
186
    except Exception:
186
187
        do_listdir = True
 
188
        force_rewrite = True
187
189
    if do_listdir:
188
190
        for suff in os.listdir(partition_dir):
189
191
            if len(suff) == 3:
203
205
            modified = True
204
206
    if modified:
205
207
        with lock_path(partition_dir):
206
 
            if not os.path.exists(hashes_file) or \
 
208
            if force_rewrite or not os.path.exists(hashes_file) or \
207
209
                    os.path.getmtime(hashes_file) == mtime:
208
210
                write_pickle(
209
211
                    hashes, hashes_file, partition_dir, PICKLE_PROTOCOL)
562
564
                continue
563
565
            unlink_older_than(tmp_path, time.time() - self.reclaim_age)
564
566
            if not os.path.exists(obj_path):
565
 
                mkdirs(obj_path)
 
567
                try:
 
568
                    mkdirs(obj_path)
 
569
                except Exception, err:
 
570
                    self.logger.exception('ERROR creating %s' % obj_path)
566
571
                continue
567
572
            for partition in os.listdir(obj_path):
568
573
                try:
645
650
        self.logger.info(
646
651
            _("Object replication complete (once). (%.02f minutes)"), total)
647
652
        if not (override_partitions or override_devices):
648
 
            dump_recon_cache({'object_replication_time': total},
 
653
            dump_recon_cache({'object_replication_time': total,
 
654
                              'object_replication_last': time.time()},
649
655
                             self.rcache, self.logger)
650
656
 
651
657
    def run_forever(self, *args, **kwargs):
659
665
            total = (time.time() - start) / 60
660
666
            self.logger.info(
661
667
                _("Object replication complete. (%.02f minutes)"), total)
662
 
            dump_recon_cache({'object_replication_time': total},
 
668
            dump_recon_cache({'object_replication_time': total,
 
669
                              'object_replication_last': time.time()},
663
670
                             self.rcache, self.logger)
664
671
            self.logger.debug(_('Replication sleeping for %s seconds.'),
665
672
                              self.run_pause)