Exemplo n.º 1
0
    def _httpfetchpacks(self, fileids, fetchdata, fetchhistory):
        """Fetch packs via HTTPS using the Eden API"""
        perftrace.traceflag("http")

        # The Eden API Rust bindings require that fileids
        # be a list of tuples; lists-of-lists or generators
        # will result in a type error, so convert them here.
        fileids = [tuple(i) for i in fileids]

        dpack, hpack = self.repo.fileslog.getmutablesharedpacks()
        if fetchdata:
            self._httpfetchdata(fileids, dpack)
        if fetchhistory:
            self._httpfetchhistory(fileids, hpack)
Exemplo n.º 2
0
    def requestpacks(self, fileids, fetchdata, fetchhistory):
        self.remotecache.reconnect()

        perftrace.traceflag("packs")
        cache = self.remotecache
        fileslog = self.repo.fileslog

        total = len(fileids)
        totalfetches = 0
        if fetchdata:
            totalfetches += total
        if fetchhistory:
            totalfetches += total
        with progress.bar(self.ui,
                          _("fetching from memcache"),
                          total=totalfetches) as prog:
            # generate `get` keys and make data request
            getkeys = [file + "\0" + node for file, node in fileids]
            if fetchdata:
                cache.getdatapack(getkeys)
            if fetchhistory:
                cache.gethistorypack(getkeys)

            # receive both data and history
            misses = []
            try:
                allmisses = set()
                if fetchdata:
                    allmisses.update(cache.receive(prog))
                    fileslog.contentstore.markforrefresh()
                if fetchhistory:
                    allmisses.update(cache.receive(prog))
                    fileslog.metadatastore.markforrefresh()

                misses = [key.split("\0") for key in allmisses]
                perftrace.tracevalue("Memcache Misses", len(misses))
            except CacheConnectionError:
                misses = fileids
                self.ui.warn(
                    _("warning: cache connection closed early - " +
                      "falling back to server\n"))

            global fetchmisses
            missedfiles = len(misses)
            fetchmisses += missedfiles

            fromcache = total - missedfiles
            self.ui.log(
                "remotefilelog",
                "remote cache hit rate is %r of %r\n",
                fromcache,
                total,
                hit=fromcache,
                total=total,
            )

        oldumask = os.umask(0o002)
        try:
            # receive cache misses from master
            if missedfiles > 0:
                self._fetchpackfiles(misses, fetchdata, fetchhistory)
        finally:
            os.umask(oldumask)