Andrea Campanella
Committed by Gerrit Code Review

Exception and Preconditions Netconf Refactoring

Change-Id: I3cb4abee2c70138e37160b68418e71bb5f52e1a5
......@@ -106,17 +106,16 @@ public class NetconfSessionImpl implements NetconfSession {
deviceInfo.name(), deviceInfo.password());
}
} catch (IOException e) {
log.error("Authentication connection to device " +
deviceInfo.getDeviceId() + " failed:" +
e.getMessage());
log.error("Authentication connection to device {} failed: {} ",
deviceInfo.getDeviceId(), e.getMessage());
throw new NetconfException("Authentication connection to device " +
deviceInfo.getDeviceId() + " failed", e);
}
connectionActive = true;
Preconditions.checkArgument(isAuthenticated,
"Authentication to device {} with username " +
"{} Failed",
"Authentication to device %s with username " +
"%s failed",
deviceInfo.getDeviceId(), deviceInfo.name());
startSshSession();
}
......@@ -132,8 +131,7 @@ public class NetconfSessionImpl implements NetconfSession {
this.addDeviceOutputListener(new NetconfDeviceOutputEventListenerImpl(deviceInfo));
sendHello();
} catch (IOException e) {
log.error("Failed to create ch.ethz.ssh2.Session session:" +
e.getMessage());
log.error("Failed to create ch.ethz.ssh2.Session session:", e);
throw new NetconfException("Failed to create ch.ethz.ssh2.Session session with device" +
deviceInfo, e);
}
......@@ -434,7 +432,7 @@ public class NetconfSessionImpl implements NetconfSession {
return true;
}
}
log.warn("Device " + deviceInfo + "has error in reply {}", reply);
log.warn("Device {} has error in reply {}", deviceInfo, reply);
return false;
}
......@@ -445,8 +443,8 @@ public class NetconfSessionImpl implements NetconfSession {
Optional<Integer> messageId = event.getMessageID();
if (!messageId.isPresent()) {
errorReplies.add(event.getMessagePayload());
log.error("Device " + event.getDeviceInfo() +
" sent error reply " + event.getMessagePayload());
log.error("Device {} sent error reply {}",
event.getDeviceInfo(), event.getMessagePayload());
return;
}
CompletableFuture<String> completedReply =
......
......@@ -202,7 +202,7 @@ public class NetconfStreamThread extends Thread implements NetconfStreamHandler
}
}
} catch (IOException e) {
log.warn("Error in reading from the session for device " + netconfDeviceInfo, e);
log.warn("Error in reading from the session for device {} ", netconfDeviceInfo, e);
throw new RuntimeException(new NetconfException("Error in reading from the session for device {}" +
netconfDeviceInfo, e));
//TODO should we send a socket closed message to listeners ?
......
......@@ -145,9 +145,8 @@ public class NetconfDeviceProvider extends AbstractProvider
public boolean isReachable(DeviceId deviceId) {
NetconfDevice netconfDevice = controller.getNetconfDevice(deviceId);
if (netconfDevice == null) {
log.debug("Requested device id: "
+ deviceId.toString()
+ " is not associated to any NETCONF Device");
log.debug("Requested device id: {} is not associated to any " +
"NETCONF Device", deviceId.toString());
return false;
}
return netconfDevice.isActive();
......