public class HostRoleCommandDAO extends Object
Modifier and Type | Class and Description |
---|---|
static class |
HostRoleCommandDAO.LastServiceCheckDTO
A simple DTO for storing the most recent service check time for a given
Role . |
Modifier and Type | Field and Description |
---|---|
static String |
HRC_STATUS_SUMMARY_CACHE_ENABLED |
static String |
HRC_STATUS_SUMMARY_CACHE_EXPIRY_DURATION_MINUTES |
static String |
HRC_STATUS_SUMMARY_CACHE_SIZE |
Constructor and Description |
---|
HostRoleCommandDAO(boolean hostRoleCommandStatusSummaryCacheEnabled,
long hostRoleCommandStatusSummaryCacheLimit,
long hostRoleCommandStatusSummaryCacheExpiryDurationMins) |
Modifier and Type | Method and Description |
---|---|
void |
create(HostRoleCommandEntity entity) |
Map<Long,HostRoleCommandStatusSummaryDTO> |
findAggregateCounts(Long requestId)
Finds the counts of tasks for a request and groups them by stage id.
|
List<HostRoleCommandEntity> |
findAll() |
List<HostRoleCommandEntity> |
findAll(Request request,
Predicate predicate)
Finds all
HostRoleCommandEntity that match the provided predicate. |
List<HostRoleCommandEntity> |
findByHostId(Long hostId) |
List<HostRoleCommandEntity> |
findByHostRole(String hostName,
long requestId,
long stageId,
String role) |
HostRoleCommandEntity |
findByPK(long taskId) |
List<HostRoleCommandEntity> |
findByPKs(Collection<Long> taskIds) |
List<HostRoleCommandEntity> |
findByRequest(long requestId) |
List<HostRoleCommandEntity> |
findByRequest(long requestId,
boolean refreshHint) |
List<HostRoleCommandEntity> |
findByRequestAndTaskIds(Collection<Long> requestIds,
Collection<Long> taskIds) |
List<HostRoleCommandEntity> |
findByRequestIdAndStatuses(Long requestId,
Collection<HostRoleStatus> statuses) |
List<HostRoleCommandEntity> |
findByRequestIds(Collection<Long> requestIds) |
List<HostRoleCommandEntity> |
findByStatus(Collection<HostRoleStatus> statuses)
Gets the commands in a particular status.
|
List<HostRoleCommandEntity> |
findByStatusBetweenStages(long requestId,
HostRoleStatus status,
long minStageId,
long maxStageId)
Finds all the
HostRoleCommandEntity s for the given request that are
between the specified stage IDs and have the specified status. |
HostRoleCommandEntity |
findMostRecentFailure(Long requestId)
During Rolling and Express Upgrade, want to bubble up the error of the most recent failure, i.e., greatest
task id, assuming that there are no other completed tasks after it.
|
List<HostRoleCommandEntity> |
findSortedCommandsByRequestIdAndCustomCommandName(Long requestId,
String customCommandName) |
Map<String,List<HostRoleCommandEntity>> |
findSortedCommandsByStage(StageEntity stageEntity) |
List<HostRoleCommandEntity> |
findSortedCommandsByStageAndHost(StageEntity stageEntity,
HostEntity hostEntity) |
List<Long> |
findTaskIdsByHostRoleAndStatus(String hostname,
String role,
HostRoleStatus status) |
List<Long> |
findTaskIdsByRequest(long requestId) |
List<Long> |
findTaskIdsByRequestAndTaskIds(Collection<Long> requestIds,
Collection<Long> taskIds) |
List<Long> |
findTaskIdsByRequestIds(Collection<Long> requestIds) |
Set<Long> |
findTaskIdsByRequestStageIds(List<RequestDAO.StageEntityPK> requestStageIds) |
List<Long> |
findTaskIdsByRoleAndStatus(String role,
HostRoleStatus status) |
List<Long> |
findTaskIdsByStage(long requestId,
long stageId) |
List<String> |
getBlockingHostsForRequest(long lowerRequestIdInclusive,
long requestId)
Gets a lists of hosts with commands in progress which occurr before the
specified request ID.
|
List<Long> |
getCompletedRequests(int maxResults,
boolean ascOrder) |
Number |
getCountByStatus(Collection<HostRoleStatus> statuses)
Gets the number of commands in a particular status.
|
Map<Long,Integer> |
getHostIdToCountOfCommandsWithStatus(Collection<HostRoleStatus> statuses) |
List<HostRoleCommand> |
getHostRoleCommands(Collection<HostRoleCommandEntity> entities) |
List<String> |
getHostsWithPendingTasks(long iLowestRequestIdInProgress,
long iHighestRequestIdInProgress)
Gets a lists of hosts with commands in progress given a range of requests.
|
List<HostRoleCommandDAO.LastServiceCheckDTO> |
getLatestServiceChecksByRole(long clusterId)
Gets the most recently run service check grouped by the command's role
(which is the only way to identify the service it was for!?)
|
List<Long> |
getRequestsByTaskStatus(Collection<HostRoleStatus> statuses,
int maxResults,
boolean ascOrder)
Gets requests that have tasks in any of the specified statuses.
|
protected void |
invalidateHostRoleCommandStatusSummaryCache(HostRoleCommandEntity hostRoleCommandEntity)
Invalidates those entries in host role command status cache which are
dependent on the passed
HostRoleCommandEntity entity. |
protected void |
invalidateHostRoleCommandStatusSummaryCache(Long requestId)
Invalidates the host role command status summary cache entry that corresponds to the given request.
|
protected void |
invalidateHostRoleCommandStatusSummaryCache(Set<Long> requestIds)
Invalidates the host role command status summary cache entry that
corresponds to each request.
|
HostRoleCommandEntity |
merge(HostRoleCommandEntity entity) |
List<HostRoleCommandEntity> |
mergeAll(Collection<HostRoleCommandEntity> entities) |
HostRoleCommandEntity |
mergeWithoutPublishEvent(HostRoleCommandEntity entity) |
void |
publishTaskCreateEvent(List<HostRoleCommand> hostRoleCommands) |
void |
publishTaskUpdateEvent(List<HostRoleCommand> hostRoleCommands) |
void |
remove(HostRoleCommandEntity entity) |
void |
removeByHostId(Long hostId) |
void |
removeByPK(int taskId) |
void |
updateAutomaticSkipOnFailure(long requestId,
boolean skipOnFailure,
boolean skipOnServiceCheckFailure)
Updates the
HostRoleCommandEntity.isFailureAutoSkipped() flag for
all commands for the given request. |
int |
updateStatusByRequestId(long requestId,
HostRoleStatus target,
Collection<HostRoleStatus> sources)
NB: You cannot rely on return value if batch write is enabled
|
public static final String HRC_STATUS_SUMMARY_CACHE_SIZE
public static final String HRC_STATUS_SUMMARY_CACHE_EXPIRY_DURATION_MINUTES
public static final String HRC_STATUS_SUMMARY_CACHE_ENABLED
@Inject public HostRoleCommandDAO(boolean hostRoleCommandStatusSummaryCacheEnabled, long hostRoleCommandStatusSummaryCacheLimit, long hostRoleCommandStatusSummaryCacheExpiryDurationMins)
protected void invalidateHostRoleCommandStatusSummaryCache(Long requestId)
requestId
- the key of the cache entry to be invalidated.protected void invalidateHostRoleCommandStatusSummaryCache(Set<Long> requestIds)
requestIds
- the requests to invalidateprotected void invalidateHostRoleCommandStatusSummaryCache(HostRoleCommandEntity hostRoleCommandEntity)
HostRoleCommandEntity
entity.hostRoleCommandEntity
- public HostRoleCommandEntity findByPK(long taskId)
public List<HostRoleCommandEntity> findByPKs(Collection<Long> taskIds)
public List<HostRoleCommandEntity> findByHostId(Long hostId)
public List<HostRoleCommandEntity> findByRequestIds(Collection<Long> requestIds)
public List<HostRoleCommandEntity> findByRequestIdAndStatuses(Long requestId, Collection<HostRoleStatus> statuses)
public List<Long> findTaskIdsByRequestIds(Collection<Long> requestIds)
public List<HostRoleCommandEntity> findByRequestAndTaskIds(Collection<Long> requestIds, Collection<Long> taskIds)
public List<Long> findTaskIdsByRequestAndTaskIds(Collection<Long> requestIds, Collection<Long> taskIds)
public List<Long> findTaskIdsByHostRoleAndStatus(String hostname, String role, HostRoleStatus status)
public List<Long> findTaskIdsByRoleAndStatus(String role, HostRoleStatus status)
public List<HostRoleCommandEntity> findSortedCommandsByRequestIdAndCustomCommandName(Long requestId, String customCommandName)
public List<HostRoleCommandEntity> findSortedCommandsByStageAndHost(StageEntity stageEntity, HostEntity hostEntity)
public Map<String,List<HostRoleCommandEntity>> findSortedCommandsByStage(StageEntity stageEntity)
public Map<Long,Integer> getHostIdToCountOfCommandsWithStatus(Collection<HostRoleStatus> statuses)
public List<HostRoleCommandEntity> findByHostRole(String hostName, long requestId, long stageId, String role)
public List<HostRoleCommandEntity> findByRequest(long requestId)
public List<HostRoleCommandEntity> findByRequest(long requestId, boolean refreshHint)
public List<HostRoleCommandEntity> findByStatus(Collection<HostRoleStatus> statuses)
statuses
- the statuses to include (not null
).public Number getCountByStatus(Collection<HostRoleStatus> statuses)
statuses
- the statuses to include (not null
).public List<HostRoleCommandEntity> findAll()
public List<HostRoleCommandEntity> findByStatusBetweenStages(long requestId, HostRoleStatus status, long minStageId, long maxStageId)
HostRoleCommandEntity
s for the given request that are
between the specified stage IDs and have the specified status.requestId
- the request IDstatus
- the command status to query for (not null
).minStageId
- the lowest stage ID to requests tasks for.maxStageId
- the highest stage ID to request tasks for.public List<Long> getRequestsByTaskStatus(Collection<HostRoleStatus> statuses, int maxResults, boolean ascOrder)
statuses
- maxResults
- ascOrder
- public int updateStatusByRequestId(long requestId, HostRoleStatus target, Collection<HostRoleStatus> sources)
public void create(HostRoleCommandEntity entity)
public HostRoleCommandEntity merge(HostRoleCommandEntity entity)
public HostRoleCommandEntity mergeWithoutPublishEvent(HostRoleCommandEntity entity)
public void removeByHostId(Long hostId)
public List<HostRoleCommandEntity> mergeAll(Collection<HostRoleCommandEntity> entities)
public List<HostRoleCommand> getHostRoleCommands(Collection<HostRoleCommandEntity> entities)
entities
- public void publishTaskUpdateEvent(List<HostRoleCommand> hostRoleCommands)
hostRoleCommands
- public void publishTaskCreateEvent(List<HostRoleCommand> hostRoleCommands)
hostRoleCommands
- public void remove(HostRoleCommandEntity entity)
public void removeByPK(int taskId)
public Map<Long,HostRoleCommandStatusSummaryDTO> findAggregateCounts(Long requestId)
requestId
- the request idpublic HostRoleCommandEntity findMostRecentFailure(Long requestId)
requestId
- upgrade request idpublic void updateAutomaticSkipOnFailure(long requestId, boolean skipOnFailure, boolean skipOnServiceCheckFailure)
HostRoleCommandEntity.isFailureAutoSkipped()
flag for
all commands for the given request.
This will update each entity to ensure that the cache is maintained in a
correct state. A batch update doesn't always reflect in JPA-managed
entities.
Stages which do not support automatically skipped commands will be updated
with a value of false
.requestId
- the request ID of the commands to updateskipOnFailure
- true
to automatically skip failures, false
otherwise.skipOnServiceCheckFailure
- true
to skip service check failuresStageEntity.isAutoSkipOnFailureSupported()
public List<HostRoleCommandEntity> findAll(Request request, Predicate predicate)
HostRoleCommandEntity
that match the provided predicate.
This method will make JPA do the heavy lifting of providing a slice of the
result set.request
- public List<String> getHostsWithPendingTasks(long iLowestRequestIdInProgress, long iHighestRequestIdInProgress)
HostRoleStatus.IN_PROGRESS_STATUSES
public List<String> getBlockingHostsForRequest(long lowerRequestIdInclusive, long requestId)
AgentCommand.AgentCommandType.BACKGROUND_EXECUTION_COMMAND
as thsee commands do
not block future requests.lowerRequestIdInclusive
- the lowest request ID to consider (inclusive) when getting any
blocking hosts.requestId
- the request ID to calculate any blocking hosts for (essentially,
the upper limit exclusive)HostRoleStatus.IN_PROGRESS_STATUSES
public List<HostRoleCommandDAO.LastServiceCheckDTO> getLatestServiceChecksByRole(long clusterId)
clusterId
- the ID of the cluster to get the service checks for.public Set<Long> findTaskIdsByRequestStageIds(List<RequestDAO.StageEntityPK> requestStageIds)
Copyright © 2022 Apache Software Foundation. All rights reserved.