use of org.onap.logging.filter.base.ScheduledTaskException in project so by onap.
the class ScheduledDnsLookup method performDnsLookup.
@ScheduledLogging
@Scheduled(fixedRate = 15000)
public void performDnsLookup() throws ScheduledTaskException {
String dnsUrl = System.getenv(DB_HOST);
try {
if (dnsUrl == null) {
throw new ScheduledTaskException(ErrorCode.DataError, "Database DNS is not provided. Please verify the configuration");
}
InetAddress inetAddress = java.net.InetAddress.getByName(dnsUrl);
String ipAddress = inetAddress.getHostAddress();
String currentIpAddress = dnsIpAddress.getIpAddress();
/* This is in initial state */
if (currentIpAddress == null) {
dnsIpAddress.setIpAddress(ipAddress);
return;
}
if ((ipAddress != null) && (!ipAddress.equalsIgnoreCase(currentIpAddress))) {
logger.debug("Switched Database IP Address from {} to {}", currentIpAddress, ipAddress);
softEvictConnectionPool();
dnsIpAddress.setIpAddress(ipAddress);
}
} catch (UnknownHostException e) {
logger.warn("Database DNS %s is not resolvable to an IP Address", dnsUrl);
}
}
use of org.onap.logging.filter.base.ScheduledTaskException in project so by onap.
the class ArchiveInfraRequestsScheduler method archiveInfraRequests.
protected void archiveInfraRequests(List<InfraActiveRequests> requests) throws ScheduledTaskException {
List<ArchivedInfraRequests> newArchivedReqs = new ArrayList<>();
List<InfraActiveRequests> oldInfraReqs = new ArrayList<>();
for (InfraActiveRequests iar : requests) {
ArchivedInfraRequests archivedInfra = new ArchivedInfraRequests();
try {
archivedInfra.setCloudRegion(iar.getCloudRegion());
archivedInfra.setCallBackUrl(iar.getCallBackUrl());
archivedInfra.setConfigurationId(iar.getConfigurationId());
archivedInfra.setConfigurationName(iar.getConfigurationName());
archivedInfra.setCorrelator(iar.getCorrelator());
archivedInfra.setEndTime(iar.getEndTime());
archivedInfra.setLastModifiedBy(iar.getLastModifiedBy());
archivedInfra.setNetworkId(iar.getNetworkId());
archivedInfra.setNetworkName(iar.getNetworkName());
archivedInfra.setNetworkType(iar.getNetworkType());
archivedInfra.setOperationalEnvId(iar.getOperationalEnvId());
archivedInfra.setOperationalEnvName(iar.getOperationalEnvName());
archivedInfra.setRequestUrl(iar.getRequestUrl());
archivedInfra.setProgress(iar.getProgress());
archivedInfra.setRequestAction(iar.getRequestAction());
archivedInfra.setRequestBody(iar.getRequestBody());
archivedInfra.setRequestId(iar.getRequestId());
archivedInfra.setRequestorId(iar.getRequestorId());
archivedInfra.setRequestScope(iar.getRequestScope());
archivedInfra.setRequestStatus(iar.getRequestStatus());
archivedInfra.setResponseBody(iar.getResponseBody());
archivedInfra.setServiceInstanceId(iar.getServiceInstanceId());
archivedInfra.setServiceInstanceName(iar.getServiceInstanceName());
archivedInfra.setServiceType(iar.getServiceType());
archivedInfra.setSource(iar.getSource());
archivedInfra.setStartTime(iar.getStartTime());
archivedInfra.setStatusMessage(iar.getStatusMessage());
archivedInfra.setTenantId(iar.getTenantId());
archivedInfra.setVfModuleId(iar.getVfModuleId());
archivedInfra.setVfModuleModelName(iar.getVfModuleModelName());
archivedInfra.setVfModuleName(iar.getVfModuleName());
archivedInfra.setVnfId(iar.getVnfId());
archivedInfra.setVnfName(iar.getVnfName());
archivedInfra.setVnfOutputs(iar.getVnfOutputs());
archivedInfra.setVnfParams(iar.getVnfParams());
archivedInfra.setVnfType(iar.getVnfType());
archivedInfra.setVolumeGroupId(iar.getVolumeGroupId());
archivedInfra.setVolumeGroupName(iar.getVolumeGroupName());
archivedInfra.setProductFamilyName(iar.getProductFamilyName());
archivedInfra.setTenantName(iar.getTenantName());
archivedInfra.setResourceStatusMessage(iar.getResourceStatusMessage());
archivedInfra.setWorkflowName(iar.getWorkflowName());
archivedInfra.setOperationName(iar.getOperationName());
newArchivedReqs.add(archivedInfra);
oldInfraReqs.add(iar);
} catch (Exception e) {
throw new ScheduledTaskException(ErrorCode.UnknownError, e.getMessage(), e);
}
}
logger.info("Creating archivedInfraRequest records: {}", newArchivedReqs.size());
archivedInfraRepo.saveAll(newArchivedReqs);
logger.info("Deleting InfraActiveRequest records: {}", oldInfraReqs.size());
infraActiveRepo.deleteAll(oldInfraReqs);
}
use of org.onap.logging.filter.base.ScheduledTaskException in project so by onap.
the class ASDCControllerSingleton method periodicControllerTask.
@ScheduledLogging
@Scheduled(fixedRate = 50000)
public void periodicControllerTask() throws ScheduledTaskException {
try {
final int randomNumber = new SecureRandom().nextInt(Integer.MAX_VALUE);
asdcController.setControllerName("mso-controller" + randomNumber);
if (asdcController.isStopped()) {
logger.info("{} not running will try to initialize it, currrent status: {}", asdcController.getClass().getName(), asdcController.getControllerStatus());
asdcController.initASDC();
}
} catch (final ASDCControllerException controllerException) {
throw new ScheduledTaskException(ErrorCode.UnknownError, controllerException.getMessage(), controllerException);
}
}
Aggregations