import com.google.common.util.concurrent.FluentFuture;
import java.math.BigDecimal;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutionException;
@Override
public ServicePathOutput setupServicePath(ServicePathInput input, ServicePathDirection direction) {
- List<Nodes> nodes = input.getNodes();
+ List<Nodes> nodes = new ArrayList<>();
+ if (input.getNodes() != null) {
+ nodes.addAll(input.getNodes());
+ }
// Register node for suppressing alarms
if (!alarmSuppressionNodeRegistration(input)) {
LOG.warn("Alarm suppresion node registration failed!!!!");
}
ConcurrentLinkedQueue<String> results = new ConcurrentLinkedQueue<>();
- Set<NodeInterface> nodeInterfaces = Sets.newConcurrentHashSet();
+ Map<NodeInterfaceKey,NodeInterface> nodeInterfaces = new ConcurrentHashMap<>();
Set<String> nodesProvisioned = Sets.newConcurrentHashSet();
CopyOnWriteArrayList<Nodes> otnNodesProvisioned = new CopyOnWriteArrayList<>();
ServiceListTopology topology = new ServiceListTopology();
.setOtuInterfaceId(createdOtuInterfaces)
.setOduInterfaceId(createdOduInterfaces)
.setOchInterfaceId(createdOchInterfaces);
- nodeInterfaces.add(nodeInterfaceBuilder.build());
+ NodeInterface nodeInterface = nodeInterfaceBuilder.build();
+ nodeInterfaces.put(nodeInterface.key(),nodeInterface);
}));
try {
forkJoinTask.get();
LOG.error("Alarm suppresion node removal failed!!!!");
}
ServicePathOutputBuilder setServBldr = new ServicePathOutputBuilder()
- .setNodeInterface(new ArrayList<>(nodeInterfaces))
+ .setNodeInterface(nodeInterfaces)
.setSuccess(success.get())
.setResult(String.join("\n", results));
return setServBldr.build();
@Override
public RendererRollbackOutput rendererRollback(RendererRollbackInput input) {
boolean success = true;
- List<FailedToRollback> failedToRollbackList = new ArrayList<>();
- for (NodeInterface nodeInterfaces : input.getNodeInterface()) {
+ Map<FailedToRollbackKey,FailedToRollback> failedToRollbackList = new HashMap<>();
+ for (NodeInterface nodeInterfaces : input.nonnullNodeInterface().values()) {
List<String> failedInterfaces = new ArrayList<>();
String nodeId = nodeInterfaces.getNodeId();
for (String connectionId : nodeInterfaces.getConnectionId()) {
failedInterfaces.add(interfaceId);
}
}
- failedToRollbackList.add(new FailedToRollbackBuilder().withKey(new FailedToRollbackKey(nodeId))
- .setNodeId(nodeId).setInterface(failedInterfaces).build());
+ FailedToRollback failedToRollack = new FailedToRollbackBuilder().withKey(new FailedToRollbackKey(nodeId))
+ .setNodeId(nodeId).setInterface(failedInterfaces).build();
+ failedToRollbackList.put(failedToRollack.key(),failedToRollack);
}
return new RendererRollbackOutputBuilder().setSuccess(success).setFailedToRollback(failedToRollbackList)
.build();
NodelistBuilder nodeListBuilder = new NodelistBuilder()
.withKey(new NodelistKey(input.getServiceName()))
.setServiceName(input.getServiceName());
- List<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service
+ Map<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service
+ .nodelist.nodelist.NodesKey,
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102.service
.nodelist.nodelist.Nodes> nodeList =
- new ArrayList<>();
- for (Nodes node : input.getNodes()) {
- nodeList.add(
- new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
- .service.nodelist.nodelist.NodesBuilder()
- .setNodeId(node.getNodeId()).build());
+ new HashMap<>();
+ if (input.getNodes() != null) {
+ for (Nodes node : input.getNodes()) {
+ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
+ .service.nodelist.nodelist.Nodes nodes =
+ new org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
+ .service.nodelist.nodelist.NodesBuilder().setNodeId(node.getNodeId()).build();
+ nodeList.put(nodes.key(),nodes);
+ }
}
nodeListBuilder.setNodes(nodeList);
InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
.service.nodelist.Nodelist> nodeListIID =
- InstanceIdentifier.create(ServiceNodelist.class).child(
- org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression
- .rev171102.service.nodelist.Nodelist.class,
- new NodelistKey(input.getServiceName()));
+ InstanceIdentifier.create(ServiceNodelist.class)
+ .child(org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
+ .service.nodelist.Nodelist.class, new NodelistKey(input.getServiceName()));
final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction();
writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, nodeListIID, nodeListBuilder.build());
FluentFuture<? extends @NonNull CommitInfo> commit = writeTransaction.commit();
private boolean alarmSuppressionNodeRemoval(String serviceName) {
InstanceIdentifier<org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
.service.nodelist.Nodelist> nodeListIID =
- InstanceIdentifier.create(ServiceNodelist.class).child(
- org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression
- .rev171102.service.nodelist.Nodelist.class,
- new NodelistKey(serviceName));
+ InstanceIdentifier.create(ServiceNodelist.class)
+ .child(org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.alarmsuppression.rev171102
+ .service.nodelist.Nodelist.class, new NodelistKey(serviceName));
final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction();
writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, nodeListIID);
FluentFuture<? extends @NonNull CommitInfo> commit = writeTransaction.commit();