diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2019-03-20 11:32:40 +0100 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2019-03-20 13:15:39 +0100 |
commit | 77dc326d513b46969e755b76ed277150d88b875e (patch) | |
tree | 2fdff16349f7b5f4622d358fa64ead2010313c82 | |
parent | cddf79bc63fdb5213eed6a51e5fc6c7200539e0f (diff) |
Remove implementation of write() in LogConnection
3 files changed, 4 insertions, 48 deletions
diff --git a/logserver/src/main/java/com/yahoo/logserver/net/LogConnection.java b/logserver/src/main/java/com/yahoo/logserver/net/LogConnection.java index 1a9221b82a7..cfe4e425ff3 100644 --- a/logserver/src/main/java/com/yahoo/logserver/net/LogConnection.java +++ b/logserver/src/main/java/com/yahoo/logserver/net/LogConnection.java @@ -2,7 +2,6 @@ package com.yahoo.logserver.net; import com.yahoo.io.Connection; -import com.yahoo.io.Listener; import com.yahoo.io.ReadLine; import com.yahoo.log.InvalidLogFormatException; import com.yahoo.log.LogLevel; @@ -14,7 +13,6 @@ import java.nio.ByteBuffer; import java.nio.channels.SelectionKey; import java.nio.channels.SocketChannel; import java.util.HashSet; -import java.util.LinkedList; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -38,23 +36,15 @@ public class LogConnection implements Connection { private static final Set<LogConnection> activeConnections = new HashSet<>(); private final SocketChannel socket; - private final Listener listener; private final LogDispatcher dispatcher; private final ByteBuffer readBuffer = ByteBuffer.allocateDirect(READBUFFER_SIZE); - private final LinkedList<ByteBuffer> writeBufferList = new LinkedList<>(); - private ByteBuffer writeBuffer; - // counters private long totalBytesRead = 0; - private long totalBytesWritten = 0; - public LogConnection(SocketChannel socket, - Listener listener, - LogDispatcher dispatcher) { + public LogConnection(SocketChannel socket, LogDispatcher dispatcher) { this.socket = socket; - this.listener = listener; this.dispatcher = dispatcher; addToActiveSet(this); @@ -72,13 +62,6 @@ public class LogConnection implements Connection { } /** - * @return Return total number of bytes written to connection - */ - public long getTotalBytesWritten () { - return totalBytesWritten; - } - - /** * @return Return total number of bytes read from connection */ public long getTotalBytesRead () { @@ -116,34 +99,8 @@ public class LogConnection implements Connection { throw new RuntimeException("connect() is not supposed to be called"); } - public synchronized void write () throws IOException { - int bytesWritten; - do { - // if writeBufferList is not set we need to fetch the next buffer - if (writeBuffer == null) { - - // if the list is empty, signal the selector we do not need - // to do any writing for a while yet and bail - if (writeBufferList.isEmpty()) { - listener.modifyInterestOpsBatch(this, - SelectionKey.OP_WRITE, - false); - return; - } - writeBuffer = writeBufferList.removeFirst(); - } - - // invariants: we have a writeBuffer - - bytesWritten = socket.write(writeBuffer); - totalBytesWritten += bytesWritten; - - // buffer drained so we forget it and see what happens when we - // go around. if indeed we go around - if ((writeBuffer != null) && (!writeBuffer.hasRemaining())) { - writeBuffer = null; - } - } while (bytesWritten > 0); + public void write () { + throw new UnsupportedOperationException(); } public void read() throws IOException { diff --git a/logserver/src/main/java/com/yahoo/logserver/net/LogConnectionFactory.java b/logserver/src/main/java/com/yahoo/logserver/net/LogConnectionFactory.java index 7ef6f7bb942..c41484f3814 100644 --- a/logserver/src/main/java/com/yahoo/logserver/net/LogConnectionFactory.java +++ b/logserver/src/main/java/com/yahoo/logserver/net/LogConnectionFactory.java @@ -27,7 +27,6 @@ public class LogConnectionFactory implements ConnectionFactory { log.fine("New connection: " + socket); } return new LogConnection(socket, - listener, dispatcher); } } diff --git a/logserver/src/test/java/com/yahoo/logserver/net/test/LogConnectionTestCase.java b/logserver/src/test/java/com/yahoo/logserver/net/test/LogConnectionTestCase.java index 799de5ac8c6..a68b62b122b 100644 --- a/logserver/src/test/java/com/yahoo/logserver/net/test/LogConnectionTestCase.java +++ b/logserver/src/test/java/com/yahoo/logserver/net/test/LogConnectionTestCase.java @@ -150,7 +150,7 @@ public class LogConnectionTestCase { assertTrue(mock.getName().endsWith("MockHandler")); dispatcher.registerLogHandler(mock); LogConnection logConnection = - new LogConnection(sock, null, dispatcher); + new LogConnection(sock, dispatcher); try { for (int i = 0; i < 100; i++) { |