-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into chogan/bo_organize
- Loading branch information
Showing
39 changed files
with
2,752 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
project(PubSubAdapter VERSION 0.3.0) | ||
|
||
set(HERMES_PUBSUB_ADAPTER_DIR ${HERMES_ADAPTER_DIR}/pubsub) | ||
|
||
set(PUBSUB_ADAPTER_PUBLIC_HEADER pubsub.h) | ||
set(PUBSUB_ADAPTER_PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/metadata_manager.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/datastructures.h | ||
${HERMES_ADAPTER_DIR}/constants.h | ||
${HERMES_ADAPTER_DIR}/singleton.h) | ||
set(PUBSUB_ADAPTER_SRC pubsub.cc metadata_manager.cc) | ||
|
||
add_library(hermes_pubsub SHARED ${PUBSUB_ADAPTER_PRIVATE_HEADER} ${PUBSUB_ADAPTER_PUBLIC_HEADER} ${PUBSUB_ADAPTER_SRC}) | ||
target_include_directories(hermes_pubsub PRIVATE ${HERMES_ADAPTER_DIR}) | ||
add_dependencies(hermes_pubsub hermes) | ||
target_link_libraries(hermes_pubsub hermes MPI::MPI_CXX) | ||
|
||
#----------------------------------------------------------------------------- | ||
# Add Target(s) to CMake Install | ||
#----------------------------------------------------------------------------- | ||
install( | ||
TARGETS | ||
hermes_pubsub | ||
EXPORT | ||
${HERMES_EXPORTED_TARGETS} | ||
LIBRARY DESTINATION ${HERMES_INSTALL_LIB_DIR} | ||
ARCHIVE DESTINATION ${HERMES_INSTALL_LIB_DIR} | ||
RUNTIME DESTINATION ${HERMES_INSTALL_BIN_DIR} | ||
) | ||
#----------------------------------------------------------------------------- | ||
# Add Target(s) to Coverage | ||
#----------------------------------------------------------------------------- | ||
if(HERMES_ENABLE_COVERAGE) | ||
set_coverage_flags(hermes_pubsub) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Distributed under BSD 3-Clause license. * | ||
* Copyright by The HDF Group. * | ||
* Copyright by the Illinois Institute of Technology. * | ||
* All rights reserved. * | ||
* * | ||
* This file is part of Hermes. The full Hermes copyright notice, including * | ||
* terms governing use, modification, and redistribution, is contained in * | ||
* the COPYING file, which can be found at the top directory. If you do not * | ||
* have access to the file, you may request a copy from help@hdfgroup.org. * | ||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
|
||
#ifndef HERMES_PUBSUB_ADAPTER_DATASTRUCTURES_H | ||
#define HERMES_PUBSUB_ADAPTER_DATASTRUCTURES_H | ||
|
||
/** | ||
* Standard header | ||
*/ | ||
#include <string> | ||
|
||
/** | ||
* Internal header | ||
*/ | ||
#include <bucket.h> | ||
#include <buffer_pool.h> | ||
#include <hermes_types.h> | ||
|
||
/** | ||
* Namespace simplification. | ||
*/ | ||
namespace hapi = hermes::api; | ||
|
||
namespace hermes::adapter::pubsub { | ||
|
||
/** | ||
* Struct that defines the metadata required for the pubsub adapter. | ||
*/ | ||
struct ClientMetadata { | ||
/** | ||
* attributes | ||
*/ | ||
std::shared_ptr<hapi::Bucket> st_bkid; /* bucket associated with the topic */ | ||
u64 last_subscribed_blob; /* Current blob being used */ | ||
timespec st_atim; /* time of last access */ | ||
/** | ||
* Constructor | ||
*/ | ||
ClientMetadata() | ||
: st_bkid(), | ||
last_subscribed_blob(0), | ||
st_atim() {} /* default constructor */ | ||
explicit ClientMetadata(const struct ClientMetadata &st) | ||
: st_bkid(st.st_bkid), | ||
last_subscribed_blob(st.last_subscribed_blob), | ||
st_atim(st.st_atim) {} /* parameterized constructor */ | ||
}; | ||
|
||
} // namespace hermes::adapter::pubsub | ||
|
||
#endif // HERMES_PUBSUB_ADAPTER_DATASTRUCTURES_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Distributed under BSD 3-Clause license. * | ||
* Copyright by The HDF Group. * | ||
* Copyright by the Illinois Institute of Technology. * | ||
* All rights reserved. * | ||
* * | ||
* This file is part of Hermes. The full Hermes copyright notice, including * | ||
* terms governing use, modification, and redistribution, is contained in * | ||
* the COPYING file, which can be found at the top directory. If you do not * | ||
* have access to the file, you may request a copy from help@hdfgroup.org. * | ||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
|
||
#include "metadata_manager.h" | ||
|
||
/** | ||
* Namespace declarations for cleaner code. | ||
*/ | ||
using hermes::adapter::pubsub::MetadataManager; | ||
using hermes::adapter::pubsub::MetadataManager; | ||
|
||
bool MetadataManager::Create(const std::string& topic, | ||
const ClientMetadata&stat) { | ||
LOG(INFO) << "Create metadata for topic: " << topic << std::endl; | ||
auto ret = metadata.emplace(topic, stat); | ||
return ret.second; | ||
} | ||
|
||
bool MetadataManager::Update(const std::string& topic, | ||
const ClientMetadata&stat) { | ||
LOG(INFO) << "Update metadata for topic: " << topic << std::endl; | ||
auto iter = metadata.find(topic); | ||
if (iter != metadata.end()) { | ||
metadata.erase(iter); | ||
auto ret = metadata.emplace(topic, stat); | ||
return ret.second; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
std::pair<ClientMetadata, bool> MetadataManager::Find( | ||
const std::string& topic) { | ||
typedef std::pair<ClientMetadata, bool> MetadataReturn; | ||
auto iter = metadata.find(topic); | ||
if (iter == metadata.end()) | ||
return MetadataReturn(ClientMetadata(), false); | ||
else | ||
return MetadataReturn(iter->second, true); | ||
} | ||
|
||
bool MetadataManager::Delete(const std::string& topic) { | ||
LOG(INFO) << "Delete metadata for topic: " << topic << std::endl; | ||
auto iter = metadata.find(topic); | ||
if (iter != metadata.end()) { | ||
metadata.erase(iter); | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} |
Oops, something went wrong.