void StoreDelegateRddActor::handleRddCreate(const ActorMessagePtr& msg) { DVLOG(2) << "StoreDelegateRddActor : handle create store delegate."; rawMsg = msg; CreateDelegateRddRequest* request = dynamic_cast<CreateDelegateRddRequest*>(msg->getPayload().get()); idgs::store::MetadataHelper::loadStoreMetadata(request->store_name(), metadata.get()); ClusterFramework& cluster = ::idgs::util::singleton<ClusterFramework>::getInstance(); for (int32_t partition = 0; partition < partitionSize; ++partition) { int32_t memberId = cluster.getPartitionManager()->getPartition(partition)->getPrimaryMemberId(); shared_ptr<CreateDelegatePartitionRequest> payload(new CreateDelegatePartitionRequest); payload->set_store_name(request->store_name()); payload->set_partition(partition); payload->set_rdd_name(getRddName()); ActorMessagePtr reqMsg = createActorMessage(); reqMsg->setOperationName(CREATE_DELEGATE_PARTITION); reqMsg->setDestActorId(RDD_SERVICE_ACTOR); reqMsg->setDestMemberId(memberId); reqMsg->setPayload(payload); DVLOG(3) << "RDD \"" << getRddName() << "\" sending create RDD partition to member " << memberId; ::idgs::actor::postMessage(reqMsg); } }
void DataAggregatorActor::handleDeleteResponse(const ActorMessagePtr& msg) { DVLOG_FIRST_N(2, 20) << "receive store remove response of member " << getActorId(); auto response = dynamic_cast<idgs::store::pb::DeleteResponse*>(msg->getPayload().get()); // error if (response->result_code() != idgs::store::pb::SRC_SUCCESS) { LOG(ERROR)<< "error in remove data to member " << msg->getSourceActorId(); resultCode = response->result_code(); } ++ responseCount; DVLOG_FIRST_N(2, 20) << "member " << msg->getSourceMemberId() << " response, left " << requestCount - responseCount << " members."; if (requestCount == responseCount) { DVLOG_FIRST_N(2, 20) << "all member response, send response to client."; auto globalResponse = make_shared<idgs::store::pb::DeleteResponse>(); globalResponse->set_result_code(resultCode); sendResponse(OP_DELETE_RESPONSE, globalResponse); terminate(); } }
void DataAggregatorActor::handleInsertResponse(const ActorMessagePtr& msg) { DVLOG_FIRST_N(2, 20) << "receive store insert response of member " << msg->getSourceMemberId(); idgs::store::pb::InsertResponse* response = dynamic_cast<idgs::store::pb::InsertResponse*>(msg->getPayload().get()); // error if (response->result_code() != idgs::store::pb::SRC_SUCCESS) { resultCode = response->result_code(); LOG(ERROR)<< "error in insert data to member " << msg->getSourceActorId() << " error code : " << resultCode; } // collect response from all members and calculate size and then response to client. ++ responseCount; DVLOG_FIRST_N(2, 20) << "member " << msg->getSourceMemberId() << " responsed, left " << requestCount - responseCount << " members."; if (requestCount == responseCount) { DVLOG_FIRST_N(2, 20) << "all member responsed, send response to client"; shared_ptr<idgs::store::pb::InsertResponse> globalResponse = make_shared<idgs::store::pb::InsertResponse>(); globalResponse->set_result_code(resultCode); sendResponse(OP_INSERT_RESPONSE, globalResponse); terminate(); } }