Allow specifying maximum message size for UDP syslog server (#14)

This commit is contained in:
Kirill Temnenkov 2016-09-28 13:31:24 +03:00 committed by Jochen Schalanda
parent 3c5a920305
commit 54a5fadd1b
2 changed files with 25 additions and 1 deletions

View File

@ -69,7 +69,7 @@ public class UDPNetSyslogServer extends AbstractSyslogServer {
return;
}
byte[] receiveData = new byte[SyslogConstants.SYSLOG_BUFFER_SIZE];
byte[] receiveData = new byte[syslogBufferSize()];
handleInitialize(this);
@ -99,4 +99,11 @@ public class UDPNetSyslogServer extends AbstractSyslogServer {
handleDestroy(this);
}
private int syslogBufferSize(){
if (getConfig() instanceof UDPNetSyslogServerConfig){
return ((UDPNetSyslogServerConfig) getConfig()).getMaxMessageSize();
}
return SyslogConstants.SYSLOG_BUFFER_SIZE;
}
}

View File

@ -1,5 +1,6 @@
package org.graylog2.syslog4j.server.impl.net.udp;
import org.graylog2.syslog4j.SyslogConstants;
import org.graylog2.syslog4j.server.impl.net.AbstractNetSyslogServerConfig;
/**
@ -15,6 +16,8 @@ import org.graylog2.syslog4j.server.impl.net.AbstractNetSyslogServerConfig;
public class UDPNetSyslogServerConfig extends AbstractNetSyslogServerConfig {
private static final long serialVersionUID = -2005919161187055486L;
private int maxMessageSize = SyslogConstants.SYSLOG_BUFFER_SIZE;
public UDPNetSyslogServerConfig() {
//
}
@ -32,6 +35,20 @@ public class UDPNetSyslogServerConfig extends AbstractNetSyslogServerConfig {
this.port = port;
}
public UDPNetSyslogServerConfig(String host, int port, int maxMessageSize) {
this.host = host;
this.port = port;
this.maxMessageSize = maxMessageSize;
}
public int getMaxMessageSize() {
return maxMessageSize;
}
public void setMaxMessageSize(int maxMessageSize) {
this.maxMessageSize = maxMessageSize;
}
public Class getSyslogServerClass() {
return UDPNetSyslogServer.class;
}