Search in sources :

Example 1 with ScheduledTaskException

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);
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) ScheduledTaskException(org.onap.logging.filter.base.ScheduledTaskException) InetAddress(java.net.InetAddress) Scheduled(org.springframework.scheduling.annotation.Scheduled) ScheduledLogging(org.onap.logging.filter.base.ScheduledLogging)

Example 2 with ScheduledTaskException

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);
}
Also used : ArrayList(java.util.ArrayList) ScheduledTaskException(org.onap.logging.filter.base.ScheduledTaskException) ArchivedInfraRequests(org.onap.so.db.request.beans.ArchivedInfraRequests) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) ScheduledTaskException(org.onap.logging.filter.base.ScheduledTaskException)

Example 3 with ScheduledTaskException

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);
    }
}
Also used : ASDCControllerException(org.onap.so.asdc.client.exceptions.ASDCControllerException) SecureRandom(java.security.SecureRandom) ScheduledTaskException(org.onap.logging.filter.base.ScheduledTaskException) Scheduled(org.springframework.scheduling.annotation.Scheduled) ScheduledLogging(org.onap.logging.filter.base.ScheduledLogging)

Aggregations

ScheduledTaskException (org.onap.logging.filter.base.ScheduledTaskException)3 ScheduledLogging (org.onap.logging.filter.base.ScheduledLogging)2 Scheduled (org.springframework.scheduling.annotation.Scheduled)2 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 SecureRandom (java.security.SecureRandom)1 ArrayList (java.util.ArrayList)1 ASDCControllerException (org.onap.so.asdc.client.exceptions.ASDCControllerException)1 ArchivedInfraRequests (org.onap.so.db.request.beans.ArchivedInfraRequests)1 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)1