Skip to content

Commit

Permalink
singleton fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonHartley committed Feb 11, 2024
1 parent 89d58b4 commit 4e6b05a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
14 changes: 12 additions & 2 deletions coerce/src/remote/cluster/singleton/manager/lease.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,22 @@ impl<F: SingletonFactory> Handler<LeaseAck> for Manager<F> {
}

impl<F: SingletonFactory> Manager<F> {
pub async fn request_lease(&self, ctx: &ActorContext) {
pub async fn request_lease(&mut self, ctx: &ActorContext) {
if self.managers.len() == 0 {
self.on_all_managers_acknowledged(ctx).await;
return;
}

let request = RequestLease {
source_node_id: self.node_id,
};

debug!(source_node_id = self.node_id, "requesting lease");
let manager_count = self.managers.len();
debug!(
source_node_id = self.node_id,
manager_count = manager_count,
"requesting lease"
);
self.notify_managers(request, ctx).await;
}

Expand Down
2 changes: 2 additions & 0 deletions coerce/src/remote/cluster/singleton/manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ impl<F: SingletonFactory> Handler<Receive<SystemTopic>> for Manager<F> {
}

ClusterEvent::NodeAdded(node) => {
debug!(node_id = node.id, "node added");

if node.id != self.node_id && self.selector.includes(node.as_ref()) {
let mut entry = self.managers.entry(node.id);
if let Entry::Vacant(mut entry) = entry {
Expand Down
4 changes: 2 additions & 2 deletions coerce/src/sharding/coordinator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ impl PersistentActor for ShardCoordinator {
// or rebalance/rehydrate if necessary

info!(
"shard coordinator started (shard_entity={})",
&self.shard_entity
shard_entity = &self.shard_entity,
"shard coordinator started",
);

self.system_event_subscription = Some(
Expand Down
2 changes: 1 addition & 1 deletion coerce/tests/test_remote_sharding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ pub async fn test_shard_host_actor_request() {
.with_handler::<TestActor, SetStatusRequest>("SetStatusRequest")
})
.with_id(1)
.single_node()
// .single_node()
.build()
.await;

Expand Down

0 comments on commit 4e6b05a

Please sign in to comment.