Skip to content

Commit

Permalink
Merge pull request #34 from rajakrishi/master
Browse files Browse the repository at this point in the history
  • Loading branch information
mashoodk authored Dec 12, 2022
2 parents 5c4d544 + 7df362a commit c2ecafa
Show file tree
Hide file tree
Showing 5 changed files with 195 additions and 167 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ endif()
# add boost
#
set(BOOST_ROOT $ENV{BOOST_ROOT})
find_package(Boost 1.55 COMPONENTS log log_setup thread system filesystem REQUIRED)
find_package(Boost 1.65 COMPONENTS log log_setup thread system filesystem REQUIRED)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIR})
Expand Down
222 changes: 112 additions & 110 deletions include/nvmm/error_code.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* (c) Copyright 2016-2021 Hewlett Packard Enterprise Development Company LP.
* (c) Copyright 2016-2022 Hewlett Packard Enterprise Development Company LP.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the
* GNU Lesser General Public License Version 3, or (at your option)
* later with exceptions included below, or under the terms of the
* licenses. You may choose to be licensed under the terms of the
* GNU Lesser General Public License Version 3, or (at your option)
* later with exceptions included below, or under the terms of the
* MIT license (Expat) available in COPYING file in the source tree.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Expand All @@ -28,111 +28,113 @@

