Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hariharan/vbucket trait #64

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
634ff70
added packages
hariharan-devarajan Jan 11, 2021
0b1b359
Merge pull request #4 from HDFGroup/master
hariharan-devarajan Jan 11, 2021
f56f0e7
initial commit for adding traits infrastructure.
hariharan-devarajan Jan 11, 2021
a85b64a
added test infra.
hariharan-devarajan Jan 11, 2021
3d14fd4
added FileBackedTrait test case.
hariharan-devarajan Jan 12, 2021
8a3f7da
cpplint error
hariharan-devarajan Jan 12, 2021
3f004e9
cpplint error
hariharan-devarajan Jan 12, 2021
c7dfdf2
cpplint error
hariharan-devarajan Jan 12, 2021
7754bf9
cpplint error
hariharan-devarajan Jan 12, 2021
ad2765c
cpplint error
hariharan-devarajan Jan 12, 2021
a75f0d2
remove warnings.
hariharan-devarajan Jan 12, 2021
e82a513
remove warnings.
hariharan-devarajan Jan 12, 2021
7c20244
remove warnings.
hariharan-devarajan Jan 12, 2021
9fce890
remove warnings.
hariharan-devarajan Jan 12, 2021
e58ed55
fixed ctest
hariharan-devarajan Jan 12, 2021
2133f96
fixed the flow of operations
hariharan-devarajan Jan 13, 2021
61f0f73
remove pycache files
hariharan-devarajan Jan 13, 2021
2e5a55c
added __pycache__/ to git ignore.
hariharan-devarajan Jan 13, 2021
226fab9
added __pycache__/ to git ignore.
hariharan-devarajan Jan 13, 2021
e2170dd
added __pycache__/ to git ignore.
hariharan-devarajan Jan 13, 2021
08e9759
removed whitespace through formatting.
hariharan-devarajan Jan 13, 2021
683aae7
removed whitespace through formatting.
hariharan-devarajan Jan 13, 2021
0963cd8
changes to fix comments in the PR.
hariharan-devarajan Jan 14, 2021
8d7212b
added CATCH2 fast compile and fixed #def to prefix with HERMES_
hariharan-devarajan Jan 14, 2021
0f4b97b
added check to test flush data.
hariharan-devarajan Jan 14, 2021
0f00327
removed FIXME as it has been fixed :).
hariharan-devarajan Jan 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ GTAGS

/cmake-build-debug/
/.idea/
/.clang-format
__pycache__/
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ endif()

if(NOT CMAKE_CXX_FLAGS)
#TODO: add -Werror
set (CMAKE_CXX_FLAGS "-Wall -Wextra ${CMAKE_CXX_FLAGS}")
set (CMAKE_CXX_FLAGS "-Wall -Wextra ${CMAKE_CXX_FLAGS} -DCATCH_CONFIG_FAST_COMPILE")
message (STATUS "Warnings Configuration: default: ${CMAKE_CXX_FLAGS}")
endif()

Expand Down
3 changes: 1 addition & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ set(HERMES_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/api/hermes.cc
${CMAKE_CURRENT_SOURCE_DIR}/api/vbucket.cc
${CMAKE_CURRENT_SOURCE_DIR}/buffer_pool.cc
${CMAKE_CURRENT_SOURCE_DIR}/data_placement_engine.cc
)
${CMAKE_CURRENT_SOURCE_DIR}/data_placement_engine.cc)

#------------------------------------------------------------------------------
# Libraries
Expand Down
8 changes: 8 additions & 0 deletions src/api/hermes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ void Hermes::AppBarrier() {
hermes::SubBarrier(&comm_);
}

bool Hermes::BucketContainsBlob(const std::string &bucket_name,
const std::string &blob_name) {
BucketID bucket_id = GetBucketIdByName(&context_, &rpc_, bucket_name.c_str());
bool result = hermes::ContainsBlob(&context_, &rpc_, bucket_id, blob_name);

return result;
}

