use of org.apache.sling.distribution.agent.DistributionAgentState 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.agent.DistributionAgentState in project sling by apache.
the class ExtendedDistributionServiceResourceProvider method getChildResourceProperties.
@Override
protected Map<String, Object> getChildResourceProperties(DistributionComponent<?> component, String childResourceName) {
DistributionComponentKind kind = component.getKind();
if (DistributionComponentKind.AGENT == kind) {
DistributionAgent agent = (DistributionAgent) component.getService();
if (agent != null && childResourceName != null) {
if (childResourceName.startsWith(QUEUES_PATH)) {
SimplePathInfo queuePathInfo = SimplePathInfo.parsePathInfo(QUEUES_PATH, childResourceName);
return getQueueProperties(agent, queuePathInfo);
} else if (childResourceName.startsWith(LOG_PATH)) {
Map<String, Object> result = new HashMap<String, Object>();
result.put(SLING_RESOURCE_TYPE, DistributionResourceTypes.LOG_RESOURCE_TYPE);
DistributionLog distributionLog = agent.getLog();
result.put(INTERNAL_ADAPTABLE, distributionLog);
return result;
} else if (childResourceName.startsWith(STATUS_PATH)) {
Map<String, Object> result = new HashMap<String, Object>();
DistributionAgentState agentState = agent.getState();
result.put("state", agentState.name());
return result;
}
}
}
return null;
}
Aggregations