use of com.redhat.service.bridge.manager.models.Work in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class WorkManagerImpl method schedule.
@Override
public Work schedule(ManagedResource managedResource) {
Work w = workDAO.findByManagedResource(managedResource);
if (w == null) {
w = Work.forResource(managedResource, workerIdProvider.getWorkerId());
workDAO.persist(w);
if (LOGGER.isInfoEnabled()) {
LOGGER.info(String.format("Scheduling work for '%s' [%s]", w.getManagedResourceId(), w.getType()));
}
fireEvent(w);
}
return w;
}
use of com.redhat.service.bridge.manager.models.Work in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class WorkManagerImpl method recordAttempt.
@Override
@Transactional
public void recordAttempt(Work work) {
if (!exists(work)) {
return;
}
// Work has been serialised by VertX at this point and has therefore lost all affinity with
// a JPA session. We therefore need to first retrieve the entity before updating it.
Work w = workDAO.findById(work.getId());
w.setModifiedAt(ZonedDateTime.now());
w.setAttempts(w.getAttempts() + 1);
}
use of com.redhat.service.bridge.manager.models.Work in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorWorker method delegate.
private Processor delegate(Work work, Processor processor) {
// Get Processor's Connector for which work needs completing
final ConnectorEntity connectorEntity = getConnectorEntity(processor);
// Delegate to the ConnectorWorker however mimic that the Work originated from the Processor.
Work connectorEntityWork = Work.forDependentResource(connectorEntity, work);
ConnectorEntity updatedConnectorEntity = connectorWorker.handleWork(connectorEntityWork);
processor.setDependencyStatus(updatedConnectorEntity.getStatus());
return persist(processor);
}
use of com.redhat.service.bridge.manager.models.Work in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class WorkManagerImplTest method completeWhenExists.
@Test
void completeWhenExists() {
Work work = new Work();
work.setAttempts(0);
when(workDAO.findById(anyString())).thenReturn(work);
manager.complete(work);
verify(workDAO).deleteById(work.getId());
}
use of com.redhat.service.bridge.manager.models.Work in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class WorkManagerImplTest method existsForExistingWork.
@Test
void existsForExistingWork() {
Work existing = mock(Work.class);
when(workDAO.findById(anyString())).thenReturn(existing);
assertThat(manager.exists(new Work())).isTrue();
}
Aggregations