|  | 
| 71 | 71 | import java.util.Set; | 
| 72 | 72 | import java.util.stream.Collectors; | 
| 73 | 73 | 
 | 
| 74 |  | -import static org.opensearch.jobscheduler.spi.utils.LockService.LOCK_INDEX_NAME; | 
| 75 | 74 | import static org.opensearch.securityanalytics.settings.SecurityAnalyticsSettings.INDEX_TIMEOUT; | 
| 76 | 75 | import static org.opensearch.securityanalytics.threatIntel.common.TIFJobState.AVAILABLE; | 
| 77 | 76 | import static org.opensearch.securityanalytics.threatIntel.common.TIFJobState.REFRESHING; | 
| @@ -419,45 +418,6 @@ public void deleteTIFSourceConfig( | 
| 419 | 418 |         )); | 
| 420 | 419 |     } | 
| 421 | 420 | 
 | 
| 422 |  | -    // Manually delete threat intel job scheduler lock if job is disabled | 
| 423 |  | -    public void deleteJobSchedulerLockIfJobDisabled( | 
| 424 |  | -            SATIFSourceConfig saTifSourceConfig, | 
| 425 |  | -            final ActionListener<DeleteResponse> actionListener | 
| 426 |  | -    ) { | 
| 427 |  | -        if (saTifSourceConfig.isEnabled()) { | 
| 428 |  | -            actionListener.onResponse(null); | 
| 429 |  | -            return; | 
| 430 |  | -        } | 
| 431 |  | - | 
| 432 |  | -        // check to make sure the job scheduler lock index exists | 
| 433 |  | -        if (clusterService.state().metadata().hasIndex(LOCK_INDEX_NAME) == false) { | 
| 434 |  | -            actionListener.onResponse(null); | 
| 435 |  | -            return; | 
| 436 |  | -        } | 
| 437 |  | - | 
| 438 |  | -        String id = SecurityAnalyticsPlugin.JOB_INDEX_NAME + "-" + saTifSourceConfig.getId(); | 
| 439 |  | -        DeleteRequest request = new DeleteRequest(LOCK_INDEX_NAME, id) | 
| 440 |  | -                .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE) | 
| 441 |  | -                .timeout(clusterSettings.get(INDEX_TIMEOUT)); | 
| 442 |  | - | 
| 443 |  | -        client.delete(request, ActionListener.wrap( | 
| 444 |  | -                deleteResponse -> { | 
| 445 |  | -                    if (deleteResponse.status().equals(RestStatus.OK)) { | 
| 446 |  | -                        log.info("Deleted threat intel job scheduler lock [{}] successfully", id); | 
| 447 |  | -                        actionListener.onResponse(deleteResponse); | 
| 448 |  | -                    } else if (deleteResponse.status().equals(RestStatus.NOT_FOUND)) { | 
| 449 |  | -                        log.info("Threat intel job scheduler lock with id [{}] not found", id); | 
| 450 |  | -                        actionListener.onResponse(deleteResponse); | 
| 451 |  | -                    } else { | 
| 452 |  | -                        actionListener.onFailure(SecurityAnalyticsException.wrap(new OpenSearchStatusException(String.format(Locale.ROOT, "Failed to delete threat intel job scheduler lock with id [{%s}]", id), deleteResponse.status()))); | 
| 453 |  | -                    } | 
| 454 |  | -                }, e -> { | 
| 455 |  | -                    log.error("Failed to delete threat intel job scheduler lock with id [{}]", id); | 
| 456 |  | -                    actionListener.onFailure(e); | 
| 457 |  | -                } | 
| 458 |  | -        )); | 
| 459 |  | -    } | 
| 460 |  | - | 
| 461 | 421 |     public void deleteAllIocIndices(Set<String> indicesToDelete, Boolean backgroundJob, ActionListener<AcknowledgedResponse> listener) { | 
| 462 | 422 |         if (indicesToDelete.isEmpty() == false) { | 
| 463 | 423 |             DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indicesToDelete.toArray(new String[0])); | 
|  | 
0 commit comments