Skip to content

Commit

Permalink
renamed concord client request cmf file
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarunkumar Banda authored and Tarunkumar Banda committed May 30, 2022
1 parent 85c009b commit a816d03
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 28 deletions.
2 changes: 1 addition & 1 deletion client/client_pool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ target_link_libraries(concord_client_pool PUBLIC
bftclient
bftclient_new
corebft
concord_client_request
concord_client_message
)

install (TARGETS concord_client_pool DESTINATION lib${LIB_SUFFIX})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class ConcordClientPool {
std::string correlation_id = {},
const std::string& span_context = std::string(),
const bftEngine::RequestType request_type = bftEngine::RequestType::RAW_MESSAGE,
const std::string& subscriptionId = std::string(),
const std::string& client_service_id = std::string(),
const bftEngine::RequestCallBack& callback = {});

// This method is responsible to get write requests with the new client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "client_pool_config.hpp"
#include "communication/StatusInfo.h"
#include "external_client_exception.hpp"
#include "concord_client_request.cmf.hpp"
#include "concord_client_message.cmf.hpp"

namespace concord {

Expand Down Expand Up @@ -105,11 +105,11 @@ class ConcordClient {

std::string messageSignature(bft::client::Msg&);

static void createConcordClientRequest(bft::client::Msg& request,
bftEngine::RequestType typed_request,
const std::string& subscriptionId);
void prepareConcordClientRequest(bft::client::Msg& request,
bftEngine::RequestType request_type,
const std::string& client_service_id);

static void createConcordClientResponse(bft::client::Msg& response);
void prepareConcordClientResponse(bft::client::Msg& response);

private:
void CreateClient(std::shared_ptr<concordMetrics::Aggregator> aggregator);
Expand Down
10 changes: 7 additions & 3 deletions client/client_pool/src/concord_client_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ SubmitResult ConcordClientPool::SendRequest(std::vector<uint8_t> &&request,
std::string correlation_id,
const std::string &span_context,
const bftEngine::RequestType request_type,
const std::string &subscriptionId,
const std::string &client_service_id,
const bftEngine::RequestCallBack &callback) {
if (callback && timeout_ms.count() == 0) {
callback(bftEngine::SendResult{static_cast<uint32_t>(OperationResult::INVALID_REQUEST)});
Expand All @@ -58,7 +58,8 @@ SubmitResult ConcordClientPool::SendRequest(std::vector<uint8_t> &&request,

while (!clients_.empty() && serving_candidates != 0) {
auto client = clients_.front();
external_client::ConcordClient::createConcordClientRequest(request, request_type, subscriptionId);
client->prepareConcordClientRequest(request, request_type, client_service_id);
LOG_DEBUG(logger_, "In ConcordClientPool::SendRequest completed packing concord client request to cmf format");
client_id = client->getClientId();
if (is_overloaded_) {
is_overloaded_ = false;
Expand Down Expand Up @@ -494,8 +495,11 @@ void SingleRequestProcessingJob::execute() {
OperationResult operation_result = processing_client_->getRequestExecutionResult();
reply_size = res.matched_data.size();
if (callback_) {
logging::Logger logger_(logging::getLogger("com.vmware.SingleRequestProcessingJob"));
if (operation_result == OperationResult::SUCCESS) {
external_client::ConcordClient::createConcordClientResponse(res.matched_data);
processing_client_->prepareConcordClientResponse(res.matched_data);
LOG_DEBUG(logger_,
"In SingleRequestProcessingJob::execute completed extracting concord client response from cmf packing");
reply_size = res.matched_data.size();
callback_(res);
} else {
Expand Down
24 changes: 13 additions & 11 deletions client/client_pool/src/external_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ std::pair<int32_t, ConcordClient::PendingReplies> ConcordClient::SendPendingRequ
}
auto cid = pending_seq_num_to_cid_entry->second;
cid_response_map_[cid] = std::chrono::steady_clock::now();
createConcordClientResponse(received_reply_entry.second.matched_data);
prepareConcordClientResponse(received_reply_entry.second.matched_data);
LOG_DEBUG(logger_,
"In ConcordClient::SendPendingRequests completed extracting concord client response from cmf packing");
auto data_size = received_reply_entry.second.matched_data.size();
for (auto& pending_reply : pending_replies_) {
if (pending_reply.cid != cid) continue;
Expand Down Expand Up @@ -393,20 +395,20 @@ OperationResult ConcordClient::getRequestExecutionResult() { return clientReques

std::string ConcordClient::messageSignature(bft::client::Msg& message) { return new_client_->signMessage(message); }

void ConcordClient::createConcordClientRequest(bft::client::Msg& request,
bftEngine::RequestType typed_request,
const std::string& subscriptionId) {
concord::client::request::messages::ConcordClientRequest concord_request;
concord_request.type = static_cast<decltype(concord_request.type)>(typed_request);
concord_request.client_id = static_cast<decltype(concord_request.client_id)>(subscriptionId);
void ConcordClient::prepareConcordClientRequest(bft::client::Msg& request,
bftEngine::RequestType request_type,
const std::string& client_service_id) {
concord::client::message::ConcordClientRequest concord_request;
concord_request.request_type = static_cast<decltype(concord_request.request_type)>(request_type);
concord_request.client_service_id = static_cast<decltype(concord_request.client_service_id)>(client_service_id);
concord_request.application_request = std::vector<uint8_t>(request.begin(), request.end());
request.clear();
concord::client::request::messages::serialize(request, concord_request);
concord::client::message::serialize(request, concord_request);
}

void ConcordClient::createConcordClientResponse(bft::client::Msg& response) {
concord::client::request::messages::ConcordClientResponse concord_response;
concord::client::request::messages::deserialize(response, concord_response);
void ConcordClient::prepareConcordClientResponse(bft::client::Msg& response) {
concord::client::message::ConcordClientResponse concord_response;
concord::client::message::deserialize(response, concord_response);
response.clear();
response.assign(concord_response.application_response.begin(), concord_response.application_response.end());
}
Expand Down
6 changes: 6 additions & 0 deletions client/clientservice/src/request_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,14 @@ void RequestServiceCallData::sendToConcordClient() {
this->populateResult(status);
return;
}
LOG_DEBUG(logger_,
"In RequestServiceCallData::sendToConcordClient callback function done parsing application ANY Data "
"and updated the response");
} else {
this->response_.set_raw_response(std::move(data));
LOG_DEBUG(logger_,
"In RequestServiceCallData::sendToConcordClient callback function done parsing application RAW Data "
"and updated the response");
}

this->populateResult(grpc::Status::OK);
Expand Down
2 changes: 1 addition & 1 deletion client/concordclient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ add_subdirectory("cmf")

target_link_libraries(concordclient PUBLIC
thin_replica_client_lib
concord_client_request
concord_client_message
concord_client_pool
concordclient-event-api
util
Expand Down
8 changes: 4 additions & 4 deletions client/concordclient/cmf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmf_generate_cpp(header cpp concord::client::request::messages concord_client_request.cmf)
add_library(concord_client_request ${cpp})
set_target_properties(concord_client_request PROPERTIES LINKER_LANGUAGE CXX)
target_include_directories(concord_client_request PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
cmf_generate_cpp(header cpp concord::client::message concord_client_message.cmf)
add_library(concord_client_message ${cpp})
set_target_properties(concord_client_message PROPERTIES LINKER_LANGUAGE CXX)
target_include_directories(concord_client_message PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
# with clientservice specific information to the blockchain network.

Msg ConcordClientRequest 1 {
uint32 type
string client_id
# request_type is type of input request, which can be of RAW or ANY request
uint32 request_type
# Client service ID or thin replica client's subscription ID
# used for filtering events for this client.
string client_service_id
# Required application request which gets evaluated by the execution engine.
bytes application_request
}

Expand Down

0 comments on commit a816d03

Please sign in to comment.