public class ExecutionScheduleManager extends Object
Modifier and Type | Field and Description |
---|---|
protected com.sun.jersey.api.client.Client |
ambariClient |
protected com.sun.jersey.api.client.WebResource |
ambariWebResource |
protected static String |
BATCH_REQUEST_JOB_PREFIX |
protected static Pattern |
CONTAINS_API_VERSION_PATTERN |
protected static String |
DEFAULT_API_PATH |
protected static String |
REQUEST_EXECUTION_TRIGGER_PREFIX |
protected static String |
REQUESTS_ABORTED_TASKS_KEY |
protected static String |
REQUESTS_FAILED_TASKS_KEY |
protected static String |
REQUESTS_ID_KEY |
protected static String |
REQUESTS_STATUS_KEY |
protected static String |
REQUESTS_TIMEDOUT_TASKS_KEY |
protected static String |
REQUESTS_TOTAL_TASKS_KEY |
static String |
USER_ID_HEADER |
Constructor and Description |
---|
ExecutionScheduleManager(Configuration configuration,
ExecutionScheduler executionScheduler,
InternalTokenStorage tokenStorage,
Clusters clusters,
ActionDBAccessor actionDBAccessor,
com.google.gson.Gson gson) |
Modifier and Type | Method and Description |
---|---|
protected RequestStatus |
abortRequestById(RequestExecution requestExecution,
Long requestId) |
protected void |
buildApiClient() |
boolean |
continueOnMisfire(org.quartz.JobExecutionContext jobExecutionContext)
Find out by how much did a schedule misfire and decide whether to continue
based on configuration
|
void |
deleteAllJobs(RequestExecution requestExecution)
Delete all jobs and triggers if possible.
|
void |
deleteJobs(RequestExecution requestExecution,
Long startingBatchOrderId)
Delete all jobs and triggers if possible.
|
Long |
executeBatchRequest(long executionId,
long batchId,
String clusterName)
Execute a Batch request and return request id if the server responds with
a request id for long running operations.
|
protected com.sun.jersey.api.client.WebResource |
extendApiResource(com.sun.jersey.api.client.WebResource webResource,
String relativeUri)
Returns the absolute web resource with
DEFAULT_API_PATH |
void |
finalizeBatch(long executionId,
String clusterName)
Marks Request Schedule as COMPLETED, if:
No triggers exist for the first job in the chain OR
If the trigger will never fire again.
|
BatchRequestResponse |
getBatchRequestResponse(Long requestId,
String clusterName)
Get status of a long running operation
|
String |
getBatchRequestStatus(Long executionId,
String clusterName) |
protected String |
getJobName(Long executionId,
Long orderId) |
boolean |
hasToleranceThresholdExceeded(Long executionId,
String clusterName,
Map<String,Integer> taskCounts)
Check if the allowed threshold for failed tasks has exceeded.
|
boolean |
isSchedulerAvailable()
Is Execution scheduler available for accepting jobs?
|
void |
pauseAfterBatchIfNeeded(long executionId,
long batchId,
String clusterName)
Checks if scheduled request should be auto paused and updates the status to PAUSED if it does.
|
protected BatchRequestResponse |
performApiGetRequest(String relativeUri,
boolean queryAllFields) |
protected BatchRequestResponse |
performApiRequest(String relativeUri,
String body,
String method,
Integer userId) |
protected BatchRequestResponse |
performUriRequest(String url,
String body,
String method) |
void |
scheduleAllBatches(RequestExecution requestExecution)
Persist jobs based on the request batch and create trigger for the first
job
|
void |
scheduleBatch(RequestExecution requestExecution,
long startingBatchOrderId)
Persist jobs based on the request batches staring from the defined batch and create trigger for the first
job
|
void |
scheduleJob(org.quartz.Trigger trigger)
Add trigger for a job to the scheduler
|
void |
start()
Start Execution scheduler
|
void |
stop()
Stop execution scheduler
|
void |
updateBatchRequest(long executionId,
long batchId,
String clusterName,
BatchRequestResponse batchRequestResponse,
boolean statusOnly) |
void |
updateBatchSchedule(RequestExecution requestExecution)
Pause/resume/abort request schedule and related jobs and triggers
|
void |
validateSchedule(Schedule schedule)
Validate if schedule expression is a valid Cron schedule
|
protected static final String BATCH_REQUEST_JOB_PREFIX
protected static final String REQUEST_EXECUTION_TRIGGER_PREFIX
protected static final String DEFAULT_API_PATH
public static final String USER_ID_HEADER
protected com.sun.jersey.api.client.Client ambariClient
protected com.sun.jersey.api.client.WebResource ambariWebResource
protected static final String REQUESTS_STATUS_KEY
protected static final String REQUESTS_ID_KEY
protected static final String REQUESTS_FAILED_TASKS_KEY
protected static final String REQUESTS_ABORTED_TASKS_KEY
protected static final String REQUESTS_TIMEDOUT_TASKS_KEY
protected static final String REQUESTS_TOTAL_TASKS_KEY
protected static final Pattern CONTAINS_API_VERSION_PATTERN
@Inject public ExecutionScheduleManager(Configuration configuration, ExecutionScheduler executionScheduler, InternalTokenStorage tokenStorage, Clusters clusters, ActionDBAccessor actionDBAccessor, com.google.gson.Gson gson)
protected void buildApiClient() throws NoSuchAlgorithmException, KeyManagementException
public void start()
public void stop()
public boolean isSchedulerAvailable()
public void scheduleJob(org.quartz.Trigger trigger)
trigger
- public boolean continueOnMisfire(org.quartz.JobExecutionContext jobExecutionContext)
jobExecutionContext
- public void scheduleAllBatches(RequestExecution requestExecution) throws org.apache.ambari.server.AmbariException
requestExecution
- org.apache.ambari.server.AmbariException
public void scheduleBatch(RequestExecution requestExecution, long startingBatchOrderId) throws org.apache.ambari.server.AmbariException
requestExecution
- org.apache.ambari.server.AmbariException
public void updateBatchSchedule(RequestExecution requestExecution) throws org.apache.ambari.server.AmbariException
requestExecution
- org.apache.ambari.server.AmbariException
public void validateSchedule(Schedule schedule) throws org.apache.ambari.server.AmbariException
schedule
- org.apache.ambari.server.AmbariException
public void deleteAllJobs(RequestExecution requestExecution) throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
public void deleteJobs(RequestExecution requestExecution, Long startingBatchOrderId) throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
public Long executeBatchRequest(long executionId, long batchId, String clusterName) throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
public BatchRequestResponse getBatchRequestResponse(Long requestId, String clusterName) throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
protected RequestStatus abortRequestById(RequestExecution requestExecution, Long requestId) throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
public String getBatchRequestStatus(Long executionId, String clusterName) throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
public void updateBatchRequest(long executionId, long batchId, String clusterName, BatchRequestResponse batchRequestResponse, boolean statusOnly) throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
protected BatchRequestResponse performUriRequest(String url, String body, String method)
protected BatchRequestResponse performApiGetRequest(String relativeUri, boolean queryAllFields)
protected BatchRequestResponse performApiRequest(String relativeUri, String body, String method, Integer userId)
public boolean hasToleranceThresholdExceeded(Long executionId, String clusterName, Map<String,Integer> taskCounts) throws org.apache.ambari.server.AmbariException
executionId
- clusterName
- taskCounts
- org.apache.ambari.server.AmbariException
public void finalizeBatch(long executionId, String clusterName) throws org.apache.ambari.server.AmbariException
executionId
- clusterName
- org.apache.ambari.server.AmbariException
protected com.sun.jersey.api.client.WebResource extendApiResource(com.sun.jersey.api.client.WebResource webResource, String relativeUri)
DEFAULT_API_PATH
webResource
- Ambari WebResource as provided by the client ambariWebResource
relativeUri
- relative request URIpublic void pauseAfterBatchIfNeeded(long executionId, long batchId, String clusterName) throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
Copyright © 2022 Apache Software Foundation. All rights reserved.