private void registerPurgingTasks(String scriptFilePath) throws DeploymentException {
   File deploymentFileData = new File(scriptFilePath);
   int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
   log.info(
       "Deploying purging task : " + deploymentFileData.getName() + " for tenant : " + tenantId);
   try {
     AnalyticsDataPurgingConfiguration purgingConfiguration =
         getAnalyticsDataPurgingConfiguration(deploymentFileData);
     if (purgingConfiguration != null) {
       if (purgingConfiguration.getPurgingIncludeTables() != null) {
         TaskManager taskManager =
             AnalyticsServiceHolder.getTaskService()
                 .getTaskManager(Constants.ANALYTICS_DATA_PURGING);
         for (AnalyticsDataPurgingIncludeTable analyticsDataPurgingIncludeTable :
             purgingConfiguration.getPurgingIncludeTables()) {
           if (analyticsDataPurgingIncludeTable.getValue() != null
               && !analyticsDataPurgingIncludeTable.getValue().isEmpty()) {
             TaskInfo dataPurgingTask =
                 createDataPurgingTask(
                     analyticsDataPurgingIncludeTable.getValue(),
                     purgingConfiguration.getCronExpression(),
                     purgingConfiguration.getRetentionDays());
             taskManager.registerTask(dataPurgingTask);
             taskManager.rescheduleTask(dataPurgingTask.getName());
           }
         }
       }
     }
   } catch (TaskException e) {
     log.error(
         "Unable to get task manager instance for ANALYTICS_DATA_PURGING:" + e.getMessage(), e);
   }
 }
 private void deletePurgingTasks(String scriptFilePath) {
   File deploymentFileData = new File(scriptFilePath);
   int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
   log.info(
       "Undeploying purging task : " + deploymentFileData.getName() + " for tenant : " + tenantId);
   try {
     AnalyticsDataPurgingConfiguration purgingConfiguration =
         getAnalyticsDataPurgingConfiguration(deploymentFileData);
     if (purgingConfiguration != null) {
       if (purgingConfiguration.getPurgingIncludeTables() != null) {
         TaskManager taskManager =
             AnalyticsServiceHolder.getTaskService()
                 .getTaskManager(Constants.ANALYTICS_DATA_PURGING);
         for (AnalyticsDataPurgingIncludeTable analyticsDataPurgingIncludeTable :
             purgingConfiguration.getPurgingIncludeTables()) {
           if (analyticsDataPurgingIncludeTable.getValue() != null
               && !analyticsDataPurgingIncludeTable.getValue().isEmpty()) {
             taskManager.deleteTask(
                 getDataPurgingTaskName(analyticsDataPurgingIncludeTable.getValue()));
           }
         }
       }
     }
   } catch (TaskException e) {
     log.error(
         "Unable to get task manager instance for ANALYTICS_DATA_PURGING:" + e.getMessage(), e);
   }
 }