else:
yield Account(ownerid, pubkey_vs,
self.storage_server, self._leasedb)
+
+ def get_total_leased_sharecount_and_used_space(self):
+ return self._leasedb.get_total_leased_sharecount_and_used_space()
+
+ def get_number_of_sharesets(self):
+ return self._leasedb.get_number_of_sharesets()
self._cursor.execute("SELECT `id`,`pubkey_vs`"
" FROM `accounts` ORDER BY `id` ASC")
return self._cursor.fetchall()
+
+ def get_total_leased_sharecount_and_used_space(self):
+ self._cursor.execute("SELECT COUNT(*), SUM(`used_space`)"
+ " FROM (SELECT `used_space`"
+ " FROM `shares` s JOIN `leases` l"
+ " ON (s.`storage_index` = l.`storage_index` AND s.`shnum` = l.`shnum`)"
+ " GROUP BY s.`storage_index`, s.`shnum`)")
+ share_count, used_space = self._cursor.fetchall()[0]
+ if share_count == 0 and used_space is None:
+ used_space = 0
+ return share_count, used_space
+
+ def get_number_of_sharesets(self):
+ self._cursor.execute("SELECT COUNT(DISTINCT `storage_index`) AS si_num FROM `shares`")
+ return self._cursor.fetchall()[0][0]
self.backend.fill_in_space_stats(stats)
- if self.bucket_counter:
- s = self.bucket_counter.get_state()
- bucket_count = s.get("last-complete-bucket-count")
- if bucket_count:
- stats['storage_server.total_bucket_count'] = bucket_count
+ sharecount = self.accountant.get_number_of_sharesets()
+ leased_share_count, leased_used_space = self.accountant.get_total_leased_sharecount_and_used_space()
+ stats['storage_server.total_bucket_count'] = sharecount
+ stats["storage_server.total_leased_sharecount"] = leased_share_count
+ stats["storage_server.total_leased_used_space"] = leased_used_space
return stats
def get_available_space(self):