Skip to content

Commit

Permalink
Merge pull request #127 from whoodes/add-remove-compute-cost
Browse files Browse the repository at this point in the history
FileRegistry: Add an ADD_ENTRY, and REMOVE_ENTRY cost.
  • Loading branch information
henricasanova committed Nov 25, 2019
2 parents 1e675cf + d45cdc3 commit 2f87d52
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions include/wrench/services/file_registry/FileRegistryService.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ namespace wrench {

std::map<std::string, std::string> default_property_values = {
{FileRegistryServiceProperty::LOOKUP_COMPUTE_COST, "0.0"},
{FileRegistryServiceProperty::ADD_ENTRY_COMPUTE_COST, "0.0"},
{FileRegistryServiceProperty::REMOVE_ENTRY_COMPUTE_COST, "0.0"},
};

std::map<std::string, double> default_messagepayload_values = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ namespace wrench {

public:

/** @brief The computational cost, in flops, of looking up entries for a file **/
/**
* @brief The computational cost, in flops, of looking up, adding, and
* removing entries for a file
*/
DECLARE_PROPERTY_NAME(LOOKUP_COMPUTE_COST);
DECLARE_PROPERTY_NAME(ADD_ENTRY_COMPUTE_COST);
DECLARE_PROPERTY_NAME(REMOVE_ENTRY_COMPUTE_COST);

};

Expand Down
8 changes: 8 additions & 0 deletions src/wrench/services/file_registry/FileRegistryService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ namespace wrench {

} else if (auto msg = std::dynamic_pointer_cast<FileRegistryAddEntryRequestMessage>(message)) {
addEntryToDatabase(msg->file, msg->location);

// Simulate an add overhead
S4U_Simulation::compute(getPropertyValueAsDouble(FileRegistryServiceProperty::ADD_ENTRY_COMPUTE_COST));

S4U_Mailbox::dputMessage(msg->answer_mailbox,
new FileRegistryAddEntryAnswerMessage(this->getMessagePayloadValue(
FileRegistryServiceMessagePayload::ADD_ENTRY_ANSWER_MESSAGE_PAYLOAD)));
Expand All @@ -347,6 +351,10 @@ namespace wrench {
} else if (auto msg = std::dynamic_pointer_cast<FileRegistryRemoveEntryRequestMessage>(message)) {

bool success = removeEntryFromDatabase(msg->file, msg->location);

// Simulate a removal overhead
S4U_Simulation::compute(getPropertyValueAsDouble(FileRegistryServiceProperty::REMOVE_ENTRY_COMPUTE_COST));

S4U_Mailbox::dputMessage(msg->answer_mailbox,
new FileRegistryRemoveEntryAnswerMessage(success,
this->getMessagePayloadValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
namespace wrench {

SET_PROPERTY_NAME(FileRegistryServiceProperty, LOOKUP_COMPUTE_COST);
SET_PROPERTY_NAME(FileRegistryServiceProperty, ADD_ENTRY_COMPUTE_COST);
SET_PROPERTY_NAME(FileRegistryServiceProperty, REMOVE_ENTRY_COMPUTE_COST);
};

Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,9 @@ void StorageServiceLinkFailuresTest::do_StorageServiceLinkFailureSimpleRandom_Te
file_registry_service = simulation->add(
new wrench::FileRegistryService("Host1",
{
{wrench::FileRegistryServiceProperty::LOOKUP_COMPUTE_COST, "0"}
{wrench::FileRegistryServiceProperty::LOOKUP_COMPUTE_COST, "0"},
{wrench::FileRegistryServiceProperty::ADD_ENTRY_COMPUTE_COST, "0"},
{wrench::FileRegistryServiceProperty::REMOVE_ENTRY_COMPUTE_COST, "0"}
},
{
{wrench::FileRegistryServiceMessagePayload::ADD_ENTRY_REQUEST_MESSAGE_PAYLOAD, message_payload},
Expand Down

0 comments on commit 2f87d52

Please sign in to comment.