import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutionException;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.OtnServicePathOutputBuilder;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.az.api.info.AEndApiInfo;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.az.api.info.ZEndApiInfo;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OpucnTribSlotDef;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.OpucnTribSlotDef;
import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210930.link.tp.LinkTp;
import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210930.link.tp.LinkTpBuilder;
import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210930.node.interfaces.NodeInterface;
private final CrossConnect crossConnect;
private final OpenRoadmInterfaces openRoadmInterfaces;
private final DeviceTransactionManager deviceTransactionManager;
- private final NetworkModelService networkModelService;
public OtnDeviceRendererServiceImpl(OpenRoadmInterfaceFactory openRoadmInterfaceFactory, CrossConnect crossConnect,
OpenRoadmInterfaces openRoadmInterfaces,
this.crossConnect = crossConnect;
this.openRoadmInterfaces = openRoadmInterfaces;
this.deviceTransactionManager = deviceTransactionManager;
- this.networkModelService = networkModelService;
}
//TODO Align log messages and returned results messages
String connectionNumber = "";
switch (serviceType) {
case StringConstants.SERVICE_TYPE_100GE_S:
- connectionNumber = getConnectionNumber(null, node, networkTp, "ODU4");
+ connectionNumber = getConnectionNumber(node, networkTp, "ODU4");
break;
case StringConstants.SERVICE_TYPE_100GE_M:
- connectionNumber = getConnectionNumber(input.getServiceName(), node, networkTp, "ODU4");
+ connectionNumber = getConnectionNumber(node, networkTp, "ODU4");
otnLinkTps.add(new LinkTpBuilder()
.setNodeId(nodeId)
.setTpId(networkTp)
if (node.getClientTp() == null && node.getNetwork2Tp() != null) {
interfacesToDelete.add(networkTp + "-ODU4");
interfacesToDelete.add(node.getNetwork2Tp() + "-ODU4");
- connectionNumber = getConnectionNumber(null, node, networkTp, "ODU4");
+ connectionNumber = getConnectionNumber(node, networkTp, "ODU4");
}
break;
case StringConstants.SERVICE_TYPE_ODUC2:
if (node.getClientTp() == null && node.getNetwork2Tp() != null) {
interfacesToDelete.add(networkTp + "-" + serviceType);
interfacesToDelete.add(node.getNetwork2Tp() + "-" + serviceType);
- connectionNumber = getConnectionNumber(null, node, networkTp, serviceType);
+ connectionNumber = getConnectionNumber(node, networkTp, serviceType);
}
break;
case StringConstants.SERVICE_TYPE_10GE:
- connectionNumber = getConnectionNumber(input.getServiceName(), node, networkTp, "ODU2e");
+ connectionNumber = getConnectionNumber(node, networkTp, "ODU2e");
otnLinkTps.add(new LinkTpBuilder()
.setNodeId(nodeId)
.setTpId(networkTp)
.build());
break;
case StringConstants.SERVICE_TYPE_1GE:
- connectionNumber = getConnectionNumber(input.getServiceName(), node, networkTp, "ODU0");
+ connectionNumber = getConnectionNumber(node, networkTp, "ODU0");
otnLinkTps.add(new LinkTpBuilder()
.setNodeId(nodeId)
.setTpId(networkTp)
.build();
}
- private String getConnectionNumber(String serviceName, Nodes node, String networkTp, String oduType) {
+ private String getConnectionNumber(Nodes node, String networkTp, String oduType) {
List<String> list1 = new ArrayList<>();
List<String> list2 = new ArrayList<>(Arrays.asList("x"));
if (node.getClientTp() != null) {
} else {
return "";
}
- if (serviceName != null) {
- list1.add(serviceName);
- list2.add(serviceName);
- }
list1.addAll(list2);
return String.join("-", list1);
}
apiInfoZ = input.getZEndApiInfo();
}
// check if the node is mounted or not?
- List<String> createdEthInterfaces = new ArrayList<>();
- List<String> createdOduInterfaces = new ArrayList<>();
+ Set<String> createdEthInterfaces = new HashSet<>();
+ Set<String> createdOduInterfaces = new HashSet<>();
switch (input.getServiceRate().intValue()) {
case 1:
LOG.info("Input service is 1G");
createdOduInterfaces.add(
// suppporting interface?, payload ?
openRoadmInterfaceFactory.createOpenRoadmOdu2eInterface(node.getNodeId(),
- node.getClientTp(), input.getServiceName(), false, input.getTribPortNumber(),
+ node.getClientTp(), false, input.getTribPortNumber(),
input.getTribSlot(), apiInfoA, apiInfoZ, PT_03));
}
createdOduInterfaces.add(
// supporting interface? payload ?
openRoadmInterfaceFactory.createOpenRoadmOdu2eInterface(node.getNodeId(), node.getNetworkTp(),
- input.getServiceName(), true, input.getTribPortNumber(), input.getTribSlot(), null,
+ true, input.getTribPortNumber(), input.getTribSlot(), null,
null, null));
linkTpList.add(
new LinkTpBuilder().setNodeId(node.getNodeId()).setTpId(node.getNetworkTp()).build());
createdOduInterfaces.add(
// supporting interface? payload ?
openRoadmInterfaceFactory.createOpenRoadmOdu2eInterface(node.getNodeId(),
- node.getNetwork2Tp(), input.getServiceName(), true, input.getTribPortNumber(),
+ node.getNetwork2Tp(), true, input.getTribPortNumber(),
input.getTribSlot(), null, null, null));
linkTpList.add(
new LinkTpBuilder().setNodeId(node.getNodeId()).setTpId(node.getNetworkTp()).build());
LOG.info("Input service is 100G");
// Take the first and last value in the list of OpucnTribSlot (assuming SH would provide
// min and max value only, size two)
- OpucnTribSlotDef minOpucnTs = OpucnTribSlotDef.getDefaultInstance(
- input.getOpucnTribSlots().get(0).getValue());
- OpucnTribSlotDef maxOpucnTs = OpucnTribSlotDef.getDefaultInstance(
- input.getOpucnTribSlots().get(1).getValue());
+ OpucnTribSlotDef minOpucnTs = input.getOpucnTribSlots().stream()
+ .min((ts1, ts2) -> ts1.getValue().compareTo(ts2.getValue())).get();
+ OpucnTribSlotDef maxOpucnTs = input.getOpucnTribSlots().stream()
+ .max((ts1, ts2) -> ts1.getValue().compareTo(ts2.getValue())).get();
if (node.getClientTp() != null) {
createdEthInterfaces.add(openRoadmInterfaceFactory.createOpenRoadmEth100GInterface(
node.getNodeId(), node.getClientTp()));
}
// implement cross connect
- List<String> createdConnections = new ArrayList<>();
+ Set<String> createdConnections = new HashSet<>();
if (!createdOduInterfaces.isEmpty()) {
- Optional<String> connectionNameOpt = postCrossConnect(createdOduInterfaces, node);
+ Optional<String> connectionNameOpt = postCrossConnect(new ArrayList<>(createdOduInterfaces), node);
createdConnections.add(connectionNameOpt.get());
LOG.info("Created cross connects");
}
apiInfoZ = input.getZEndApiInfo();
}
// check if the node is mounted or not?
- List<String> createdEthInterfaces = new ArrayList<>();
- List<String> createdOduInterfaces = new ArrayList<>();
+ Set<String> createdEthInterfaces = new HashSet<>();
+ Set<String> createdOduInterfaces = new HashSet<>();
switch (input.getServiceRate().intValue()) {
case 100:
LOG.info("Input service is 100G");
}
// implement cross connect
- List<String> createdConnections = new ArrayList<>();
+ Set<String> createdConnections = new HashSet<>();
if (createdOduInterfaces.size() == 2) {
- Optional<String> connectionNameOpt = postCrossConnect(createdOduInterfaces, node);
+ Optional<String> connectionNameOpt = postCrossConnect(new ArrayList<>(createdOduInterfaces), node);
createdConnections.add(connectionNameOpt.get());
LOG.info("Created cross connects");
}
nodeInterfaces.add(new NodeInterfaceBuilder()
.withKey(new NodeInterfaceKey(node.getNodeId()))
.setNodeId(node.getNodeId())
- .setOduInterfaceId(List.of(
+ .setOduInterfaceId(Set.of(
// though this is odu, actually it has ODUCn interfaces
openRoadmInterfaceFactory.createOpenRoadmOtnOducnInterface(node.getNodeId(),
node.getNetworkTp(), supportingOtuInterface, tgtNode.getNodeId(), tgtNode.getNetworkTp())))