mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-01 00:45:52 +00:00
helper: add stats for the gatherer, show some on the webish welcome page
This commit is contained in:
parent
9b3a32d0b3
commit
36f5c025a6
@ -456,7 +456,7 @@ class LocalCiphertextReader(AskUntilSuccessMixin):
|
|||||||
|
|
||||||
|
|
||||||
class Helper(Referenceable, service.MultiService):
|
class Helper(Referenceable, service.MultiService):
|
||||||
implements(interfaces.RIHelper)
|
implements(interfaces.RIHelper, interfaces.IStatsProducer)
|
||||||
# this is the non-distributed version. When we need to have multiple
|
# this is the non-distributed version. When we need to have multiple
|
||||||
# helpers, this object will become the HelperCoordinator, and will query
|
# helpers, this object will become the HelperCoordinator, and will query
|
||||||
# the farm of Helpers to see if anyone has the storage_index of interest,
|
# the farm of Helpers to see if anyone has the storage_index of interest,
|
||||||
@ -473,14 +473,45 @@ class Helper(Referenceable, service.MultiService):
|
|||||||
fileutil.make_dirs(self._chk_incoming)
|
fileutil.make_dirs(self._chk_incoming)
|
||||||
fileutil.make_dirs(self._chk_encoding)
|
fileutil.make_dirs(self._chk_encoding)
|
||||||
self._active_uploads = {}
|
self._active_uploads = {}
|
||||||
|
self._stats = {"CHK_upload_requests": 0,
|
||||||
|
"CHK_upload_already_present": 0,
|
||||||
|
"CHK_upload_need_upload": 0,
|
||||||
|
}
|
||||||
service.MultiService.__init__(self)
|
service.MultiService.__init__(self)
|
||||||
|
|
||||||
|
def setServiceParent(self, parent):
|
||||||
|
service.MultiService.setServiceParent(self, parent)
|
||||||
|
stats = parent.stats_provider
|
||||||
|
if stats:
|
||||||
|
stats.register_producer(self)
|
||||||
|
|
||||||
|
def get_stats(self):
|
||||||
|
chk_incoming_files, chk_incoming_size = 0,0
|
||||||
|
chk_encoding_files, chk_encoding_size = 0,0
|
||||||
|
for fn in os.listdir(self._chk_incoming):
|
||||||
|
size = os.stat(os.path.join(self._chk_incoming, fn))[stat.ST_SIZE]
|
||||||
|
chk_incoming_files += 1
|
||||||
|
chk_incoming_size += 1
|
||||||
|
for fn in os.listdir(self._chk_encoding):
|
||||||
|
size = os.stat(os.path.join(self._chk_encoding, fn))[stat.ST_SIZE]
|
||||||
|
chk_encoding_files += 1
|
||||||
|
chk_encoding_size += 1
|
||||||
|
stats = {"CHK_active_uploads": len(self._active_uploads),
|
||||||
|
"CHK_incoming_files": chk_incoming_files,
|
||||||
|
"CHK_incoming_size": chk_incoming_size,
|
||||||
|
"CHK_encoding_files": chk_encoding_files,
|
||||||
|
"CHK_encoding_size": chk_encoding_size,
|
||||||
|
}
|
||||||
|
stats.update(self._stats)
|
||||||
|
return {"helper": stats}
|
||||||
|
|
||||||
def log(self, *args, **kwargs):
|
def log(self, *args, **kwargs):
|
||||||
if 'facility' not in kwargs:
|
if 'facility' not in kwargs:
|
||||||
kwargs['facility'] = "tahoe.helper"
|
kwargs['facility'] = "tahoe.helper"
|
||||||
return self.parent.log(*args, **kwargs)
|
return self.parent.log(*args, **kwargs)
|
||||||
|
|
||||||
def remote_upload_chk(self, storage_index):
|
def remote_upload_chk(self, storage_index):
|
||||||
|
self._stats["CHK_upload_requests"] += 1
|
||||||
r = upload.UploadResults()
|
r = upload.UploadResults()
|
||||||
started = time.time()
|
started = time.time()
|
||||||
si_s = storage.si_b2a(storage_index)
|
si_s = storage.si_b2a(storage_index)
|
||||||
@ -498,9 +529,11 @@ class Helper(Referenceable, service.MultiService):
|
|||||||
r.timings['existence_check'] = elapsed
|
r.timings['existence_check'] = elapsed
|
||||||
if already_present:
|
if already_present:
|
||||||
# the necessary results are placed in the UploadResults
|
# the necessary results are placed in the UploadResults
|
||||||
|
self._stats["CHK_upload_already_present"] += 1
|
||||||
self.log("file already found in grid", parent=lp)
|
self.log("file already found in grid", parent=lp)
|
||||||
return (r, None)
|
return (r, None)
|
||||||
|
|
||||||
|
self._stats["CHK_upload_need_upload"] += 1
|
||||||
# the file is not present in the grid, by which we mean there are
|
# the file is not present in the grid, by which we mean there are
|
||||||
# less than 'N' shares available.
|
# less than 'N' shares available.
|
||||||
self.log("unable to find file in the grid", parent=lp,
|
self.log("unable to find file in the grid", parent=lp,
|
||||||
|
@ -58,6 +58,7 @@ class FakeClient(service.MultiService):
|
|||||||
"n": 100,
|
"n": 100,
|
||||||
"max_segment_size": 1*MiB,
|
"max_segment_size": 1*MiB,
|
||||||
}
|
}
|
||||||
|
stats_provider = None
|
||||||
def log(self, *args, **kwargs):
|
def log(self, *args, **kwargs):
|
||||||
return log.msg(*args, **kwargs)
|
return log.msg(*args, **kwargs)
|
||||||
def get_encoding_parameters(self):
|
def get_encoding_parameters(self):
|
||||||
|
@ -20,7 +20,7 @@ Downloads</a></div>
|
|||||||
<div>My nodeid: <span n:render="string" n:data="my_nodeid" /></div>
|
<div>My nodeid: <span n:render="string" n:data="my_nodeid" /></div>
|
||||||
<div>My versions: <span n:render="string" n:data="version" /></div>
|
<div>My versions: <span n:render="string" n:data="version" /></div>
|
||||||
<div>Tahoe code imported from: <span n:render="string" n:data="import_path" /></div>
|
<div>Tahoe code imported from: <span n:render="string" n:data="import_path" /></div>
|
||||||
<div>My Storage Server: <span n:render="string" n:data="storage" /></div>
|
<div n:render="services">Services Running:</div>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
@ -1452,17 +1452,30 @@ class Root(rend.Page):
|
|||||||
return str(allmydata)
|
return str(allmydata)
|
||||||
def data_my_nodeid(self, ctx, data):
|
def data_my_nodeid(self, ctx, data):
|
||||||
return idlib.nodeid_b2a(IClient(ctx).nodeid)
|
return idlib.nodeid_b2a(IClient(ctx).nodeid)
|
||||||
def data_storage(self, ctx, data):
|
|
||||||
|
def render_services(self, ctx, data):
|
||||||
|
ul = T.ul()
|
||||||
client = IClient(ctx)
|
client = IClient(ctx)
|
||||||
try:
|
try:
|
||||||
ss = client.getServiceNamed("storage")
|
ss = client.getServiceNamed("storage")
|
||||||
|
allocated_s = abbreviate_size(ss.allocated_size())
|
||||||
|
allocated = "about %s allocated" % allocated_s
|
||||||
|
sizelimit = "no size limit"
|
||||||
|
if ss.sizelimit is not None:
|
||||||
|
sizelimit = "size limit is %s" % abbreviate_size(ss.sizelimit)
|
||||||
|
ul[T.li["Storage Server: %s, %s" % (allocated, sizelimit)]]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return "Not running"
|
ul[T.li["Not running storage server"]]
|
||||||
allocated = "about %s allocated" % abbreviate_size(ss.allocated_size())
|
|
||||||
sizelimit = "no size limit"
|
try:
|
||||||
if ss.sizelimit is not None:
|
h = client.getServiceNamed("helper")
|
||||||
sizelimit = "size limit is %s" % abbreviate_size(ss.sizelimit)
|
stats = h.get_stats()
|
||||||
return "%s, %s" % (allocated, sizelimit)
|
active_uploads = stats["helper"]["CHK_active_uploads"]
|
||||||
|
ul[T.li["Helper: %d active uploads" % (active_uploads,)]]
|
||||||
|
except KeyError:
|
||||||
|
ul[T.li["Not running helper"]]
|
||||||
|
|
||||||
|
return ctx.tag[ul]
|
||||||
|
|
||||||
def data_introducer_furl(self, ctx, data):
|
def data_introducer_furl(self, ctx, data):
|
||||||
return IClient(ctx).introducer_furl
|
return IClient(ctx).introducer_furl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user