Exemplo n.º 1
0
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 AggregatorActor::multicast(const ActorMessagePtr& msg, const string& actorId, const std::string& opName) {
  requestCount = 0;
  responseCount = 0;

  auto memberMgr = idgs_application()->getMemberManager();
  auto& members = memberMgr->getMemberTable();
  auto it = members.begin();
  for (; it != members.end(); ++ it) {
    if (it->isLocalStore() && (it->getState() == idgs::pb::MS_ACTIVE || it->getState() == idgs::pb::MS_PREPARED)) {
      ActorMessagePtr multMsg = msg->createRouteMessage(it->getId(), actorId);
      multMsg->setOperationName(opName);
      multMsg->setSourceActorId(this->getActorId());
      multMsg->setSourceMemberId(memberMgr->getLocalMemberId());
      ::idgs::actor::postMessage(multMsg);
      ++ requestCount;
    }
  }
}
void AggregatorActor::sendResponse(const std::string& opName, const shared_ptr<Message>& response) {
  ActorMessagePtr am = clientMsg->createResponse();
  am->setOperationName(opName);
  am->setPayload(response);
  idgs::actor::sendMessage(am);
}