Skip to content

Conversation

@vjm
Copy link

@vjm vjm commented Jul 2, 2017

No description provided.

@vjm
Copy link
Author

vjm commented Jul 2, 2017

@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.

@jakub-bochenski
Copy link

If we add separate Logstash backend we should merge #21 too

@jakub-bochenski
Copy link

@vjm indeed #22 was only offering support for the HTTP logstash input

@jakub-bochenski
Copy link

Rebased the branch to make if FF to master

Copy link

@jakub-bochenski jakub-bochenski left a 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();

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

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());

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)

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?

@jakub-bochenski
Copy link

It would be ideal if this also supported Logstash HTTP input.
Best solution would be to add new input field to select the protocol. Easy solution would be to check for either http[s]: or tcp: in host (this pattern is already used in ES Dao)

{
logstashClientSocket = new Socket(logstashHost, logstashPort);
DataOutputStream outToServer = new DataOutputStream(logstashClientSocket.getOutputStream());
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(logstashClientSocket.getInputStream()));

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;

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;

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);
Copy link

@mwinter69 mwinter69 Jan 2, 2018

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)?

@jakub-bochenski
Copy link

Superseded by #59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants