11#if !defined INCLUDED_LOC_COORDINATOR_H
12#define INCLUDED_LOC_COORDINATOR_H
14#include "loc/common.h"
15#include "loc/communicator.h"
16#include "loc/lookup/lookup.h"
17#include "loc/record/record.h"
20#include <unordered_map>
21#include <unordered_set>
47template <
typename EntityID,
typename Comm>
50 Communicator<Comm, Coordinator<EntityID, Comm>>,
51 "Coordinator requires a Comm satisfying loc::Communicator"
56 using HandleType =
typename Comm::template HandleType<ThisType>;
57 using NodeAction = std::function<void(NodeType)>;
58 using ExistsAction = std::function<void(
bool, NodeType)>;
67 Comm& in_comm, LocationSizeType in_max_cache_size = default_max_cache_size
113 void getLocation(EntityID
const&
id, NodeType home, NodeAction action);
122 void entityExists(EntityID
const&
id, NodeType home, ExistsAction action);
125 bool isCached(EntityID
const&
id)
const;
157 LocRecType makeRec(EntityID
const&
id, NodeType node)
const;
160 static void flushPending(
161 std::unordered_map<EntityID, std::vector<NodeAction>>& map,
162 EntityID
const&
id, NodeType node
171 void announceLocation(EntityID
const&
id, NodeType node);
175 NodeType this_node_ = no_node;
176 HandleType handle_{};
179 std::unordered_set<EntityID> local_registered_;
185 std::unordered_map<EntityID, std::vector<NodeAction>> pending_;
188 std::unordered_map<EntityID, std::vector<ExistsAction>> pending_exists_;
191 std::unordered_map<EntityID, std::vector<NodeType>> pending_home_;
194 std::unordered_map<EntityID, std::unordered_set<NodeType>> loc_asks_;
199#include "loc/coordinator.impl.h"
void updateHome(EntityID id, NodeType node)
[home] Learn/refresh where an entity lives.
Definition coordinator.impl.h:124
void unregisterEntity(EntityID const &id)
Unregister an entity that no longer lives here.
Definition coordinator.impl.h:56
void entityExists(EntityID const &id, NodeType home, ExistsAction action)
Check whether an entity exists anywhere in the system.
Definition coordinator.impl.h:85
void registerEntity(EntityID const &id, NodeType home)
Register an entity as living on this rank.
Definition coordinator.impl.h:29
void existsResponse(EntityID id, bool exists, NodeType node)
[asker] Home answered an existence request.
Definition coordinator.impl.h:176
void locationRequest(EntityID id, NodeType requester)
[home] A rank asks where an entity lives.
Definition coordinator.impl.h:129
void existsRequest(EntityID id, NodeType requester)
[home] A rank asks whether an entity exists.
Definition coordinator.impl.h:157
bool isCached(EntityID const &id) const
Whether a resolved location for id is held locally (local or cached).
Definition coordinator.impl.h:109
void getLocation(EntityID const &id, NodeType home, NodeAction action)
Resolve the current location of an entity.
Definition coordinator.impl.h:62
void resolveResponse(EntityID id, NodeType node)
[asker] Home answered a location request.
Definition coordinator.impl.h:149
void entityImmigrated(EntityID const &id, NodeType home, NodeType from)
Register an entity that immigrated here from another rank.
Definition coordinator.impl.h:41
void entityEmigrated(EntityID const &id, NodeType new_node)
Note that an entity has emigrated off this rank to new_node.
Definition coordinator.impl.h:48
Coordinator(Comm &in_comm, LocationSizeType in_max_cache_size=default_max_cache_size)
Construct and collectively register with the communicator.
Definition coordinator.impl.h:19
NodeType thisNode() const
This rank.
Definition coordinator.impl.h:119
void clearCache()
Drop all cached (non-home) resolutions.
Definition coordinator.impl.h:114
Combined lookup over the home-node directory and the local LRU cache.
Definition lookup.h:27
A single location record: the last-known node for an entity along with whether that node is this rank...
Definition record.h:28