Merge pull request #253 from mmichal10/stats-refactor

Stats builder for ioclasses
This commit is contained in:
Michal Rakowski
2019-09-10 14:56:26 +02:00
committed by GitHub
25 changed files with 832 additions and 534 deletions

View File

@@ -25,7 +25,7 @@ from .data import Data
from .io import Io, IoDir
from .queue import Queue
from .shared import Uuid, OcfCompletion, OcfError, SeqCutOffPolicy
from .stats.core import CoreStats
from .stats.core import CoreInfo
from .stats.shared import UsageStats, RequestsStats, BlocksStats, ErrorsStats
from .volume import Volume
from ..ocf import OcfLib
@@ -111,7 +111,7 @@ class Core:
return Io.from_pointer(io)
def get_stats(self):
core_stats = CoreStats()
core_info = CoreInfo()
usage = UsageStats()
req = RequestsStats()
blocks = BlocksStats()
@@ -125,8 +125,8 @@ class Core:
self.cache.read_unlock()
raise OcfError("Failed collecting core stats", status)
status = self.cache.owner.lib.ocf_core_get_stats(
self.handle, byref(core_stats)
status = self.cache.owner.lib.ocf_core_get_info(
self.handle, byref(core_info)
)
if status:
self.cache.read_unlock()
@@ -134,10 +134,10 @@ class Core:
self.cache.read_unlock()
return {
"size": Size(core_stats.core_size_bytes),
"dirty_for": timedelta(seconds=core_stats.dirty_for),
"seq_cutoff_policy": SeqCutOffPolicy(core_stats.seq_cutoff_policy),
"seq_cutoff_threshold": core_stats.seq_cutoff_threshold,
"size": Size(core_info.core_size_bytes),
"dirty_for": timedelta(seconds=core_info.dirty_for),
"seq_cutoff_policy": SeqCutOffPolicy(core_info.seq_cutoff_policy),
"seq_cutoff_threshold": core_info.seq_cutoff_threshold,
"usage": struct_to_dict(usage),
"req": struct_to_dict(req),
"blocks": struct_to_dict(blocks),
@@ -207,8 +207,8 @@ lib.ocf_mngt_core_set_seq_cutoff_policy.argtypes = [c_void_p, c_uint32]
lib.ocf_mngt_core_set_seq_cutoff_policy.restype = c_int
lib.ocf_stats_collect_core.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p, c_void_p]
lib.ocf_stats_collect_core.restype = c_int
lib.ocf_core_get_stats.argtypes = [c_void_p, c_void_p]
lib.ocf_core_get_stats.restype = c_int
lib.ocf_core_get_info.argtypes = [c_void_p, c_void_p]
lib.ocf_core_get_info.restype = c_int
lib.ocf_core_new_io_wrapper.argtypes = [
c_void_p,
c_void_p,

View File

@@ -9,22 +9,13 @@ from ctypes import c_uint32, c_uint64, Structure
from .shared import OcfStatsReq, OcfStatsBlock, OcfStatsDebug, OcfStatsError
class CoreStats(Structure):
class CoreInfo(Structure):
_fields_ = [
("core_size", c_uint64),
("core_size_bytes", c_uint64),
("cache_occupancy", c_uint32),
("dirty", c_uint32),
("flushed", c_uint32),
("dirty_for", c_uint32),
("read_reqs", OcfStatsReq),
("write_reqs", OcfStatsReq),
("cache_volume", OcfStatsBlock),
("core_volume", OcfStatsBlock),
("core", OcfStatsBlock),
("cache_errors", OcfStatsError),
("core_errors", OcfStatsError),
("debug_stat", OcfStatsDebug),
("seq_cutoff_threshold", c_uint32),
("seq_cutoff_policy", c_uint32),
]