Committed by
Gerrit Code Review
Exception and Preconditions Netconf Refactoring
Change-Id: I3cb4abee2c70138e37160b68418e71bb5f52e1a5
Showing
3 changed files
with
11 additions
and
14 deletions
... | @@ -106,17 +106,16 @@ public class NetconfSessionImpl implements NetconfSession { | ... | @@ -106,17 +106,16 @@ public class NetconfSessionImpl implements NetconfSession { |
106 | deviceInfo.name(), deviceInfo.password()); | 106 | deviceInfo.name(), deviceInfo.password()); |
107 | } | 107 | } |
108 | } catch (IOException e) { | 108 | } catch (IOException e) { |
109 | - log.error("Authentication connection to device " + | 109 | + log.error("Authentication connection to device {} failed: {} ", |
110 | - deviceInfo.getDeviceId() + " failed:" + | 110 | + deviceInfo.getDeviceId(), e.getMessage()); |
111 | - e.getMessage()); | ||
112 | throw new NetconfException("Authentication connection to device " + | 111 | throw new NetconfException("Authentication connection to device " + |
113 | deviceInfo.getDeviceId() + " failed", e); | 112 | deviceInfo.getDeviceId() + " failed", e); |
114 | } | 113 | } |
115 | 114 | ||
116 | connectionActive = true; | 115 | connectionActive = true; |
117 | Preconditions.checkArgument(isAuthenticated, | 116 | Preconditions.checkArgument(isAuthenticated, |
118 | - "Authentication to device {} with username " + | 117 | + "Authentication to device %s with username " + |
119 | - "{} Failed", | 118 | + "%s failed", |
120 | deviceInfo.getDeviceId(), deviceInfo.name()); | 119 | deviceInfo.getDeviceId(), deviceInfo.name()); |
121 | startSshSession(); | 120 | startSshSession(); |
122 | } | 121 | } |
... | @@ -132,8 +131,7 @@ public class NetconfSessionImpl implements NetconfSession { | ... | @@ -132,8 +131,7 @@ public class NetconfSessionImpl implements NetconfSession { |
132 | this.addDeviceOutputListener(new NetconfDeviceOutputEventListenerImpl(deviceInfo)); | 131 | this.addDeviceOutputListener(new NetconfDeviceOutputEventListenerImpl(deviceInfo)); |
133 | sendHello(); | 132 | sendHello(); |
134 | } catch (IOException e) { | 133 | } catch (IOException e) { |
135 | - log.error("Failed to create ch.ethz.ssh2.Session session:" + | 134 | + log.error("Failed to create ch.ethz.ssh2.Session session:", e); |
136 | - e.getMessage()); | ||
137 | throw new NetconfException("Failed to create ch.ethz.ssh2.Session session with device" + | 135 | throw new NetconfException("Failed to create ch.ethz.ssh2.Session session with device" + |
138 | deviceInfo, e); | 136 | deviceInfo, e); |
139 | } | 137 | } |
... | @@ -434,7 +432,7 @@ public class NetconfSessionImpl implements NetconfSession { | ... | @@ -434,7 +432,7 @@ public class NetconfSessionImpl implements NetconfSession { |
434 | return true; | 432 | return true; |
435 | } | 433 | } |
436 | } | 434 | } |
437 | - log.warn("Device " + deviceInfo + "has error in reply {}", reply); | 435 | + log.warn("Device {} has error in reply {}", deviceInfo, reply); |
438 | return false; | 436 | return false; |
439 | } | 437 | } |
440 | 438 | ||
... | @@ -445,8 +443,8 @@ public class NetconfSessionImpl implements NetconfSession { | ... | @@ -445,8 +443,8 @@ public class NetconfSessionImpl implements NetconfSession { |
445 | Optional<Integer> messageId = event.getMessageID(); | 443 | Optional<Integer> messageId = event.getMessageID(); |
446 | if (!messageId.isPresent()) { | 444 | if (!messageId.isPresent()) { |
447 | errorReplies.add(event.getMessagePayload()); | 445 | errorReplies.add(event.getMessagePayload()); |
448 | - log.error("Device " + event.getDeviceInfo() + | 446 | + log.error("Device {} sent error reply {}", |
449 | - " sent error reply " + event.getMessagePayload()); | 447 | + event.getDeviceInfo(), event.getMessagePayload()); |
450 | return; | 448 | return; |
451 | } | 449 | } |
452 | CompletableFuture<String> completedReply = | 450 | CompletableFuture<String> completedReply = | ... | ... |
... | @@ -202,7 +202,7 @@ public class NetconfStreamThread extends Thread implements NetconfStreamHandler | ... | @@ -202,7 +202,7 @@ public class NetconfStreamThread extends Thread implements NetconfStreamHandler |
202 | } | 202 | } |
203 | } | 203 | } |
204 | } catch (IOException e) { | 204 | } catch (IOException e) { |
205 | - log.warn("Error in reading from the session for device " + netconfDeviceInfo, e); | 205 | + log.warn("Error in reading from the session for device {} ", netconfDeviceInfo, e); |
206 | throw new RuntimeException(new NetconfException("Error in reading from the session for device {}" + | 206 | throw new RuntimeException(new NetconfException("Error in reading from the session for device {}" + |
207 | netconfDeviceInfo, e)); | 207 | netconfDeviceInfo, e)); |
208 | //TODO should we send a socket closed message to listeners ? | 208 | //TODO should we send a socket closed message to listeners ? | ... | ... |
... | @@ -145,9 +145,8 @@ public class NetconfDeviceProvider extends AbstractProvider | ... | @@ -145,9 +145,8 @@ public class NetconfDeviceProvider extends AbstractProvider |
145 | public boolean isReachable(DeviceId deviceId) { | 145 | public boolean isReachable(DeviceId deviceId) { |
146 | NetconfDevice netconfDevice = controller.getNetconfDevice(deviceId); | 146 | NetconfDevice netconfDevice = controller.getNetconfDevice(deviceId); |
147 | if (netconfDevice == null) { | 147 | if (netconfDevice == null) { |
148 | - log.debug("Requested device id: " | 148 | + log.debug("Requested device id: {} is not associated to any " + |
149 | - + deviceId.toString() | 149 | + "NETCONF Device", deviceId.toString()); |
150 | - + " is not associated to any NETCONF Device"); | ||
151 | return false; | 150 | return false; |
152 | } | 151 | } |
153 | return netconfDevice.isActive(); | 152 | return netconfDevice.isActive(); | ... | ... |
-
Please register or login to post a comment