}
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@Override
public IWorker getWorkerIfItShouldRun(Integer serviceId, long nextTimeout) {
IWorker worker = null;
ServiceData serviceData = serviceDataSession.findById(serviceId);
ServiceConfiguration serviceConfiguration = serviceData.getServiceConfiguration();
if (!serviceConfiguration.isActive()) {
if (log.isDebugEnabled()) {
log.debug("Service " + serviceId + " is inactive.");
}
return null; // Don't return an inactive worker to run
}
String serviceName = serviceData.getName();
final String hostname = getHostName();
if (shouldRunOnThisNode(hostname, Arrays.asList(serviceConfiguration.getPinToNodes()))) {
long oldRunTimeStamp = serviceData.getRunTimeStamp();
long oldNextRunTimeStamp = serviceData.getNextRunTimeStamp();
worker = getWorker(serviceConfiguration, serviceName, oldRunTimeStamp, oldNextRunTimeStamp);
if (worker.getNextInterval() == IInterval.DONT_EXECUTE) {
if (log.isDebugEnabled()) {
log.debug("Service has interval IInterval.DONT_EXECUTE.");
}
return null; // Don't return an inactive worker to run
}