use of org.apache.sling.distribution.queue.DistributionQueueState in project sling by apache.
the class SimpleDistributionAgent method getState.
@Nonnull
public DistributionAgentState getState() {
DistributionAgentState agentState = DistributionAgentState.IDLE;
// if it is passive and it is not a queueing agent
if (isPassive() && distributionPackageImporter != null) {
return DistributionAgentState.PAUSED;
}
for (String queueName : getQueueNames()) {
DistributionQueue queue = getQueue(queueName);
DistributionQueueState state = queue.getStatus().getState();
if (DistributionQueueState.BLOCKED == state) {
return DistributionAgentState.BLOCKED;
}
if (DistributionQueueState.RUNNING == state) {
agentState = DistributionAgentState.RUNNING;
}
}
return agentState;
}
use of org.apache.sling.distribution.queue.DistributionQueueState in project sling by apache.
the class JobHandlingDistributionQueue method getStatus.
@Override
@Nonnull
public DistributionQueueStatus getStatus() {
List<Job> jobs = getJobs(0, -1);
Job firstJob = jobs.size() > 0 ? jobs.get(0) : null;
DistributionQueueItem firstItem = firstJob != null ? JobHandlingUtils.getItem(firstJob) : null;
DistributionQueueItemStatus firstItemStatus = firstJob != null ? JobHandlingUtils.getStatus(firstJob) : null;
DistributionQueueState state = DistributionQueueUtils.calculateState(firstItem, firstItemStatus);
if (!isActive) {
state = DistributionQueueState.PASSIVE;
}
int itemsCount = jobs.size();
return new DistributionQueueStatus(itemsCount, state);
}
Aggregations