Skip to content

Commit

Permalink
Add cluster node remove geyzer notification
Browse files Browse the repository at this point in the history
  • Loading branch information
musitdev committed Dec 22, 2023
1 parent f1a0831 commit f4bc1be
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 2 deletions.
2 changes: 2 additions & 0 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,8 @@ impl Validator {
identity_keypair.clone(),
socket_addr_space,
);

//register Geyzer notifier.
cluster_info.set_clusterinfo_notifier(cluster_info_notifier);
cluster_info.set_contact_debug_interval(config.contact_debug_interval);
cluster_info.set_entrypoints(cluster_entrypoints);
Expand Down
6 changes: 6 additions & 0 deletions geyser-plugin-interface/src/geyser_plugin_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,12 @@ pub trait GeyserPlugin: Any + Send + Sync + std::fmt::Debug {
Ok(())
}

/// Called when a cluster info is removed on gossip network.
#[allow(unused_variables)]
fn notify_clusterinfo_remove(&self, pubkey: &Pubkey) -> Result<()> {
Ok(())
}

/// Called when all accounts are notified of during startup.
fn notify_end_of_startup(&self) -> Result<()> {
Ok(())
Expand Down
41 changes: 40 additions & 1 deletion geyser-plugin-manager/src/cluster_info_notifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,45 @@ impl ClusterInfoNotifierInterface for ClusterInfoNotifierImpl {
}

fn notify_clusterinfo_remove(&self, pubkey: &Pubkey) {
todo!()
let mut measure2 = Measure::start("geyser-plugin-notify_plugins_of_cluster_info_update");
let plugin_manager = self.plugin_manager.read().unwrap();

if plugin_manager.plugins.is_empty() {
return;
}
for plugin in plugin_manager.plugins.iter() {
let mut measure = Measure::start("geyser-plugin-remove-cluster_info");
match plugin.notify_clusterinfo_remove(pubkey) {
Err(err) => {
error!(
"Failed to remove cluster_info {}, error: {} to plugin {}",
bs58::encode(pubkey).into_string(),
err,
plugin.name()
)
}
Ok(_) => {
trace!(
"Successfully remove cluster_info {} to plugin {}",
bs58::encode(pubkey).into_string(),
plugin.name()
);
}
}
measure.stop();
inc_new_counter_debug!(
"geyser-plugin-remove-cluster_info-us",
measure.as_us() as usize,
100000,
100000
);
}
measure2.stop();
inc_new_counter_debug!(
"geyser-plugin-notify_plugins_of_cluster_info_remove-us",
measure2.as_us() as usize,
100000,
100000
);
}
}
2 changes: 2 additions & 0 deletions gossip/src/crds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,8 @@ impl Crds {
self.shards.remove(index, &value);
match value.value.data {
CrdsData::LegacyContactInfo(_) => {
//notify geyzer interface
self.notify_clusterinfo_remove(&value.value.pubkey());
self.nodes.swap_remove(&index);
}
CrdsData::Vote(_, _) => {
Expand Down
7 changes: 6 additions & 1 deletion gossip/src/crds/geyser_plugin_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,10 @@ impl Crds {

/// Notified when the AccountsDb is initialized at start when restored
/// from a snapshot.
pub fn notify_clusterinfo_remove(&self, pubkey: &Pubkey) {}
pub fn notify_clusterinfo_remove(&self, pubkey: &Pubkey) {
if let Some(clusterinfo_update_notifier) = &self.clusterinfo_update_notifier {
let notifier = &clusterinfo_update_notifier.read().unwrap();
notifier.notify_clusterinfo_remove(pubkey);
}
}
}

0 comments on commit f4bc1be

Please sign in to comment.