namespace actx { using actor_id = actorx::adl::actor_id; //! Null actor_id. static actor_id const nullaid = actor_id(); //! Maker of actor_id. template <> struct maker<actor_id> { static actor_id create() { return actor_id(); } template <size_t AxidSize> static actor_id create(char const (&type)[AxidSize], int64_t timestamp, int64_t id, int64_t sid) { return create(atom(type), timestamp, id, sid); } static actor_id create(int64_t axid, int64_t timestamp, int64_t id, int64_t sid) { actor_id aid; aid.axid = axid; aid.timestamp = timestamp; aid.id = id; aid.sid = sid; return aid; } }; //! To string of actor_id. static std::string to_string(actor_id const& o) { std::string str; str += "aid<"; str += atom(o.axid); str += "."; str += to_string(o.timestamp); str += "."; str += to_string(o.id); str += "."; str += to_string(o.sid); str += ">"; return str; } //! For assertion. template <> struct format<actor_id> { static std::string convert(actor_id const& o) { return to_string(o); } }; } // namespace actx
idgs::store::ListenerResultCode RddStoreListener::insert(idgs::store::ListenerContext* context) { if (!rddLocal) { LOG(ERROR) << "RDD is not found."; return idgs::store::LRC_CONTINUE; } auto& key = * context->getKey(); auto& value = * context->getValue(); if (rddLocal->isReplicatedRdd()) { auto partitions = rddLocal->getLocalPartitions(); auto it = partitions.begin(); for (; it != partitions.end(); ++ it) { auto partitionActor = rddLocal->getPartitionActor(* it); idgs::actor::ActorMessagePtr message = std::make_shared<idgs::actor::ActorMessage>(); message->setOperationName(RDD_STORE_LISTENER); message->setSourceActorId(partitionActor.actor_id()); message->setSourceMemberId(partitionActor.member_id()); message->setDestActorId(partitionActor.actor_id()); message->setDestMemberId(partitionActor.member_id()); message->setPayload(std::make_shared<pb::RddRequest>()); message->setAttachment(RE_PARTITION_KEY, key); message->setAttachment(RE_PARTITION_VALUE, value); idgs::actor::postMessage(message); } } else { auto partitionId = context->getPartitionId(); auto partitionActor = rddLocal->getPartitionActor(partitionId); idgs::actor::ActorMessagePtr message = std::make_shared<idgs::actor::ActorMessage>(); message->setOperationName(RDD_STORE_LISTENER); message->setSourceActorId(partitionActor.actor_id()); message->setSourceMemberId(partitionActor.member_id()); message->setDestActorId(partitionActor.actor_id()); message->setDestMemberId(partitionActor.member_id()); message->setPayload(std::make_shared<pb::RddRequest>()); message->setAttachment(RE_PARTITION_KEY, key); message->setAttachment(RE_PARTITION_VALUE, value); idgs::actor::sendMessage(message); } return idgs::store::LRC_CONTINUE; }
Promise<Unit> MultiPromiseActor::get_promise() { if (empty()) { register_actor("MultiPromise", this).release(); } CHECK(!promises_.empty()); PromiseActor<Unit> promise; FutureActor<Unit> future; init_promise_future(&promise, &future); future.set_event(EventCreator::raw(actor_id(), nullptr)); futures_.emplace_back(std::move(future)); return PromiseCreator::from_promise_actor(std::move(promise)); }
static actor_id create() { return actor_id(); }