CLOUDSTACK-8656: network related exception logging

This commit is contained in:
Daan Hoogland 2015-08-04 16:38:03 +02:00 committed by Daan Hoogland
parent 6fa8b7578e
commit c0534756d0
2 changed files with 22 additions and 36 deletions

View File

@ -19,7 +19,7 @@
package com.cloud.utils.net;
import com.cloud.utils.NumbersUtil;
import static com.cloud.utils.AutoCloseableUtil.closeAutoCloseable;
import java.io.BufferedReader;
import java.io.File;
@ -29,12 +29,17 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Formatter;
import org.apache.log4j.Logger;
import com.cloud.utils.NumbersUtil;
/**
* copied from the public domain utility from John Burkard.
* @author <a href="mailto:jb@eaio.com">Johann Burkard</a>
* @version 2.1.3
**/
public class MacAddress {
private static final Logger s_logger = Logger.getLogger(MacAddress.class);
private long _addr = 0;
protected MacAddress() {
@ -124,23 +129,14 @@ public class MacAddress {
}
} catch (SecurityException ex) {
s_logger.info("[ignored] security exception in static initializer of MacAddress", ex);
} catch (IOException ex) {
s_logger.info("[ignored] io exception in static initializer of MacAddress");
} finally {
if (p != null) {
if (in != null) {
try {
in.close();
} catch (IOException ex) {
}
}
try {
p.getErrorStream().close();
} catch (IOException ex) {
}
try {
p.getOutputStream().close();
} catch (IOException ex) {
}
closeAutoCloseable(in, "closing init process input stream");
closeAutoCloseable(p.getErrorStream(), "closing init process error output stream");
closeAutoCloseable(p.getOutputStream(), "closing init process std output stream");
p.destroy();
}
}
@ -184,20 +180,9 @@ public class MacAddress {
return reader.readLine();
} finally {
if (p != null) {
if (reader != null) {
try {
reader.close();
} catch (IOException ex) {
}
}
try {
p.getErrorStream().close();
} catch (IOException ex) {
}
try {
p.getOutputStream().close();
} catch (IOException ex) {
}
closeAutoCloseable(reader, "closing process input stream");
closeAutoCloseable(p.getErrorStream(), "closing process error output stream");
closeAutoCloseable(p.getOutputStream(), "closing process std output stream");
p.destroy();
}
}

View File

@ -19,6 +19,8 @@
package com.cloud.utils.nio;
import static com.cloud.utils.AutoCloseableUtil.closeAutoCloseable;
import java.io.IOException;
import java.net.ConnectException;
import java.net.InetSocketAddress;
@ -41,10 +43,10 @@ import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import org.apache.cloudstack.utils.security.SSLUtils;
import org.apache.log4j.Logger;
import org.apache.cloudstack.utils.security.SSLUtils;
import com.cloud.utils.concurrency.NamedThreadFactory;
/**
@ -208,11 +210,8 @@ public abstract class NioConnection implements Runnable {
if (s_logger.isTraceEnabled()) {
s_logger.trace("Socket " + socket + " closed on read. Probably -1 returned: " + e.getMessage());
}
try {
socketChannel.close();
socket.close();
} catch (IOException ignore) {
}
closeAutoCloseable(socketChannel, "accepting socketChannel");
closeAutoCloseable(socket, "opened socket");
return;
}
@ -334,6 +333,7 @@ public abstract class NioConnection implements Runnable {
try {
((SocketChannel)(todo.key)).close();
} catch (IOException ignore) {
s_logger.info("[ignored] socket channel");
} finally {
Link link = (Link)todo.att;
link.terminated();
@ -420,6 +420,7 @@ public abstract class NioConnection implements Runnable {
channel.close();
}
} catch (IOException ignore) {
s_logger.info("[ignored] channel");
}
}
}