SettableFuture<RpcResult<ReconcileOutput>> result = SettableFuture.create();
List<Long> nodeList = getAllNodes();
List<Long> nodesToReconcile = reconcileAllNodes ? nodeList :
- inputNodes.stream().distinct().map(node -> node.longValue()).collect(Collectors.toList());
+ inputNodes.stream().distinct().map(BigInteger::longValue).collect(Collectors.toList());
if (nodesToReconcile.size() > 0) {
List<Long> unresolvedNodes =
nodesToReconcile.stream().filter(node -> !nodeList.contains(node)).collect(Collectors.toList());
InstanceIdentifier<ReconciliationStateList> instanceIdentifier = InstanceIdentifier
.builder(ReconciliationState.class).child(ReconciliationStateList.class,
new ReconciliationStateListKey(new BigInteger(String.valueOf(nodeId)))).build();
- ReadOnlyTransaction tx = broker.newReadOnlyTransaction();
- try {
+ try (ReadOnlyTransaction tx = broker.newReadOnlyTransaction()) {
return tx.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier).get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Exception while reading reconciliation state for {}", nodeId, e);
- } finally {
- tx.close();
}
return Optional.absent();
}
private ListenableFuture<RpcResult<ReconcileOutput>> buildErrorResponse(String msg) {
SettableFuture<RpcResult<ReconcileOutput>> result = SettableFuture.create();
- LOG.error(msg);
+ LOG.error("Error {}", msg);
RpcError error = RpcResultBuilder.newError(RpcError.ErrorType.PROTOCOL, "reconcile", msg);
result.set(RpcResultBuilder.<ReconcileOutput>failed().withRpcError(error).build());
return result;
private List<Long> getAllNodes() {
List<OFNode> nodeList = ShellUtil.getAllNodes(broker);
- List<Long> nodes = nodeList.stream().distinct().map(node -> node.getNodeId()).collect(Collectors.toList());
+ List<Long> nodes = nodeList.stream().distinct().map(OFNode::getNodeId).collect(Collectors.toList());
return nodes;
}