Esempio n. 1
0
DirectoryEntryPtr
MetaDataStore::rename(const ObjectId& from_parent,
                      const std::string& from,
                      const ObjectId& to_parent,
                      const std::string& to)
{
    LOG_TRACE(from << " -> " << to);

    FrontendPath from_path(find_path(from_parent));
    from_path /= from;

    FrontendPath to_path(find_path(to_parent));
    to_path /= to;

    boost::optional<DirectoryEntryPtr>
        maybe_overwritten(harakoon_.rename<DirectoryEntry>(yt::UUID(from_parent.str()),
                                                           from,
                                                           yt::UUID(to_parent.str()),
                                                           to));
    drop_from_cache(from_path);

    DirectoryEntryPtr dentry;

    if (maybe_overwritten)
    {
        drop_from_cache(to_path);
        dentry = *maybe_overwritten;
    }

    return dentry;
}
Esempio n. 2
0
void
MetaDataStore::add(const ObjectId& parent,
                   const std::string& name,
                   DirectoryEntryPtr dentry)
{
    LOG_TRACE(parent << ", dentry uuid " << dentry->object_id() << " name " << name);

    const yt::UUID p(parent.str());
    const boost::optional<DirectoryEntry> oldval;

    try
    {
        harakoon_.test_and_set(p,
                               name,
                               *dentry,
                               oldval);
    }
    catch (HierarchicalArakoon::PreconditionFailedException)
    {
        throw FileExistsException("Metadata entry already exists",
                                  name.c_str(),
                                  EEXIST);
    }

    FrontendPath path(find_path(parent));
    path /= name;

    maybe_add_to_cache_(path, dentry);
}
events::Event
FileSystemEvents::owner_changed(const ObjectId& oid,
                                const NodeId& new_owner_id)
{
    events::Event ev;
    auto msg = ev.MutableExtension(events::owner_changed);

    msg->set_name(oid.str());
    msg->set_new_owner_id(new_owner_id.str());

    return ev;
}
Esempio n. 4
0
void
MetaDataStore::unlink(const ObjectId& id,
                      const std::string& name)
{
    LOG_TRACE(id);

    FrontendPath path(find_path(id));
    path /= name;

    harakoon_.erase(yt::UUID(id.str()), name);
    drop_from_cache(path);
}
Esempio n. 5
0
FrontendPath
MetaDataStore::find_path(const ObjectId& id)
{
    return FrontendPath(harakoon_.get_path_by_id(yt::UUID(id.str())).str());
}