VolumeClusterCacheDataPoint::VolumeClusterCacheDataPoint(const vd::VolumeId& vid)
    : id(vid.str())
{
    LOCKVD();

    cache_hits = api::getClusterCacheHits(vid);
    cache_misses = api::getClusterCacheMisses(vid);
}
events::Event
FileSystemEvents::volume_delete(const volumedriver::VolumeId& id,
                                const FrontendPath& path)
{
    events::Event ev;
    auto msg = ev.MutableExtension(events::volume_delete);

    msg->set_path(path.string());
    msg->set_name(id.str());

    return ev;
}
VolumeMetaDataStoreDataPoint::VolumeMetaDataStoreDataPoint(const vd::VolumeId& vid)
    : id(vid.str())
{
    LOCKVD();

    const vd::MetaDataStoreStats m(api::getMetaDataStoreStats(vid));

    cache_hits = m.cache_hits;
    cache_misses = m.cache_misses;
    used_clusters = m.used_clusters;
    cached_pages = m.cached_pages;
    max_pages = m.max_pages;
}
SCOCacheNamespaceDataPoint::SCOCacheNamespaceDataPoint(const vd::VolumeId& vid)
    : id(vid.str())
{
    const be::Namespace ns(id);

    LOCKVD();

    const vd::SCOCacheNamespaceInfo i(api::getVolumeSCOCacheInfo(ns));
    disposable_bytes = i.disposable;
    non_disposable_bytes = i.nondisposable;
    min_bytes = i.min;
    max_non_disposable_bytes = i.max_non_disposable;
}
events::Event
FileSystemEvents::volume_rename(const volumedriver::VolumeId& id,
                                const FrontendPath& from,
                                const FrontendPath& to)
{
    events::Event ev;
    auto msg = ev.MutableExtension(events::volume_rename);

    msg->set_old_path(from.string());
    msg->set_new_path(to.string());
    msg->set_name(id.str());

    return ev;
}