Changeset 2c96a32 in trunk


Ignore:
Timestamp:
2008-03-27T23:46:08Z (17 years ago)
Author:
Brian Warner <warner@…>
Branches:
master
Children:
6b416fc2
Parents:
36f5c02
Message:

helper: add more stats to webapi, at /helper_status

Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/allmydata/offloaded.py

    r36f5c02 r2c96a32  
    206206        os.unlink(self._encoding_file)
    207207        self._finished_observers.fire(r)
    208         self._helper.upload_finished(self._storage_index)
     208        self._helper.upload_finished(self._storage_index, size)
    209209        del self._reader
    210210
    211211    def _failed(self, f):
    212212        self._finished_observers.fire(f)
    213         self._helper.upload_finished(self._storage_index)
     213        self._helper.upload_finished(self._storage_index, 0)
    214214        del self._reader
    215215
     
    378378                self._have += len(data)
    379379                self._ciphertext_fetched += len(data)
     380                self._upload_helper._helper._stats["CHK_fetched_bytes"] += len(data)
    380381            return False # not done
    381382        d.addCallback(_got_data)
     
    477478                       "CHK_upload_already_present": 0,
    478479                       "CHK_upload_need_upload": 0,
     480                       "CHK_fetched_bytes": 0,
     481                       "CHK_encoded_bytes": 0,
    479482                       }
    480483        service.MultiService.__init__(self)
     
    492495            size = os.stat(os.path.join(self._chk_incoming, fn))[stat.ST_SIZE]
    493496            chk_incoming_files += 1
    494             chk_incoming_size += 1
     497            chk_incoming_size += size
    495498        for fn in os.listdir(self._chk_encoding):
    496499            size = os.stat(os.path.join(self._chk_encoding, fn))[stat.ST_SIZE]
    497500            chk_encoding_files += 1
    498             chk_encoding_size += 1
     501            chk_encoding_size += size
    499502        stats = {"CHK_active_uploads": len(self._active_uploads),
    500503                 "CHK_incoming_files": chk_incoming_files,
     
    584587        return d
    585588
    586     def upload_finished(self, storage_index):
     589    def upload_finished(self, storage_index, size):
     590        self._stats["CHK_encoded_bytes"] += size
    587591        del self._active_uploads[storage_index]
  • TabularUnified src/allmydata/web/status.py

    r36f5c02 r2c96a32  
    11
    22import time
     3import simplejson
    34from twisted.internet import defer
    4 from nevow import rend, tags as T
     5from nevow import rend, inevow, tags as T
    56from allmydata.util import base32, idlib
    67from allmydata.web.common import IClient, getxmlfile, abbreviate_time, \
    7      abbreviate_rate
     8     abbreviate_rate, get_arg
    89from allmydata.interfaces import IUploadStatus, IDownloadStatus, \
    910     IPublishStatus, IRetrieveStatus
     
    761762
    762763
     764class HelperStatus(rend.Page):
     765    docFactory = getxmlfile("helper.xhtml")
     766
     767    def renderHTTP(self, ctx):
     768        t = get_arg(inevow.IRequest(ctx), "t")
     769        if t == "json":
     770            return self.render_JSON(ctx)
     771        # is there a better way to provide 'data' to all rendering methods?
     772        helper = IClient(ctx).getServiceNamed("helper")
     773        self.original = helper.get_stats()["helper"]
     774        return rend.Page.renderHTTP(self, ctx)
     775
     776    def render_JSON(self, ctx):
     777        try:
     778            h = IClient(ctx).getServiceNamed("helper")
     779        except KeyError:
     780            return simplejson.dumps({})
     781
     782        stats = h.get_stats()["helper"]
     783        return simplejson.dumps(stats, indent=1)
     784
     785    def render_active_uploads(self, ctx, data):
     786        return data["CHK_active_uploads"]
     787
     788    def render_incoming(self, ctx, data):
     789        return "%d bytes in %d files" % (data["CHK_incoming_size"],
     790                                         data["CHK_incoming_files"])
     791
     792    def render_encoding(self, ctx, data):
     793        return "%d bytes in %d files" % (data["CHK_encoding_size"],
     794                                         data["CHK_encoding_files"])
     795
     796    def render_upload_requests(self, ctx, data):
     797        return str(data["CHK_upload_requests"])
     798
     799    def render_upload_already_present(self, ctx, data):
     800        return str(data["CHK_upload_already_present"])
     801
     802    def render_upload_need_upload(self, ctx, data):
     803        return str(data["CHK_upload_need_upload"])
     804
     805    def render_upload_bytes_fetched(self, ctx, data):
     806        return str(data["CHK_fetched_bytes"])
     807
     808    def render_upload_bytes_encoded(self, ctx, data):
     809        return str(data["CHK_encoded_bytes"])
     810
  • TabularUnified src/allmydata/webish.py

    r36f5c02 r2c96a32  
    14461446    child_provisioning = provisioning.ProvisioningTool()
    14471447    child_status = status.Status()
     1448    child_helper_status = status.HelperStatus()
    14481449
    14491450    def data_version(self, ctx, data):
Note: See TracChangeset for help on using the changeset viewer.