Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,16 @@ public ServerGrpcChannelBackoffResetHandler(HelixAdmin helixAdmin, String cluste
@Override
public synchronized void onInstanceConfigChange(List<InstanceConfig> instanceConfigs,
NotificationContext context) {
// Only process INIT (listener registration) and CALLBACK (ZK data/child change).
// Ignore FINALIZE (listener unregistration) and other types.

// INIT: first callback when the listener is registered (full cluster snapshot).
// isChildChange: an instance ZK node was added or removed under /CONFIGS/PARTICIPANT.
// Both require a full scan to rebuild _shuttingDownServers from the current cluster state.
NotificationContext.Type type = context.getType();
if (type == NotificationContext.Type.INIT || context.getIsChildChange()) {
handleFullScan();
} else {
} else if (type == NotificationContext.Type.CALLBACK) {
Comment thread
timothy-e marked this conversation as resolved.
// An existing instance's config changed (e.g. IS_SHUTDOWN_IN_PROGRESS toggled).
// pathChanged is the ZK path of the specific instance that changed.
String pathChanged = context.getPathChanged();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,22 @@ private NotificationContext createCallbackContextForInstance(String instanceId)
return context;
}

@Test
public void testFinalizeNotificationIsNoOp() {
// Simulate a FINALIZE notification where pathChanged is null. The listener should ignore this.
_handler.onInstanceConfigChange(Collections.emptyList(), createFinalizeContextWithNullPath());

verify(_mailboxService, never()).resetConnectBackoff(any(), anyInt());
verify(_helixAdmin, never()).getInstancesInCluster(any());
}

private NotificationContext createFinalizeContextWithNullPath() {
NotificationContext context = new NotificationContext(_helixManager);
context.setType(NotificationContext.Type.FINALIZE);
// pathChanged is not set, so getPathChanged() returns null
return context;
}

private NotificationContext createInitContext() {
NotificationContext context = new NotificationContext(_helixManager);
context.setType(NotificationContext.Type.INIT);
Expand Down
Loading