class Surveiller {

	public static void main(String[] args) throws Exception{
		String surveillerTaskName = "SurveillerStatusCheck";
		String taskStatus = "SUCCESS";
		Date reqStartTime = new Date();
		
		try {
			if(args == null || args.length == 0){
				HealthCheck.doSurveiller();
				return;
			}
			surveillerTaskName = args[0];
			switch (args[0].toUpperCase()) {
				case "DOMARATHONBACKUP":
					MarathonBackUpTask.doMarathonBackUp();
					break;
				case "DOCOUNTERDATALOAD":
					CounterDataLoader.doDataLoad();
					break;
				case "DOPURGEOLDDATA":
					PurgeOldData.doPurgeOldData();
					break;
				case "DOAPIDASHBOARDTASK":
					APIDashboardTask.doApiDashboardDataLoad();
					break;
				case "DOMESOSTPSDATALOAD":
					TPSDataLoadTask.doTpsDataLoad(SurveillerConstants.MESOS_PLATFORM);
					break;	
				case "DOKUBERNETESBACKUP":
					KubernetesBackUpTask.doKubernetesBackUp();
					break;	
				case "DOK8SAPIDASHBOARDTASK":
					K8sAPIDashboardTask.doK8sApiDashboardDataLoad();
					break;
				case "DOK8STPSLOOKUPLOADTASK":
					TPSLookupTask.doTpsLookupLoad();
					break;		
				case "DOK8STPSDATALOAD":
					TPSDataLoadTask.doTpsDataLoad(SurveillerConstants.K8S_PLATFORM);
					break;						
				default:
					HealthCheck.doSurveiller();
					break;
			}
			
		} catch (Exception ex) {
			logger.error("Surveiller task FAILED",ex);
			CommonsUtil.handleException(ex , surveillerTaskName);
			taskStatus = "FAILED";
			throw ex;
		}finally {
			HibernateConfig.closeSessionFactory();
			PrometheusMetricService.pushMetric(surveillerTaskName, taskStatus, reqStartTime);
		}
	}

	private  Surveiller();

}