Skip to content

[Studio] feat: Route Change Event Detection and Notification System #10635

Description

@zhaohai666

[studio] feat: Route Change Event Detection and Notification System

Background

This is the fourth atomic PR in the RIP-2 (Proxy Admin Interface) series. It implements a real-time route change monitoring system that enables admin clients to subscribe to topic routing changes via server-streaming gRPC.

Design Proposal

Event Detection

  • RouteChangeEventDetector: Periodically polls the TopicRouteService for route state changes. Uses a snapshot-diffing approach:
    1. Capture a TopicRouteSnapshot at each polling interval
    2. Compare with the previous snapshot to detect additions, removals, and modifications
    3. Emit RouteChangeEvent objects for each detected change

Event Notification

  • RouteChangeNotifier: Manages subscriber lifecycle and event dispatch:
    • Subscribers register via the WatchRouteChange streaming RPC
    • Events are dispatched asynchronously to all active subscribers
    • Supports topic-level filtering (subscribe to specific topics or all)
    • Handles subscriber disconnection gracefully with cleanup

Data Models

  • RouteChangeEvent: Immutable event object containing event type, topic name, timestamp, and before/after route data
  • RouteChangeEventType: Enum — TOPIC_ADDED, TOPIC_REMOVED, ROUTE_CHANGED, BROKER_CHANGED
  • TopicRouteSnapshot: Point-in-time capture of all topic routes, used for diffing

Integration with TopicRouteService

  • Modified TopicRouteService to expose a change signal (version counter) that the detector can poll efficiently without full route table comparison

Scope

File Type Description
RouteChangeEventDetector.java New Change detection engine
RouteChangeNotifier.java New Subscriber management and dispatch
RouteChangeEvent.java New Event data model
RouteChangeEventType.java New Event type enumeration
TopicRouteSnapshot.java New Route state snapshot
TopicRouteService.java Modified Change signal exposure
RouteChangeEventDetectorTest.java New Detector tests (610 lines)
RouteChangeNotifierTest.java New Notifier tests (531 lines)
RouteChangeEventTest.java New Event model tests
TopicRouteSnapshotTest.java New Snapshot tests

Total: 10 files, +2414 lines

Dependencies

Testing

  • Detector tests: single change, batch changes, no-change polling, concurrent modifications
  • Notifier tests: subscriber add/remove, event dispatch, filtering, disconnection cleanup
  • Model tests: immutability, equality, serialization

Branch

feature/rip-2-pr4-route-change-event

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions