public class ActionDBAccessorImpl extends Object implements ActionDBAccessor
Constructor and Description |
---|
ActionDBAccessorImpl(long cacheLimit,
AmbariEventPublisher eventPublisher) |
Modifier and Type | Method and Description |
---|---|
void |
abortHostRole(String host,
long requestId,
long stageId,
String role)
Mark the task as to have been aborted
|
void |
abortHostRole(String host,
long requestId,
long stageId,
String role,
String reason)
Mark the task as to have been aborted.
|
Collection<HostRoleCommandEntity> |
abortOperation(long requestId)
Abort all outstanding operations associated with the given request.
|
void |
bulkAbortHostRole(Stage s,
Map<ExecutionCommand,String> commands)
Bulk abort commands
|
void |
bulkHostRoleScheduled(Stage s,
List<ExecutionCommand> commands)
Bulk update scheduled commands
|
void |
endRequest(long requestId) |
void |
endRequestIfCompleted(long requestId) |
List<Stage> |
getAllStages(long requestId)
Get all stages associated with a single request id
|
List<HostRoleCommand> |
getAllTasksByRequestIds(Collection<Long> requestIds)
Given a list of request ids, get all the tasks that belong to these requests
|
int |
getCommandsInProgressCount()
Gets the number of commands in progress.
|
List<Stage> |
getFirstStageInProgressPerRequest()
Returns the next stage which is in-progress for every in-progress request
in the system.
|
long |
getLastPersistedRequestIdWhenInitialized()
Return the last persisted Request ID as seen when the DBAccessor object
was initialized.
|
Request |
getRequest(long requestId)
Get request object by id.
|
Map<Long,String> |
getRequestContext(List<Long> requestIds)
Gets request contexts associated with the list of request id
|
String |
getRequestContext(long requestId)
Gets the request context associated with the request id
|
RequestEntity |
getRequestEntity(long requestId)
Gets the request entity by id.
|
List<Request> |
getRequests(Collection<Long> requestIds)
Gets request objects by ids
|
List<Long> |
getRequestsByStatus(RequestStatus status,
int maxResults,
boolean ascOrder)
Get first or last maxResults requests that are in the specified status
|
List<HostRoleCommand> |
getRequestTasks(long requestId)
Given a request id, get all the tasks that belong to this request
|
Stage |
getStage(String actionId)
Given an action id of the form requestId-stageId, retrieve the Stage
|
List<Stage> |
getStagesInProgressForRequest(Long requestId)
Returns all the pending stages in a request, including queued and not-queued.
|
HostRoleCommand |
getTask(long taskId)
Gets the host role command corresponding to the task id
|
List<HostRoleCommand> |
getTasks(Collection<Long> taskIds)
Given a list of task ids, get all the host role commands
|
List<HostRoleCommand> |
getTasksByHostRoleAndStatus(String hostname,
String role,
HostRoleStatus status)
Get a List of host role commands where the host, role and status are as specified
|
List<HostRoleCommand> |
getTasksByRoleAndStatus(String role,
HostRoleStatus status)
Get a List of host role commands where the role and status are as specified
|
void |
hostRoleScheduled(Stage s,
String hostname,
String roleStr)
Updates scheduled stage.
|
void |
invalidateCommandCacheOnHostRemove(HostsRemovedEvent event)
Invalidate cached HostRoleCommands if a host is deleted.
|
void |
persistActions(Request request)
Persists all tasks for a given request
|
void |
resubmitTasks(List<Long> taskIds)
Resubmits a series of tasks
|
void |
setSourceScheduleForRequest(long requestId,
long scheduleId)
Updates request with link to source schedule
|
void |
startRequest(long requestId) |
void |
timeoutHostRole(String host,
long requestId,
long stageId,
String role)
Mark the task as to have timed out
|
void |
timeoutHostRole(String host,
long requestId,
long stageId,
String role,
boolean skipSupported,
boolean hostUnknownState)
Mark the task as to have timed out
|
void |
updateHostRoleState(String hostname,
long requestId,
long stageId,
String role,
CommandReport report)
For the given host, update all the tasks based on the command report
|
void |
updateHostRoleStates(Collection<CommandReport> reports)
Update tasks according to command reports
|
@Inject public ActionDBAccessorImpl(long cacheLimit, AmbariEventPublisher eventPublisher)
public Stage getStage(String actionId)
ActionDBAccessor
getStage
in interface ActionDBAccessor
public List<Stage> getAllStages(long requestId)
ActionDBAccessor
getAllStages
in interface ActionDBAccessor
public RequestEntity getRequestEntity(long requestId)
ActionDBAccessor
getRequestEntity
in interface ActionDBAccessor
public Request getRequest(long requestId)
ActionDBAccessor
getRequest
in interface ActionDBAccessor
requestId
- the request idpublic Collection<HostRoleCommandEntity> abortOperation(long requestId)
HostRoleStatus.SCHEDULED_STATES
to determine which
HostRoleCommand
instances to abort.
Returns the list of the aborted operations.abortOperation
in interface ActionDBAccessor
public void timeoutHostRole(String host, long requestId, long stageId, String role)
ActionDBAccessor
timeoutHostRole
in interface ActionDBAccessor
public void timeoutHostRole(String host, long requestId, long stageId, String role, boolean skipSupported, boolean hostUnknownState)
ActionDBAccessor
timeoutHostRole
in interface ActionDBAccessor
public List<Stage> getStagesInProgressForRequest(Long requestId)
ActionDBAccessor.getCommandsInProgressCount()
in
order to determine if there are stages that are in progress before getting
the stages from this method.getStagesInProgressForRequest
in interface ActionDBAccessor
HostRoleStatus.IN_PROGRESS_STATUSES
public List<Stage> getFirstStageInProgressPerRequest()
ActionDBAccessor.getCommandsInProgressCount()
in order to determine if there
are stages that are in progress before getting the stages from this method.getFirstStageInProgressPerRequest
in interface ActionDBAccessor
HostRoleStatus.IN_PROGRESS_STATUSES
public int getCommandsInProgressCount()
getCommandsInProgressCount
in interface ActionDBAccessor
public void persistActions(Request request) throws org.apache.ambari.server.AmbariException
ActionDBAccessor
persistActions
in interface ActionDBAccessor
request
- request objectorg.apache.ambari.server.AmbariException
public void startRequest(long requestId)
startRequest
in interface ActionDBAccessor
public void endRequest(long requestId)
endRequest
in interface ActionDBAccessor
public void endRequestIfCompleted(long requestId)
public void setSourceScheduleForRequest(long requestId, long scheduleId)
ActionDBAccessor
setSourceScheduleForRequest
in interface ActionDBAccessor
public void updateHostRoleStates(Collection<CommandReport> reports)
ActionDBAccessor
updateHostRoleStates
in interface ActionDBAccessor
public void updateHostRoleState(String hostname, long requestId, long stageId, String role, CommandReport report)
ActionDBAccessor
updateHostRoleState
in interface ActionDBAccessor
public void abortHostRole(String host, long requestId, long stageId, String role)
ActionDBAccessor
abortHostRole
in interface ActionDBAccessor
public void abortHostRole(String host, long requestId, long stageId, String role, String reason)
ActionDBAccessor
abortHostRole
in interface ActionDBAccessor
public long getLastPersistedRequestIdWhenInitialized()
ActionDBAccessor
getLastPersistedRequestIdWhenInitialized
in interface ActionDBAccessor
public void bulkHostRoleScheduled(Stage s, List<ExecutionCommand> commands)
ActionDBAccessor
bulkHostRoleScheduled
in interface ActionDBAccessor
public void bulkAbortHostRole(Stage s, Map<ExecutionCommand,String> commands)
ActionDBAccessor
bulkAbortHostRole
in interface ActionDBAccessor
public void hostRoleScheduled(Stage s, String hostname, String roleStr)
ActionDBAccessor
hostRoleScheduled
in interface ActionDBAccessor
public List<HostRoleCommand> getRequestTasks(long requestId)
ActionDBAccessor
getRequestTasks
in interface ActionDBAccessor
public List<HostRoleCommand> getAllTasksByRequestIds(Collection<Long> requestIds)
ActionDBAccessor
getAllTasksByRequestIds
in interface ActionDBAccessor
public List<HostRoleCommand> getTasks(Collection<Long> taskIds)
ActionDBAccessor
getTasks
in interface ActionDBAccessor
public List<HostRoleCommand> getTasksByHostRoleAndStatus(String hostname, String role, HostRoleStatus status)
ActionDBAccessor
getTasksByHostRoleAndStatus
in interface ActionDBAccessor
public List<HostRoleCommand> getTasksByRoleAndStatus(String role, HostRoleStatus status)
ActionDBAccessor
getTasksByRoleAndStatus
in interface ActionDBAccessor
public HostRoleCommand getTask(long taskId)
ActionDBAccessor
getTask
in interface ActionDBAccessor
public List<Long> getRequestsByStatus(RequestStatus status, int maxResults, boolean ascOrder)
ActionDBAccessor
getRequestsByStatus
in interface ActionDBAccessor
status
- Desired request statusmaxResults
- maximal number of returned id'sascOrder
- defines sorting order for database query resultpublic Map<Long,String> getRequestContext(List<Long> requestIds)
ActionDBAccessor
getRequestContext
in interface ActionDBAccessor
public String getRequestContext(long requestId)
ActionDBAccessor
getRequestContext
in interface ActionDBAccessor
public List<Request> getRequests(Collection<Long> requestIds)
ActionDBAccessor
getRequests
in interface ActionDBAccessor
public void resubmitTasks(List<Long> taskIds)
ActionDBAccessor
resubmitTasks
in interface ActionDBAccessor
public void invalidateCommandCacheOnHostRemove(HostsRemovedEvent event)
event
- @HostRemovedEventCopyright © 2022 Apache Software Foundation. All rights reserved.