use of org.onap.logging.filter.base.ScheduledLogging 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.ScheduledLogging in project so by onap.
the class ArchiveInfraRequestsScheduler method infraRequestsScheduledTask.
/**
* Runs the scheduler nightly [Seconds] [Minutes] [Hours] [Day of month] [Month] [Day of week] [Year]
*
* @throws ScheduledTaskException
*/
@ScheduledLogging
@Scheduled(cron = "0 0 1 * * ?")
@SchedulerLock(name = "archiveInfraRequestsScheduler")
public void infraRequestsScheduledTask() throws ScheduledTaskException {
logger.debug("Start of archiveInfraRequestsScheduler");
Date currentDate = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(currentDate);
calendar.add(Calendar.DATE, -archivedPeriod);
Date archivingDate = calendar.getTime();
logger.debug("Date before 6 months: " + (calendar.get(Calendar.MONTH) + 1) + "-" + calendar.get(Calendar.DATE) + "-" + calendar.get(Calendar.YEAR));
List<InfraActiveRequests> requestsByEndTime = new ArrayList<>();
// Could use sorting here
PageRequest pageRequest = PageRequest.of(0, 100);
do {
requestsByEndTime = infraActiveRepo.findByEndTimeLessThan(archivingDate, pageRequest);
logger.debug("{} requests to be archived based on End Time", requestsByEndTime.size());
archiveInfraRequests(requestsByEndTime);
} while (!requestsByEndTime.isEmpty());
List<InfraActiveRequests> requestsByStartTime = new ArrayList<>();
do {
requestsByStartTime = infraActiveRepo.findByStartTimeLessThanAndEndTime(archivingDate, null, pageRequest);
logger.debug("{} requests to be archived based on Start Time", requestsByEndTime.size());
archiveInfraRequests(requestsByStartTime);
} while (!requestsByStartTime.isEmpty());
logger.debug("End of archiveInfraRequestsScheduler");
}
use of org.onap.logging.filter.base.ScheduledLogging 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