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 MigrationVerifyActor::handleVerifyRequest(const idgs::actor::ActorMessagePtr& msg) {
  pb::MigrationVerifyRequest* request = NULL;
  if (msg->getPayload()) {
    request = dynamic_cast<pb::MigrationVerifyRequest*>(msg->getPayload().get());
  }

  if (request && request->has_schema_name() && request->has_store_name()) {
    auto datastore = idgs::store::idgs_store_module()->getDataStore();
    auto store = datastore->getStore(request->schema_name(), request->store_name());
    if (!store) {
      LOG(ERROR) << "store " << request->schema_name() << "." << request->store_name() << " is not found.";
      auto payload = std::make_shared<pb::MigrationVerifyResponse>();
      payload->set_result_code(static_cast<int32_t>(RC_STORE_NOT_FOUND));
      auto respMsg = msg->createResponse();
      respMsg->setOperationName("VERIFY_RESPONSE");
      respMsg->setPayload(payload);
      idgs::actor::sendMessage(respMsg);
      return;
    }

    if (store->getStoreConfig()->getStoreConfig().partition_type() != idgs::store::pb::PARTITION_TABLE) {
      LOG(ERROR) << "store " << request->schema_name() << "." << request->store_name() << " is not a partition store.";
      auto payload = std::make_shared<pb::MigrationVerifyResponse>();
      payload->set_result_code(static_cast<int32_t>(RC_STORE_NOT_FOUND));
      auto respMsg = msg->createResponse();
      respMsg->setOperationName("VERIFY_RESPONSE");
      respMsg->setPayload(payload);
      idgs::actor::sendMessage(respMsg);
      return;
    }
  }

  clientMsg = msg;
  auto& members = idgs_application()->getMemberManager()->getMemberTable();
  auto it = members.begin();
  for (; it != members.end(); ++ it) {
    if (it->isLocalStore() && (it->getState() == idgs::pb::MS_PREPARED || it->getState() == idgs::pb::MS_ACTIVE)) {
      auto reqMsg = createActorMessage();
      reqMsg->setOperationName("LOCAL_VERIFY_REQUEST");
      reqMsg->setDestMemberId(it->getId());
      reqMsg->setDestActorId(actorId);
      reqMsg->setPayload(msg->getPayload());
      idgs::actor::sendMessage(reqMsg);
      ++ memberSize;
    }
  }
}
void PairStoreDelegateRddPartition::handleRddTransform(const idgs::actor::ActorMessagePtr& msg) {
  if (!active) {
    active = true;
  }

  transform();

  rddLocal->setPartitionState(partition, TRANSFORM_COMPLETE);
  shared_ptr<RddResponse> response = make_shared<RddResponse>();
  response->set_partition(partition);
  response->set_result_code(RRC_SUCCESS);

  auto respMsg = createActorMessage();
  respMsg->setDestActorId(rddLocal->getRddId().actor_id());
  respMsg->setDestMemberId(rddLocal->getRddId().member_id());
  respMsg->setOperationName(PARTITION_TRANSFORM_COMPLETE);
  respMsg->setPayload(response);
  sendMessage(respMsg);
}
Example #4
0
idgs::ResultCode MembershipTableMgr::multicastMemberMessage(const std::string& message_type, std::shared_ptr<google::protobuf::Message> payload) {
  std::shared_ptr<ActorMessage> actor_msg_ptr = createActorMessage();
  actor_msg_ptr->setOperationName(message_type);
  actor_msg_ptr->setPayload(payload);
  return ::idgs::util::singleton<ClusterFramework>::getInstance().getClusterAdapter()->multicastMessage(actor_msg_ptr);
}