-
Notifications
You must be signed in to change notification settings - Fork 3.8k
as per @itaiy suggested will close then try to connect. #3669
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,16 +136,14 @@ public void emit(Event event) | |
|
|
||
| private class ConsumerRunnable implements Runnable | ||
| { | ||
| private PickledGraphite pickledGraphite = new PickledGraphite( | ||
| graphiteEmitterConfig.getHostname(), | ||
| graphiteEmitterConfig.getPort(), | ||
| graphiteEmitterConfig.getBatchSize() | ||
| ); | ||
|
|
||
| @Override | ||
| public void run() | ||
| { | ||
| try { | ||
| try (PickledGraphite pickledGraphite = new PickledGraphite( | ||
| graphiteEmitterConfig.getHostname(), | ||
| graphiteEmitterConfig.getPort(), | ||
| graphiteEmitterConfig.getBatchSize() | ||
| )) { | ||
| if (!pickledGraphite.isConnected()) { | ||
| log.info("trying to connect to graphite server"); | ||
| pickledGraphite.connect(); | ||
|
|
@@ -174,12 +172,16 @@ public void run() | |
| log.error(e, e.getMessage()); | ||
| if (e instanceof InterruptedException) { | ||
| Thread.currentThread().interrupt(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What practically happens after this statement? We continue with the next iteration in the loop?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if it is interrupted it will terminate the current thread right ?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @b-slim as far as I know it will just set interrupted flag and continue executing as normal: https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#interrupt() The next blocking operation may fail immediately with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh i see you are right thanks for the catch. |
||
| break; | ||
| } else if (e instanceof SocketException) { | ||
| // This is antagonistic to general Closeable contract in Java, | ||
| // it is needed to allow re-connection in case of the socket is closed due long period of inactivity | ||
| pickledGraphite.close(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. General
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
| log.warn("Trying to re-connect to graphite server"); | ||
| pickledGraphite.connect(); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @b-slim - why did you remove |
||
| } | ||
| } | ||
| pickledGraphite.flush(); | ||
| } | ||
| catch (Exception e) { | ||
| log.error(e, e.getMessage()); | ||
|
|
||
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.
@itaiy this try will call the close once run is done.
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.
Right, I missed it, thanks :)