namespace nvmm {
enum ErrorCode {
// general errors (0-)
NO_ERROR = 0,
NOT_YET_IMPLEMENTED,
BUG,
OUT_OF_MEMORY,
INVALID_ARGUMENTS, // one or more of the argument to the function is invalid

// shelf file (20-)
SHELF_FILE_CREATE_FAILED = 20,
SHELF_FILE_DESTROY_FAILED,
SHELF_FILE_TRUNCATE_FAILED,
SHELF_FILE_OPEN_FAILED,
SHELF_FILE_CLOSE_FAILED,
SHELF_FILE_MAP_FAILED,
SHELF_FILE_FAM_ATOMIC_REGISTER_REGION_FAILED,
SHELF_FILE_UNMAP_FAILED,
SHELF_FILE_FOUND,
SHELF_FILE_NOT_FOUND,
SHELF_FILE_RENAME_FAILED = 30,

SHELF_FILE_FORMAT_FAILED,
SHELF_FILE_CLEAR_FAILED, // clear the formatting
SHELF_FILE_VERIFY_FAILED,
SHELF_FILE_INVALID_FORMAT,
SHELF_FILE_RECOVER_FAILED,
SHELF_FILE_GET_PERM_FAILED,
SHELF_FILE_SET_PERM_FAILED,

SHELF_FILE_OPENED,
SHELF_FILE_CLOSED,

// pool (60-)
POOL_CREATE_FAILED = 60,
POOL_DESTROY_FAILED,
POOL_VERIFY_FAILED,
POOL_OPEN_FAILED,
POOL_CLOSE_FAILED,
POOL_MEMBERSHIP_FULL,
POOL_MEMBERSHIP_EMPTY,
POOL_INVALID_META_FILE,
POOL_INVALID_POOL_ID,
POOL_FOUND,
POOL_NOT_FOUND,
POOL_SHELF_FOUND,
POOL_SHELF_NOT_FOUND,
POOL_ADD_SHELF_FAILED,
POOL_REMOVE_SHELF_FAILED,
POOL_INCONSISTENCY_FOUND,
POOL_OPENED,
POOL_CLOSED,

// membership (80-)
MEMBERSHIP_CREATE_FAILED = 80,
MEMBERSHIP_DESTROY_FAILED,
MEMBERSHIP_OPEN_FAILED,

// Heap (100-)
HEAP_CREATE_FAILED = 100,
HEAP_DESTROY_FAILED,
HEAP_OPEN_FAILED,
HEAP_CLOSE_FAILED,
HEAP_ALLOC_FAILED,
HEAP_OPENED,
HEAP_CLOSED,
HEAP_RESIZE_FAILED,
HEAP_SET_PERMISSION_FAILED,
HEAP_GET_PERMISSION_FAILED,
HEAP_BUSY, // Some other metadata operation in progress
HEAP_NOT_OPEN,
HEAP_IS_OPEN,

// Region (120-)
REGION_CREATE_FAILED = 120,
REGION_DESTROY_FAILED,
REGION_OPEN_FAILED,
REGION_CLOSE_FAILED,
REGION_MAP_FAILED,
REGION_UNMAP_FAILED,
REGION_OPENED,
REGION_CLOSED,

// FreeLists (140-)
FREELISTS_CREATE_FAILED = 140,
FREELISTS_DESTROY_FAILED,
FREELISTS_OPEN_FAILED,
FREELISTS_PUT_FAILED,
FREELISTS_EMPTY,

// Ownership (150-)
OWNERSHIP_CREATE_FAILED = 150,
OWNERSHIP_DESTROY_FAILED,
OWNERSHIP_OPEN_FAILED,

// memory manager (200-)
ID_FOUND = 200, // this id is in use
ID_NOT_FOUND, // this id is available
ID_NOT_VALID, // This id is not valid
INVALID_PTR,
MAP_POINTER_FAILED,

// shelf manager (250-)
SHELF_ID_NOT_FOUND = 250,

// max return code
MAX_RETURN_CODE
// general errors (0-)
NO_ERROR = 0,
NOT_YET_IMPLEMENTED,
BUG,
OUT_OF_MEMORY,
INVALID_ARGUMENTS, // one or more of the argument to the function is invalid

// shelf file (20-)
SHELF_FILE_CREATE_FAILED = 20,
SHELF_FILE_DESTROY_FAILED,
SHELF_FILE_TRUNCATE_FAILED,
SHELF_FILE_OPEN_FAILED,
SHELF_FILE_CLOSE_FAILED,
SHELF_FILE_MAP_FAILED,
SHELF_FILE_FAM_ATOMIC_REGISTER_REGION_FAILED,
SHELF_FILE_UNMAP_FAILED,
SHELF_FILE_FOUND,
SHELF_FILE_NOT_FOUND,
SHELF_FILE_RENAME_FAILED = 30,

SHELF_FILE_FORMAT_FAILED,
SHELF_FILE_CLEAR_FAILED, // clear the formatting
SHELF_FILE_VERIFY_FAILED,
SHELF_FILE_INVALID_FORMAT,
SHELF_FILE_RECOVER_FAILED,
SHELF_FILE_GET_PERM_FAILED,
SHELF_FILE_SET_PERM_FAILED,

SHELF_FILE_OPENED,
SHELF_FILE_CLOSED,

// pool (60-)
POOL_CREATE_FAILED = 60,
POOL_DESTROY_FAILED,
POOL_VERIFY_FAILED,
POOL_OPEN_FAILED,
POOL_CLOSE_FAILED,
POOL_MEMBERSHIP_FULL,
POOL_MEMBERSHIP_EMPTY,
POOL_INVALID_META_FILE,
POOL_INVALID_POOL_ID,
POOL_FOUND,
POOL_NOT_FOUND,
POOL_SHELF_FOUND,
POOL_SHELF_NOT_FOUND,
POOL_ADD_SHELF_FAILED,
POOL_REMOVE_SHELF_FAILED,
POOL_INCONSISTENCY_FOUND,
POOL_OPENED,
POOL_CLOSED,

// membership (80-)
MEMBERSHIP_CREATE_FAILED = 80,
MEMBERSHIP_DESTROY_FAILED,
MEMBERSHIP_OPEN_FAILED,

// Heap (100-)
HEAP_CREATE_FAILED = 100,
HEAP_DESTROY_FAILED,
HEAP_OPEN_FAILED,
HEAP_CLOSE_FAILED,
HEAP_ALLOC_FAILED,
HEAP_OPENED,
HEAP_CLOSED,
HEAP_RESIZE_FAILED,
HEAP_SET_PERMISSION_FAILED,
HEAP_GET_PERMISSION_FAILED,
HEAP_BUSY, // Some other metadata operation in progress
HEAP_NOT_OPEN,
HEAP_IS_OPEN,

// Region (120-)
REGION_CREATE_FAILED = 120,
REGION_DESTROY_FAILED,
REGION_OPEN_FAILED,
REGION_CLOSE_FAILED,
REGION_MAP_FAILED,
REGION_UNMAP_FAILED,
REGION_OPENED,
REGION_CLOSED,

// FreeLists (140-)
FREELISTS_CREATE_FAILED = 140,
FREELISTS_DESTROY_FAILED,
FREELISTS_OPEN_FAILED,
FREELISTS_PUT_FAILED,
FREELISTS_EMPTY,

// Ownership (150-)
OWNERSHIP_CREATE_FAILED = 150,
OWNERSHIP_DESTROY_FAILED,
OWNERSHIP_OPEN_FAILED,

// memory manager (200-)
ID_FOUND = 200, // this id is in use
ID_NOT_FOUND, // this id is available
ID_NOT_VALID, // This id is not valid
INVALID_PTR,
MAP_POINTER_FAILED,
SHELF_BASE_DIR_CREATE_FAILED,
SHELF_BASE_PATH_DOES_NOT_EXIST,

// shelf manager (250-)
SHELF_ID_NOT_FOUND = 250,

// max return code
MAX_RETURN_CODE
};

} // namespace nvmm
Expand Down
12 changes: 6 additions & 6 deletions include/nvmm/memory_manager.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* (c) Copyright 2016-2021 Hewlett Packard Enterprise Development Company LP.
* (c) Copyright 2016-2022 Hewlett Packard Enterprise Development Company LP.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the
* GNU Lesser General Public License Version 3, or (at your option)
* later with exceptions included below, or under the terms of the
* licenses. You may choose to be licensed under the terms of the
* GNU Lesser General Public License Version 3, or (at your option)
* later with exceptions included below, or under the terms of the
* MIT license (Expat) available in COPYING file in the source tree.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Expand Down Expand Up @@ -50,7 +50,7 @@ namespace nvmm{
// this function is NOT thread-safe/process-safe
// this function must run once and only once in both single-node and multi-node environments,
// before the first call to GetInstance()
void StartNVMM(std::string base="", std::string user="");
int StartNVMM(std::string base = "", std::string user = "");

// Delete all previous shelves, resetting both the memory manager and epoch manager
// this function is NOT thread-safe/process-safe
Expand Down
4 changes: 2 additions & 2 deletions src/common/log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/make_shared_object.hpp>
#include <boost/utility/empty_deleter.hpp>
#include <boost/core/null_deleter.hpp>

#include <boost/log/core.hpp>
#include <boost/log/sinks/sync_frontend.hpp>
Expand Down Expand Up @@ -82,7 +82,7 @@ void init_log(boost::log::trivial::severity_level level, std::string file_name)
if (file_name.empty()) {
// Add console output
// We have to provide an empty deleter to avoid destroying the global stream object
boost::shared_ptr< std::ostream > stream(&std::clog, boost::empty_deleter());
boost::shared_ptr< std::ostream > stream(&std::clog, boost::null_deleter());
sink->locked_backend()->add_stream(stream);
} else {
sink->locked_backend()->add_stream(boost::make_shared< std::ofstream >(file_name));
Expand Down
Loading

0 comments on commit c2ecafa

Please sign in to comment.