How lunar-huang/a-distributed-flight-information-system works
Main Components
• Server (C-based):
• Core UDP server (server.c) which listens for incoming client requests and spawns new threads per request.
• Flight Service – implemented in flight_service.c and flight_service.h – handling queries, reservations, and business logic.
• Callback Handler – manages client callback registrations to push updates (updates on seat availability).
• Data Storage – modules in data_storage.c (and related SQL scripts) that interface with the MariaDB database.
• Thread Pool – implemented via thread_pool.c to support concurrent request handling.
• Marshalling/Unmarshalling – these modules (marshalling.c and unmarshalling.c) transform data between C-struct representations and byte streams.
• Database Connect and SQL integration – see database_connect.c, database_insert.sql and flight_system.sql.
• Client (Java-based):
• Client GUI and logic – with files Client.java, Flight.java, Message.java, and UserInterface.java which capture the client-side interface.
• Callback mechanism interface – enabling the server to notify the client of changes.
• Communication Infrastructure:
• The message structure encoding (including message type, request id, data_length, and flight data) which ties client and server communications.
• UDP socket communication with directional flows.
• External/Supporting Components:
• Database (MariaDB) hosting the flights table and supporting SQL operations.
• Configuration for fault tolerance that selects between “at-least-once” and “at-most-once” semantics.
• Build scripts and Makefile in your server folder for compiling and linking.
Relationships and Data Flow
• The client initiates requests via its GUI. These requests are constructed into the defined message structure (with marshalling handled by Java code on the client side) and sent over UDP to the server.
• The Server receives these messages through its socket interface and spawns a new thread (or uses a thread from the thread pool) to handle each incoming request.
• Inside the server, the request is processed by the flight service and possibly routed through modules:
• For queries and reservation requests, the service interacts with the database via data_storage and database_connect modules.
• Marshalling/unmarshalling layers transform data between network byte streams and internal C structures.
• Callback functionality: when seat or baggage availability changes, the callback_handler is invoked to communicate updates back to registered clients.
• The server then sends a reply (remarshalled into a byte message) back to the client over UDP.
• The database component is central to storing flight details and is updated based on operations (e.g., making seat reservations).
Architectural Patterns & Design Principles
• Modular Design: Each functional aspect (communication, flight service logic, data persistence, thread management, marshalling) is implemented in its own module.
• Client-Server Pattern: With clear separation of concerns between the Java-based client (presentation, request generation, callback reception) and C-based server (business logic and data processing).
• Concurrency: The use of multi-threading and thread pools ensures the server can handle multiple simultaneous client connections.
• Fault Tolerance: The design provides alternative request handling semantics (at-least-once vs. at-most-once) to ensure resiliency.
• Network Communication Focus: Using UDP sockets and a clear message protocol, with marshalling routines to ensure data consistency.
Additional Details to Emphasize
• Notation for fault tolerance choices (e.g., indicate on the server block that it supports at-least-once and at-most-once processing strategies).
• Multi-threading aspect in the server by depicting a “Thread Pool” sub-component.
• Mention the significance of the marshalling/unmarshalling modules that convert messages between byte streams and application-level data.
• That the system uses UDP sockets for network communication and illustrate how the client's requests are handled concurrently by the server.