WIFI-540: Added more robust exception handling to prevent crashing registration thread during

cleaning up of stale records.
Also removed the base dependencies from opensync-process that are coming from opensync-ext-cloud.
This commit is contained in:
Rahul Sharma
2020-08-26 10:36:44 -04:00
parent 5867584afb
commit 01b5d7dd5e
2 changed files with 47 additions and 52 deletions

View File

@@ -411,26 +411,32 @@ public class OpensyncCloudGatewayController {
*/ */
protected void cleanupStaleGwRecord() { protected void cleanupStaleGwRecord() {
LOG.debug("In CleanUp stale registered Gateways records "); LOG.debug("In CleanUp stale registered Gateways records ");
// Get Equipment gateway list try {
List<EquipmentGatewayRecord> eqGwRecList = eqRoutingSvc.getGateway(GatewayType.CEGW); // Get Equipment gateway list
if (eqGwRecList != null) { List<EquipmentGatewayRecord> eqGwRecList = eqRoutingSvc.getGateway(GatewayType.CEGW);
for (EquipmentGatewayRecord eqpRec : eqGwRecList) { if (eqGwRecList != null) {
if (!isGwReachable(eqpRec.getIpAddr(), eqpRec.getPort())) { for (EquipmentGatewayRecord eqpRec : eqGwRecList) {
// GW isn't reachable --> invoke deleteGw if (!isGwReachable(eqpRec.getIpAddr(), eqpRec.getPort())) {
LOG.debug("Gateway {} is not-reachable... deleting from Routing Svc", eqpRec.getHostname()); // GW isn't reachable --> invoke deleteGw
try { LOG.debug("Gateway {} is not-reachable... deleting from Routing Svc", eqpRec.getHostname());
eqRoutingSvc.deleteGateway(eqpRec.getId()); try {
} catch (RuntimeException e) { eqRoutingSvc.deleteGateway(eqpRec.getId());
// failed } catch (RuntimeException e) {
LOG.error("Failed to delete Equipment Gateway (name={}) from Routing Service: {}", // failed
eqpRec.getHostname(), e.getLocalizedMessage()); LOG.error("Failed to delete Equipment Gateway (name={}) from Routing Service: {}",
eqpRec.getHostname(), e.getLocalizedMessage());
}
} else {
LOG.debug("Gateway {} is reachable.", eqpRec.getHostname());
} }
} else {
LOG.debug("Gateway {} is reachable.", eqpRec.getHostname());
} }
} else {
LOG.debug("No gateways registered with Routing Service");
} }
} else { } catch (Exception ex) { // Catching Exception to prevent crashing the register thread
LOG.debug("No gateways registered with Routing Service"); LOG.debug("Generic Exception encountered when trying to cleanup " +
"the stale not-reachable GateWays. Continuing to register the new Gateway." +
" Error: {} ", ex.getMessage());
} }
} }
@@ -518,36 +524,37 @@ public class OpensyncCloudGatewayController {
*/ */
protected void cleanupStaleEqptRoutingRecord(Long equipmentId) { protected void cleanupStaleEqptRoutingRecord(Long equipmentId) {
LOG.debug("In Clean Up stale Equipment Routing record for Equipment ID {}", equipmentId); LOG.debug("In Clean Up stale Equipment Routing record for Equipment ID {}", equipmentId);
List<EquipmentRoutingRecord> eqptRoutingRecsList = eqRoutingSvc.getRegisteredRouteList(equipmentId); try {
if (eqptRoutingRecsList != null) { List<EquipmentRoutingRecord> eqptRoutingRecsList = eqRoutingSvc.getRegisteredRouteList(equipmentId);
for(EquipmentRoutingRecord eqRouting : eqptRoutingRecsList) { if (eqptRoutingRecsList != null) {
try { for (EquipmentRoutingRecord eqRouting : eqptRoutingRecsList) {
EquipmentGatewayRecord gwRec = eqRoutingSvc.getGateway(eqRouting.getGatewayId()); try {
if (gwRec != null) { EquipmentGatewayRecord gwRec = eqRoutingSvc.getGateway(eqRouting.getGatewayId());
if (!isGwReachable(gwRec.getIpAddr(), gwRec.getPort())) { if (gwRec != null) {
// GW isn't reachable --> invoke unregister if (!isGwReachable(gwRec.getIpAddr(), gwRec.getPort())) {
LOG.debug("Gateway {} is not-reachable... Deleting the equipment routing entry", gwRec.getHostname()); // GW isn't reachable --> invoke unregister
deleteUnresponiveGwRoutingRecord(eqRouting.getId(), equipmentId); LOG.debug("Gateway {} is not-reachable... Deleting the equipment routing entry", gwRec.getHostname());
deleteUnresponiveGwRoutingRecord(eqRouting.getId(), equipmentId);
} else {
LOG.debug("Gateway {} is reachable.", gwRec.getHostname());
}
} else { } else {
LOG.debug("Gateway {} is reachable.", gwRec.getHostname()); LOG.debug("Gateway with ID {} not found. Deleting the equipment routing entry ", eqRouting.getGatewayId());
deleteUnresponiveGwRoutingRecord(eqRouting.getId(), equipmentId);
} }
} else { } catch (DsEntityNotFoundException entityNotFoundException) {
LOG.debug("Gateway with ID {} not found. Deleting the equipment routing entry ", eqRouting.getGatewayId()); LOG.debug("Gateway ID: {} not found... Deleting the equipment routing entry", eqRouting.getGatewayId());
deleteUnresponiveGwRoutingRecord(eqRouting.getId(), equipmentId); deleteUnresponiveGwRoutingRecord(eqRouting.getId(), equipmentId);
} }
} catch ( DsEntityNotFoundException entityNotFoundException) {
LOG.debug("Gateway ID: {} not found... Deleting the equipment routing entry", eqRouting.getGatewayId());
deleteUnresponiveGwRoutingRecord(eqRouting.getId(), equipmentId);
} catch ( Exception genericException) {
LOG.debug("Generic Exception encountered when trying to query/delete " +
"the Gateway with ID: {}. Error: {} ", eqRouting.getGatewayId(), genericException.getMessage());
} }
} else {
LOG.debug("No gateways registered with Routing Service for Equipment ID {}", equipmentId);
} }
} catch (Exception genericException) { // Catching Exception to prevent crashing the register thread
} else { LOG.debug("Generic Exception encountered when trying to cleanup " +
LOG.debug("No gateways registered with Routing Service for Equipment ID {}", equipmentId); "the stale routing records for equipment ID: {}. Continuing to register the new RoutingRecord." +
" Error: {} ", equipmentId, genericException.getMessage());
} }
} }
private boolean deleteUnresponiveGwRoutingRecord(Long routingId, Long eqptId) { private boolean deleteUnresponiveGwRoutingRecord(Long routingId, Long eqptId) {

View File

@@ -24,23 +24,11 @@
<artifactId>opensync-ext-cloud</artifactId> <artifactId>opensync-ext-cloud</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>${tip-wlan-cloud.release.version}</version>
</dependency> </dependency>
<dependency>
<artifactId>base-container</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>${tip-wlan-cloud.release.version}</version>
</dependency>
<dependency>
<artifactId>base-client</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>${tip-wlan-cloud.release.version}</version>
</dependency>
<dependency> <dependency>
<artifactId>filestore-service</artifactId> <artifactId>filestore-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<version>${tip-wlan-cloud.release.version}</version> <version>${tip-wlan-cloud.release.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<artifactId>customer-service-remote</artifactId> <artifactId>customer-service-remote</artifactId>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>