Skip to content

Commit 84d1ffe

Browse files
committed
minor changes/cleaning up
1 parent 678d127 commit 84d1ffe

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

interop-testing/src/test/java/io/grpc/testing/integration/TrafficControlProxy.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public final class TrafficControlProxy {
5353
private static final int DEFAULT_DELAY_NANOS = 200 * 1000 * 1000;
5454
private static final Logger logger = Logger.getLogger(TrafficControlProxy.class.getName());
5555

56-
// TODO: make ports arguments (and probably loopback/ip as well)
57-
private String loopback = "127.0.0.1";
56+
// TODO: make host and ports arguments
57+
private String localhost = "127.0.0.1";
5858
private int proxyPort = 5050;
5959
private int serverPort = 5001;
6060
private int queueLength;
@@ -90,7 +90,7 @@ public TrafficControlProxy(int targetBps, int targetLatency, TimeUnit latencyUni
9090
}
9191

9292
/**
93-
* Starts a thread that waits for client and server and start reader/writer threads.
93+
* Starts a new thread that waits for client and server and start reader/writer threads.
9494
*/
9595
public void start() throws IOException {
9696
// ClientAcceptor uses a ServerSocket server so that the client can connect to the proxy as it
@@ -99,14 +99,14 @@ public void start() throws IOException {
9999
logger.info("Starting new proxy on port " + proxyPort + " with Queue Length " + queueLength);
100100
clientAcceptor = new ServerSocket();
101101
clientAcceptor.setReuseAddress(true);
102-
clientAcceptor.bind(new InetSocketAddress(loopback, proxyPort));
102+
clientAcceptor.bind(new InetSocketAddress(localhost, proxyPort));
103103
executor.submit(new Runnable() {
104104
@Override
105105
public void run() {
106106
try {
107107
clientSock = clientAcceptor.accept();
108108
serverSock = new Socket();
109-
serverSock.connect(new InetSocketAddress(loopback, serverPort));
109+
serverSock.connect(new InetSocketAddress(localhost, serverPort));
110110
startWorkers();
111111
} catch (IOException e) {
112112
throw new RuntimeException(e);
@@ -187,7 +187,9 @@ public void run() {
187187
}
188188
}
189189

190-
// A Delay Queue that counts by number of bytes instead of the number of elements.
190+
/**
191+
* A Delay Queue that counts by number of bytes instead of the number of elements.
192+
*/
191193
private class MessageQueue {
192194
DataInputStream inStream;
193195
DataOutputStream outStream;
@@ -221,6 +223,10 @@ void readIn() throws InterruptedException, IOException {
221223
incrementBytes(readableBytes);
222224
}
223225

226+
/**
227+
* Block until space on the queue becomes available. Returns how many bytes can be read on to
228+
* the queue
229+
*/
224230
synchronized int getNextChunk() throws InterruptedException {
225231
while (bytesQueued == queueLength) {
226232
wait();

0 commit comments

Comments
 (0)