import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.reconciliation.service.rev180227.NodeReconcileState.State.FAILED;
import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.reconciliation.service.rev180227.NodeReconcileState.State.INPROGRESS;
-import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.applications.southboundcli.alarm.AlarmAgent;
import org.opendaylight.openflowplugin.applications.southboundcli.util.OFNode;
import org.opendaylight.openflowplugin.applications.southboundcli.util.ShellUtil;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
public ListenableFuture<RpcResult<ReconcileOutput>> reconcile(ReconcileInput input) {
boolean reconcileAllNodes = input.isReconcileAllNodes();
- List<BigInteger> inputNodes = input.getNodes();
+ List<Uint64> inputNodes = input.getNodes();
if (inputNodes == null) {
inputNodes = new ArrayList<>();
}
SettableFuture<RpcResult<ReconcileOutput>> result = SettableFuture.create();
List<Long> nodeList = getAllNodes();
List<Long> nodesToReconcile = reconcileAllNodes ? nodeList :
- inputNodes.stream().distinct().map(BigInteger::longValue).collect(Collectors.toList());
+ inputNodes.stream().distinct().map(Uint64::longValue).collect(Collectors.toList());
if (nodesToReconcile.size() > 0) {
List<Long> unresolvedNodes =
nodesToReconcile.stream().filter(node -> !nodeList.contains(node)).collect(Collectors.toList());
return buildErrorResponse("Error executing command reconcile. "
+ "Node(s) not found: " + String.join(", ", unresolvedNodes.toString()));
}
- List<BigInteger> inprogressNodes = new ArrayList<>();
+ List<Uint64> inprogressNodes = new ArrayList<>();
nodesToReconcile.parallelStream().forEach(nodeId -> {
Optional<ReconciliationStateList> state = getReconciliationState(nodeId);
if (state.isPresent() && state.get().getState().equals(INPROGRESS)) {
- inprogressNodes.add(new BigInteger(String.valueOf(nodeId)));
+ inprogressNodes.add(Uint64.valueOf(nodeId));
} else {
alarmAgent.raiseNodeReconciliationAlarm(nodeId);
LOG.info("Executing reconciliation for node {}", nodeId);
InstanceIdentifier<ReconciliationStateList> instanceIdentifier = InstanceIdentifier
.builder(ReconciliationState.class).child(ReconciliationStateList.class,
new ReconciliationStateListKey(new BigInteger(String.valueOf(nodeId)))).build();
- try (ReadOnlyTransaction tx = broker.newReadOnlyTransaction()) {
+ try (ReadTransaction tx = broker.newReadOnlyTransaction()) {
return tx.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier).get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Exception while reading reconciliation state for {}", nodeId, e);
}
- return Optional.absent();
+ return Optional.empty();
}
private ListenableFuture<RpcResult<ReconcileOutput>> buildErrorResponse(String msg) {
if (isSuccess) {
if (count.isPresent()) {
- Long successCount = count.get().getSuccessCount();
+ long successCount = count.get().getSuccessCount().toJava();
counterBuilder.setSuccessCount(++successCount);
LOG.debug("Reconcile success count {} for the node: {} ", successCount, nodeId);
} else {
}
} else {
if (count.isPresent()) {
- Long failureCount = count.get().getFailureCount();
+ long failureCount = count.get().getFailureCount().toJava();
counterBuilder.setFailureCount(++failureCount);
LOG.debug("Reconcile failure count {} for the node: {} ", failureCount, nodeId);
} else {
}
try {
tx.merge(LogicalDatastoreType.OPERATIONAL, instanceIdentifier, counterBuilder.build(), true);
- tx.submit().get();
+ tx.commit().get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Exception while submitting counter for {}", nodeId, e);
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Exception while reading counter for node: {}", nodeId, e);
}
- return Optional.absent();
+ return Optional.empty();
}
private void updateReconciliationState(State state) {
.setState(state);
try {
tx.merge(LogicalDatastoreType.OPERATIONAL, instanceIdentifier, stateBuilder.build(), true);
- tx.submit().get();
+ tx.commit().get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Exception while updating reconciliation state: {}", nodeId, e);
}