Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/main/java/org/fluentd/logger/sender/RawSocketSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.util.Map;

Expand All @@ -38,8 +37,6 @@ public class RawSocketSender implements Sender {

private MessagePack msgpack;

private SocketAddress server;

private Socket socket;

private int timeout;
Expand All @@ -52,6 +49,10 @@ public class RawSocketSender implements Sender {

private String name;

private final String host;

private final int port;

private ErrorHandler errorHandler = DEFAULT_ERROR_HANDLER;

public RawSocketSender() {
Expand All @@ -71,7 +72,8 @@ public RawSocketSender(String host, int port, int timeout, int bufferCapacity, R
msgpack = new MessagePack();
msgpack.register(Event.class, Event.EventTemplate.INSTANCE);
pendings = ByteBuffer.allocate(bufferCapacity);
server = new InetSocketAddress(host, port);
this.host = host;
this.port = port;
this.reconnector = reconnector;
name = String.format("%s_%d_%d_%d", host, port, timeout, bufferCapacity);
this.timeout = timeout;
Expand All @@ -80,7 +82,7 @@ public RawSocketSender(String host, int port, int timeout, int bufferCapacity, R
private void connect() throws IOException {
try {
socket = new Socket();
socket.connect(server, timeout);
socket.connect(new InetSocketAddress(host, port), timeout);
out = new BufferedOutputStream(socket.getOutputStream());
} catch (IOException e) {
throw e;
Expand Down Expand Up @@ -153,7 +155,7 @@ private boolean flushBuffer() {
if (pendings.position() == 0) {
return true;
} else {
LOG.error("Cannot send logs to " + server.toString());
LOG.error("Cannot send logs to " + socket.getInetAddress().toString());
}
}

Expand Down