/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/smart/medium.py

  • Committer: Robert Collins
  • Date: 2009-05-23 20:57:12 UTC
  • mfrom: (4371 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4441.
  • Revision ID: robertc@robertcollins.net-20090523205712-lcwbfqk6vwavinuv
MergeĀ .dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""The 'medium' layer for the smart servers and clients.
18
18
 
43
43
    ui,
44
44
    urlutils,
45
45
    )
46
 
from bzrlib.smart import client, protocol
 
46
from bzrlib.smart import client, protocol, request, vfs
47
47
from bzrlib.transport import ssh
48
48
""")
49
49
 
381
381
    def accept_bytes(self, bytes):
382
382
        """Accept bytes for inclusion in this request.
383
383
 
384
 
        This method may not be be called after finished_writing() has been
 
384
        This method may not be called after finished_writing() has been
385
385
        called.  It depends upon the Medium whether or not the bytes will be
386
386
        immediately transmitted. Message based Mediums will tend to buffer the
387
387
        bytes until finished_writing() is called.
509
509
        """
510
510
        medium_repr = repr(medium)
511
511
        # Add this medium to the WeakKeyDictionary
512
 
        self.counts[medium] = [0, medium_repr]
 
512
        self.counts[medium] = dict(count=0, vfs_count=0,
 
513
                                   medium_repr=medium_repr)
513
514
        # Weakref callbacks are fired in reverse order of their association
514
515
        # with the referenced object.  So we add a weakref *after* adding to
515
516
        # the WeakKeyDict so that we can report the value from it before the
519
520
    def increment_call_count(self, params):
520
521
        # Increment the count in the WeakKeyDictionary
521
522
        value = self.counts[params.medium]
522
 
        value[0] += 1
 
523
        value['count'] += 1
 
524
        request_method = request.request_handlers.get(params.method)
 
525
        if issubclass(request_method, vfs.VfsRequest):
 
526
            value['vfs_count'] += 1
523
527
 
524
528
    def done(self, ref):
525
529
        value = self.counts[ref]
526
 
        count, medium_repr = value
 
530
        count, vfs_count, medium_repr = (
 
531
            value['count'], value['vfs_count'], value['medium_repr'])
527
532
        # In case this callback is invoked for the same ref twice (by the
528
533
        # weakref callback and by the atexit function), set the call count back
529
534
        # to 0 so this item won't be reported twice.
530
 
        value[0] = 0
 
535
        value['count'] = 0
 
536
        value['vfs_count'] = 0
531
537
        if count != 0:
532
 
            trace.note('HPSS calls: %d %s', count, medium_repr)
 
538
            trace.note('HPSS calls: %d (%d vfs) %s',
 
539
                       count, vfs_count, medium_repr)
533
540
 
534
541
    def flush_all(self):
535
542
        for ref in list(self.counts.keys()):
741
748
        self._vendor = vendor
742
749
        self._write_to = None
743
750
        self._bzr_remote_path = bzr_remote_path
 
751
        # for the benefit of progress making a short description of this
 
752
        # transport
 
753
        self._scheme = 'bzr+ssh'
744
754
 
745
755
    def __repr__(self):
746
756
        return "%s(connected=%r, username=%r, host=%r, port=%r)" % (