/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/request.py

  • Committer: John Arbash Meinel
  • Date: 2009-12-11 21:45:27 UTC
  • mto: (4896.1.3 2.1.0b4-dev)
  • mto: This revision was merged to the branch mainline in revision 4898.
  • Revision ID: john@arbash-meinel.com-20091211214527-7c7yzh15spl8o8d3
Make -Dhpss log debug information for the server process.

hpssdetail will dump individual chunk information, and hpss will
dump information about every request made, and the basic response info.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
from bzrlib import (
38
38
    bzrdir,
 
39
    debug,
39
40
    errors,
 
41
    osutils,
40
42
    registry,
41
43
    revision,
42
44
    trace,
287
289
        self.response = None
288
290
        self.finished_reading = False
289
291
        self._command = None
 
292
        if 'hpss' in debug.debug_flags:
 
293
            self._request_start_time = osutils.timer_func()
 
294
            self._thread_id = threading.currentThread().ident
 
295
 
 
296
    def _trace(self, action, message, extra_bytes=None, suppress_time=False):
 
297
        if suppress_time:
 
298
            t = ''
 
299
        else:
 
300
            t = '%5.3fs ' % (osutils.timer_func() - self._request_start_time)
 
301
        if extra_bytes is None:
 
302
            extra = ''
 
303
        else:
 
304
            extra = ' ' + repr(extra_bytes[:40])
 
305
            if len(extra) > 33:
 
306
                extra = extra[:29] + extra[-1] + '...'
 
307
        trace.mutter('%12s: [%s] %s%s%s'
 
308
                     % (action, self._thread_id, t, message, extra))
290
309
 
291
310
    def accept_body(self, bytes):
292
311
        """Accept body data."""
294
313
            # no active command object, so ignore the event.
295
314
            return
296
315
        self._run_handler_code(self._command.do_chunk, (bytes,), {})
 
316
        if 'hpss' in debug.debug_flags:
 
317
            self._trace('accept body',
 
318
                        '%d bytes' % (len(bytes),), bytes)
297
319
 
298
320
    def end_of_body(self):
299
321
        """No more body data will be received."""
300
322
        self._run_handler_code(self._command.do_end, (), {})
301
323
        # cannot read after this.
302
324
        self.finished_reading = True
 
325
        if 'hpss' in debug.debug_flags:
 
326
            self._trace('end of body', '')
303
327
 
304
328
    def _run_handler_code(self, callable, args, kwargs):
305
329
        """Run some handler specific code 'callable'.
334
358
 
335
359
    def headers_received(self, headers):
336
360
        # Just a no-op at the moment.
337
 
        pass
 
361
        if 'hpss' in debug.debug_flags:
 
362
            self._trace('headers', repr(headers))
338
363
 
339
364
    def args_received(self, args):
340
365
        cmd = args[0]
342
367
        try:
343
368
            command = self._commands.get(cmd)
344
369
        except LookupError:
 
370
            if 'hpss' in debug.debug_flags:
 
371
                self._trace('hpss unknown request', 
 
372
                            cmd, repr(args)[1:-1],
 
373
                            suppress_time=True)
345
374
            raise errors.UnknownSmartMethod(cmd)
 
375
        if 'hpss' in debug.debug_flags:
 
376
            from bzrlib.smart import vfs
 
377
            if issubclass(command, vfs.VfsRequest):
 
378
                action = 'hpss vfs req'
 
379
            else:
 
380
                action = 'hpss request'
 
381
            self._trace(action, 
 
382
                        '%s %s' % (cmd, repr(args)[1:-1]),
 
383
                        suppress_time=True)
346
384
        self._command = command(
347
385
            self._backing_transport, self._root_client_path, self._jail_root)
348
386
        self._run_handler_code(self._command.execute, args, {})
352
390
            # no active command object, so ignore the event.
353
391
            return
354
392
        self._run_handler_code(self._command.do_end, (), {})
 
393
        if 'hpss' in debug.debug_flags:
 
394
            self._trace('end', '')
355
395
 
356
396
    def post_body_error_received(self, error_args):
357
397
        # Just a no-op at the moment.