-
Notifications
You must be signed in to change notification settings - Fork 0
Implementation
- ConnectionManager
- Connection
- TcpConnection
- UdpConnection
- Server
- SquallClient
- SquallClientHandler
- Set of Connections: keeps a list of open connections to server and enables
ServerandConnectionto modify connection set.
It is a singleton object so there will be only one manager while topology is running. It is thread-safe since set is synchronized.
It exchanges a protocol to define characteristics of the connection, accordingly either creates new connection or refuses it. Protocol exchange requires tackling a bit since reading is blocking: One thread waits for input and another one notes the time. If client doesn't talk for a given time, timeout occurs and waiting thread is interrupted and connection is refused. Moreover, if client doesn't follow the protocol, connection again is refused. However, if default is set, we'd not need this trick.
- stream(
ConcurrentLinkedQueue): keeps the tuples to be sent through this connection. - status: status of the connection, namely running or closed.
This is an abstract class that extends Thread to poll its queue and to send the tuples to its pair. It provides default close and tuple addition methods. However, according to exchanged protocol in the start of the connection, connection can apply filtering for which tuples to be sent.
- socket(
Socket): Communication end point. - pw(
PrintWriter): Output stream writer that is used for writing tuples.
- serverSocket(
ServerSocket): Listens for coming requests and handles new connection request via usingConnectionManager.
Passes socket information to connection manager to handle new connection.
- store(
ConcurrentLinkedQueue): Buffer of received tuples. - in(
BufferedReader): Stream to read tuples. According to configuration new tuples are put intostorefor later use or are passed to handler to be processed as soon as possible. - out(
PrintWriter): Sends heartbeat to check if server is down because reading is blocking.
- newTupleArrived: consumes new arriving tuple.