public class DataCleanupTasks {\r
\r
private static final EELFLogger logger = EELFManager.getInstance().getLogger(DataCleanupTasks.class);\r
- private static final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");\r
- \r
+ private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");\r
/**The function archives/deletes files that end in .out (Ie. dataGrooming.201511111305.out) that sit in our log/data directory structure.\r
logDir is the {project_home}/logs\r
archiveDir is the ARCHIVE directory where the files will be stored after 5 days.\r
import org.onap.aai.datagrooming.DataGroomingTasks;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.logging.LogFormatTools;
import org.onap.aai.logging.LoggingContext;
import org.onap.aai.util.AAIConfig;
import org.springframework.context.annotation.PropertySource;
public class DataSnapshotTasks {
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(DataSnapshotTasks.class);
- private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+ private final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
@Scheduled(cron = "${datasnapshottasks.cron}" )
public void snapshotScheduleTask() throws AAIException, Exception {
LOGGER.info("Started cron job dataSnapshot @ " + dateFormat.format(new Date()));
try {
if (AAIConfig.get("aai.cron.enable.dataSnapshot").equals("true")) {
- DataSnapshot dataSnapshot = new DataSnapshot();
String [] dataSnapshotParms = AAIConfig.get("aai.datasnapshot.params", "JUST_TAKE_SNAPSHOT").split("\\s+");
LOGGER.info("DataSnapshot Params {}", Arrays.toString(dataSnapshotParms));
- dataSnapshot.main(dataSnapshotParms);
+ DataSnapshot.main(dataSnapshotParms);
}
}
catch (Exception e) {
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
-
while (br.readLine() != null){
count++;
}
int exitVal = process.waitFor();
LOGGER.info("Exit value of the dataSnapshot check process: " + exitVal);
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.error("Exception in checkIfDataSnapshotIsRunning" + LogFormatTools.getStackTop(e));
}
- if(count > 0){
- return true;
- } else {
- return false;
- }
+ return count > 0;
}
}
-
\ No newline at end of file
+