From 8db1bb7c88a0e9c9186f59cc910d5dad1eeb5d98 Mon Sep 17 00:00:00 2001 From: Ning Zhang Date: Mon, 25 Nov 2019 15:31:43 +0800 Subject: [PATCH] Unsupport operation exception in NeutronvpnManager.java 1.Unsupported operation exception handling; 2.Do not use the toString() when printing logs; Change-Id: Ifb1512a7aaa2b68595d56ee5b41b26ac3edc4a8d Signed-off-by: Ning Zhang --- .../neutronvpn/NeutronPortChangeListener.java | 6 ++-- .../netvirt/neutronvpn/NeutronvpnManager.java | 33 ++++++++++--------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronPortChangeListener.java b/neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronPortChangeListener.java index 92c8a9bd21..d7680f3413 100644 --- a/neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronPortChangeListener.java +++ b/neutronvpn/impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronPortChangeListener.java @@ -680,10 +680,8 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase

sn = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetMapIdentifier); if (sn.isPresent()) { @@ -354,11 +354,11 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even Optional sn = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, id); if (!sn.isPresent()) { - LOG.error("WithRouterFixedIP: subnetmap node for subnet {} does not exist, returning ", + LOG.error("updateSubnetNodeWithFixedIp: subnetmap node for subnet {} does not exist, returning ", subnetId.getValue()); return; } - LOG.debug("WithRouterFixedIP: Updating existing subnetmap node for subnet ID {}", + LOG.debug("updateSubnetNodeWithFixedIp: Updating existing subnetmap node for subnet ID {}", subnetId.getValue()); SubnetmapBuilder builder = new SubnetmapBuilder(sn.get()); builder.setRouterId(routerId); @@ -373,7 +373,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even subnetId.getValue()); SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, id, subnetmap); } catch (ReadFailedException | TransactionCommitFailedException e) { - LOG.error("WithRouterFixedIP: subnet map for Router FixedIp failed for node {}", + LOG.error("updateSubnetNodeWithFixedIp: subnet map for Router FixedIp failed for node {}", subnetId.getValue(), e); } finally { lock.unlock(); @@ -385,7 +385,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even Subnetmap subnetmap = null; InstanceIdentifier id = InstanceIdentifier.builder(Subnetmaps.class).child(Subnetmap.class, new SubnetmapKey(subnetId)).build(); - LOG.info("updateSubnetmapNodeWithPorts : subnetId {}, subnetMapId {}", subnetId.toString(), id.toString()); + LOG.info("updateSubnetmapNodeWithPorts: Updating subnetMap with portList for subnetId {}", subnetId.getValue()); final ReentrantLock lock = lockForUuid(subnetId); lock.lock(); try { @@ -406,9 +406,10 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even subnetId.getValue(), portId.getValue()); } if (null != directPortId) { - List directPortList = builder.getDirectPortList(); - if (null == directPortList) { - directPortList = new ArrayList<>(); + List existingDirectPortList = builder.getDirectPortList(); + List directPortList = new ArrayList<>(); + if (null != existingDirectPortList) { + directPortList.addAll(existingDirectPortList); } directPortList.add(directPortId); builder.setDirectPortList(directPortList); @@ -1265,7 +1266,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even List failStrings = associateNetworksToVpn(vpnId, networkList); if (!failStrings.isEmpty()) { LOG.error("VPN {} association to networks failed for networks: {}. ", - vpnId.getValue(), failStrings.toString()); + vpnId.getValue(), failStrings); throw new Exception(failStrings.toString()); } } @@ -1390,8 +1391,8 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even try { LOG.debug("L3VPN add RPC: VpnID {}, name {}, tenantID {}, RDList {}, iRTList {}, eRTList{}, " + "routerIdList {}, networksList {}", vpn.getId().getValue(), vpn.getName(), - vpn.getTenantId(), vpn.getRouteDistinguisher().toString(), vpn.getImportRT().toString(), - vpn.getExportRT().toString(), rtrIdsList, vpn.getNetworkIds()); + vpn.getTenantId(), vpn.getRouteDistinguisher(), vpn.getImportRT(), + vpn.getExportRT(), rtrIdsList, vpn.getNetworkIds()); List rdList = vpn.getRouteDistinguisher() != null ? new ArrayList<>(vpn.getRouteDistinguisher()) : new ArrayList<>(); @@ -1644,7 +1645,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even return; } final VpnInstance vpnInstance = VpnHelper.getVpnInstance(dataBroker, vpnId.getValue()); - LOG.debug("addSubnetToVpn: VpnInstance {}", vpnInstance.toString()); + LOG.debug("addSubnetToVpn: VpnInstance {}", vpnInstance); if (isVpnOfTypeL2(vpnInstance)) { neutronEvpnUtils.updateElanAndVpn(vpnInstance, sn.getNetworkId().getValue(), NeutronEvpnUtils.Operation.ADD); @@ -2538,7 +2539,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even if (!isExternalNetwork) { updateVpnMaps(vpnId, null, null, null, new ArrayList<>(passedNwList)); } - LOG.info("Network(s) {} associated to L3VPN {} successfully", passedNwList.toString(), vpnId.getValue()); + LOG.info("Network(s) {} associated to L3VPN {} successfully", passedNwList, vpnId.getValue()); return failedNwList; } @@ -2665,7 +2666,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even } clearFromVpnMaps(vpnId, null, new ArrayList<>(passedNwList)); LOG.info("dissociateNetworksFromVpn: Network(s) {} disassociated from L3VPN {} successfully", - passedNwList.toString(), vpnId.getValue()); + passedNwList, vpnId.getValue()); return failedNwList; } @@ -2733,7 +2734,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even try { if (neutronvpnUtils.getVpnMap(vpnId) != null) { LOG.debug("associateNetworks RPC: VpnId {}, networkList {}", vpnId.getValue(), - input.getNetworkId().toString()); + input.getNetworkId()); List netIds = input.getNetworkId(); if (netIds != null && !netIds.isEmpty()) { List failed = associateNetworksToVpn(vpnId, netIds); @@ -2872,7 +2873,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable, Even try { if (neutronvpnUtils.getVpnMap(vpnId) != null) { LOG.debug("dissociateNetworks RPC: VpnId {}, networkList {}", vpnId.getValue(), - input.getNetworkId().toString()); + input.getNetworkId()); List netIds = input.getNetworkId(); if (netIds != null && !netIds.isEmpty()) { List failed = dissociateNetworksFromVpn(vpnId, netIds); -- 2.36.6