Skip to content

faafal/proxy-data-aggregator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Proxy Data Aggregator

Note: The components TCPServer, UDPServer, TCPClient, and UDPClient inside src/assignment-files are provided as part of the assignment specification. The Proxy and the inter-Proxy communication protocol are the author's implementation.

1. Requirements

  • Language: Java 8 (JDK 1.8)

2. Setup and Execution

Running Key-Value Servers

Component Command Format Description
Server java [TCPServer | UDPServer] -port <num> -key <name> -value <val> Starts a Key-Value store on the specified port.

Parameters:

Parameter Type Description
<num> Integer The TCP/UDP port number for listening.
<name> String The key string (no whitespaces).
<val> Integer The integer value associated with the key.

Running Clients

Component Command Format Description
Client java [TCPClient | UDPClient] -address <addr> -port <num> -command <cmd> Sends a request to the specified target.

Parameters:

Parameter Type Description
<addr> String The IP address/hostname of the target Server or Proxy.
<num> Integer The port number on which the target is listening.
<cmd> String The command string to be executed (e.g., "GET NAMES").

Running the Proxy (Solution)

Component Command Format Description
Proxy java Proxy -port <port> -server <addr> <port> ... Starts the intermediary Proxy application.

Launches the intermediary Proxy. It accepts connections from Clients (TCP/UDP) and forwards requests to the configured backend Servers or other Proxies.

Parameters:

Parameter Description
-port <port> The port number on which this Proxy will listen for incoming Client requests (supports both TCP and UDP).
-server <addr> <port> Specifies a neighbor Server or another Proxy to connect to.
Note: <addr> <port> pair can be repeated multiple times to connect to many Servers/Proxies.

Base Communication Protocol

  • Format: All communication is strictly via text strings.
  • Message Length: Commands and responses are each one line terminated by a newline character.
  • UDP Limit: The entire UDP message must fit within a single datagram (1460 bytes).

Connection Principles

  • Hybrid Protocol Support: TCPClient and UDPClient can talk both to TCPServer and UDPServer via Proxy.
  • Server Behavior: Servers do not maintain connections—they disconnect and handle subsequent requests sequentially.
  • Mesh Topology Support: Proxy supports mesh topology managing requests and preventing loop requests.
  • Auto-Discovery: Proxy implements auto discovery on start detecting wether server passed in arguments is TCPServer,UDPServer or another Proxy.
  • Data Aggregation (GET NAMES): Collects all names (keys) from network using agregating inter-proxy protocol.
  • Smart Routing (GET VALUE / SET): Propagate values across whole network so everthing is up to date.
  • Concurrency: by using ExecutorService implementation of interface Executor Proxy handles requests optimized.
  • Graceful Shutdown: by propagating command QUIT and checking it current state if it's still running or already received a QUIT request whole network can be shutted down without loop requests.

Communication Protocol

1. Inter-Proxy Communication Protocol (IPC)

This custom protocol enables routing and logic between Proxy nodes.

Handshake & Discovery

Upon startup, the Proxy connects to its neighbors to identify their type.

  • Request: PROXY SYN <port>
  • Response (Proxy): PROXY ACK
  • Response (Server): NA (or error)

Routing & Cycle Prevention

To support cyclic graphs, all routing commands include a trace of visited nodes.

  • Logic: When a Proxy receives a request, it checks if its own address is in the [visited_nodes] list.
    • If YES: Returns NA (loop detected).
    • If NO: Appends its address to the list and forwards the request to neighbors.

Internal Commands Table

Internal Command Parameters Description
PROXY SYN <port> Handshake initialization.
PROXY ACK - Handshake confirmation.
GET NAMES LIST - Requests only the immediate list of keys from a neighbor (no recursion).
PROXY GET NAMES <sender> [visited...] Full Aggregation. Recursively gathers keys from the network, avoiding visited nodes.
PROXY GET VALUE <key> <sender> [visited...] Recursive Search. Hunts for a key deep in the network.
PROXY SET <key> <val> <sender> [visited...] Recursive Write. Propagates a write request until the target server is found.

Testing

The project includes a test scenario (start.bat) that verifies:

  1. Gathering All Keys: Merging lists from TCP and UDP sources.
  2. Searching the Whole Network: Finding keys located multiple hops away.
  3. Loop Protection: Querying non-existent keys in a cyclic graph (must return NA, not hang).
  4. Remote Editing: Modifying data on a remote server via Proxy.
  5. Connecting TCP & UDP: TCP Client accessing data from a UDP Server via Proxy.

About

Distributed Key-Value Store system implementing a Proxy Mesh topology. Features hybrid TCP/UDP communication, automatic network discovery, and cycle-safe routing algorithms for data aggregation.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors