-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add logstash DAO #29
add logstash DAO #29
Conversation
@jakub-bochenski I opened this after discussion on #22 because the elasticsearch plugin option was forcing an http protocol message rather than TCP, which is supported in this PR (as well as the items from #28). Let me know what you think! I am using this build successfully on my Jenkins. |
If we add separate Logstash backend we should merge #21 too |
Signed-off-by: Ted Bao <ted.bao@blackboard.com>
Signed-off-by: Ted Bao <ted.bao@blackboard.com>
Signed-off-by: Haikuan Bao <hkbao2008@gmail.com>
Rebased the branch to make if FF to master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some unit tests to cover the newly added paths
Please update the README with the new backend type
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(logstashClientSocket.getInputStream())); | ||
outToServer.writeBytes(data); | ||
logstashClientSocket.setSoTimeout(10000); | ||
logstashClientSocket.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resources should be closed in finally block, or even better used in try-with-resource
block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a good idea to close the Socket before closing the outputstream?
Closing the outputtstream also closes the socket.
StringWriter sw = new StringWriter(); | ||
PrintWriter pw = new PrintWriter(sw); | ||
exc.printStackTrace(pw); | ||
throw new IOException(sw.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not chain the exception?
outToServer.close(); | ||
inFromServer.close(); | ||
} | ||
catch (Exception exc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please change this to a multi-catch with specific Exception?
It would be ideal if this also supported Logstash HTTP input. |
{ | ||
logstashClientSocket = new Socket(logstashHost, logstashPort); | ||
DataOutputStream outToServer = new DataOutputStream(logstashClientSocket.getOutputStream()); | ||
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(logstashClientSocket.getInputStream())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why opening a reader when you never read data?
|
||
final String logstashHost; | ||
final int logstashPort; | ||
Socket logstashClientSocket; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this not private? And why an instance variable?
import com.cloudbees.syslog.Facility; | ||
import com.cloudbees.syslog.MessageFormat; | ||
import com.cloudbees.syslog.Severity; | ||
import com.cloudbees.syslog.sender.UdpSyslogMessageSender; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These imports from com.cloudbees are not used
logstashClientSocket = new Socket(logstashHost, logstashPort); | ||
DataOutputStream outToServer = new DataOutputStream(logstashClientSocket.getOutputStream()); | ||
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(logstashClientSocket.getInputStream())); | ||
outToServer.writeBytes(data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The javadoc for this method says:
Each character in the string is written out, in sequence, by discarding its high eight bits.
Is this really a good idea? What if we have unicode characters (very likely to happen)?
Superseded by #59 |
No description provided.