from twisted.application import service
from twisted.application.internet import TimerService
from zope.interface import implements
-import foolscap
-from foolscap.eventual import eventually
-from twisted.internet.error import ConnectionDone, ConnectionLost
-from foolscap import DeadReferenceError
+from foolscap.api import eventually, DeadReferenceError, Referenceable, Tub
from allmydata.util import log
+from allmydata.util.encodingutil import quote_output
from allmydata.interfaces import RIStatsProvider, RIStatsGatherer, IStatsProducer
class LoadMonitor(service.MultiService):
return s
-class StatsProvider(foolscap.Referenceable, service.MultiService):
+class StatsProvider(Referenceable, service.MultiService):
implements(RIStatsProvider)
def __init__(self, node, gatherer_furl):
gatherer.callRemoteOnly('provide', self, nickname or '')
-class StatsGatherer(foolscap.Referenceable, service.MultiService):
+class StatsGatherer(Referenceable, service.MultiService):
implements(RIStatsGatherer)
poll_interval = 60
self.timer.setServiceParent(self)
def get_tubid(self, rref):
- return foolscap.SturdyRef(rref.tracker.getURL()).getTubRef().getTubID()
+ return rref.getRemoteTubID()
def remote_provide(self, provider, nickname):
tubid = self.get_tubid(provider)
# this is called lazily, when a get_stats request fails
del self.clients[tubid]
del self.nicknames[tubid]
- f.trap(DeadReferenceError, ConnectionDone, ConnectionLost)
+ f.trap(DeadReferenceError)
def log_client_error(self, f, tubid):
log.msg("StatsGatherer: error in get_stats(), peerid=%s" % tubid,
if os.path.exists(self.picklefile):
f = open(self.picklefile, 'rb')
- self.gathered_stats = pickle.load(f)
+ try:
+ self.gathered_stats = pickle.load(f)
+ except Exception:
+ print ("Error while attempting to load pickle file %s.\nYou may need to delete this file.\n" %
+ quote_output(os.path.abspath(self.picklefile)))
+ raise
f.close()
else:
self.gathered_stats = {}
def __init__(self, basedir=".", verbose=False):
service.MultiService.__init__(self)
self.basedir = basedir
- self.tub = foolscap.Tub(certFile=os.path.join(self.basedir,
- "stats_gatherer.pem"))
+ self.tub = Tub(certFile=os.path.join(self.basedir,
+ "stats_gatherer.pem"))
self.tub.setServiceParent(self)
self.tub.setOption("logLocalFailures", True)
self.tub.setOption("logRemoteFailures", True)
+ self.tub.setOption("expose-remote-exception-types", False)
self.stats_gatherer = PickleStatsGatherer(self.basedir, verbose)
self.stats_gatherer.setServiceParent(self)