int Hermes::GetProcessRank() {
int result = comm_.sub_proc_id;

Expand Down
4 changes: 4 additions & 0 deletions src/api/hermes.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "hermes_types.h"
#include "buffer_pool.h"
#include "metadata_management.h"
#include "rpc.h"
#include "id.h"

Expand Down Expand Up @@ -58,6 +59,9 @@ class Hermes {
void *GetAppCommunicator();
void Finalize(bool force_rpc_shutdown = false);

bool BucketContainsBlob(const std::string &bucket_name,
const std::string &blob_name);

// MPI comms.
// proxy/reference to Hermes core
};
Expand Down
52 changes: 52 additions & 0 deletions src/api/traits.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "traits.h"

#include <functional>

namespace hermes {
namespace api {
Trait::Trait(TraitID id, TraitIdArray conflict_traits, TraitType type)
: id(id),
conflict_traits(conflict_traits),
type(type),
onAttachFn(nullptr),
onDetachFn(nullptr),
onLinkFn(nullptr),
onUnlinkFn(nullptr) {}

FileMappingTrait::FileMappingTrait(
std::string &filename, std::unordered_map<std::string, u64> &offset_map,
TraitCallback flush_cb, TraitCallback load_cb)
: Trait(HERMES_FILE_TRAIT, TraitIdArray(), TraitType::FILE_MAPPING),
flush_cb(flush_cb),
load_cb(load_cb),
filename(filename),
offset_map(offset_map) {
this->onAttachFn = std::bind(&FileMappingTrait::onAttach, this,
std::placeholders::_1, std::placeholders::_2);
this->onDetachFn = std::bind(&FileMappingTrait::onDetach, this,
std::placeholders::_1, std::placeholders::_2);
this->onLinkFn = std::bind(&FileMappingTrait::onLink, this,
std::placeholders::_1, std::placeholders::_2);
this->onUnlinkFn = std::bind(&FileMappingTrait::onUnlink, this,
std::placeholders::_1, std::placeholders::_2);
}
void FileMappingTrait::onAttach(TraitInput &input, Trait *trait) {
if (load_cb) {
load_cb(input, trait);
// TODO(hari): @errorhandling Check if load was successful
}
}
void FileMappingTrait::onDetach(TraitInput &input, Trait *trait) {
if (flush_cb) {
flush_cb(input, trait);
// TODO(hari): @errorhandling Check if flush was successful
}
}
void FileMappingTrait::onLink(TraitInput &input, Trait *trait) {
onAttach(input, trait);
}
void FileMappingTrait::onUnlink(TraitInput &input, Trait *trait) {
onDetach(input, trait);
}
} // namespace api
} // namespace hermes
50 changes: 50 additions & 0 deletions src/api/traits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#ifndef HERMES_TRAITS_H
#define HERMES_TRAITS_H

#include <unordered_map>

#include "hermes_types.h"

namespace hermes {
namespace api {

struct BlobInfo {
std::string bucket_name;
std::string blob_name;
};

typedef BlobInfo TraitInput;
struct Trait;
typedef std::function<void(TraitInput &, Trait *)> TraitCallback;

struct Trait {
TraitID id;
TraitIdArray conflict_traits;
TraitType type;
TraitCallback onAttachFn;
TraitCallback onDetachFn;
TraitCallback onLinkFn;
TraitCallback onUnlinkFn;
Trait(TraitID id, TraitIdArray conflict_traits, TraitType type);
};

#define HERMES_FILE_TRAIT 10

struct FileMappingTrait : public Trait {
public:
TraitCallback flush_cb;
TraitCallback load_cb;
std::string filename;
std::unordered_map<std::string, u64> offset_map;
FileMappingTrait(std::string &filename,
std::unordered_map<std::string, u64> &offset_map,
TraitCallback flush_cb, TraitCallback load_cb);
void onAttach(TraitInput &blob, Trait *trait);
void onDetach(TraitInput &blob, Trait *trait);
void onLink(TraitInput &blob, Trait *trait);
void onUnlink(TraitInput &blob, Trait *trait);
};
} // namespace api
} // namespace hermes

#endif // HERMES_TRAITS_H
Loading