mirror of https://github.com/apache/nifi.git
NIFI-5279: Allow components up to 50 milliseconds to complete validation before returning from update request
This closes #2770. Signed-off-by: Andy LoPresto <alopresto@apache.org>
This commit is contained in:
parent
7b9d779a4b
commit
729f8aa246
|
@ -303,6 +303,7 @@ import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
@ -314,6 +315,7 @@ import java.util.stream.Stream;
|
||||||
*/
|
*/
|
||||||
public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(StandardNiFiServiceFacade.class);
|
private static final Logger logger = LoggerFactory.getLogger(StandardNiFiServiceFacade.class);
|
||||||
|
private static final int VALIDATION_WAIT_MILLIS = 50;
|
||||||
|
|
||||||
// nifi core components
|
// nifi core components
|
||||||
private ControllerFacade controllerFacade;
|
private ControllerFacade controllerFacade;
|
||||||
|
@ -660,7 +662,10 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
||||||
final RevisionUpdate<ProcessorDTO> snapshot = updateComponent(revision,
|
final RevisionUpdate<ProcessorDTO> snapshot = updateComponent(revision,
|
||||||
processorNode,
|
processorNode,
|
||||||
() -> processorDAO.updateProcessor(processorDTO),
|
() -> processorDAO.updateProcessor(processorDTO),
|
||||||
proc -> dtoFactory.createProcessorDto(proc));
|
proc -> {
|
||||||
|
awaitValidationCompletion(proc);
|
||||||
|
return dtoFactory.createProcessorDto(proc);
|
||||||
|
});
|
||||||
|
|
||||||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processorNode);
|
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processorNode);
|
||||||
final ProcessorStatusDTO status = dtoFactory.createProcessorStatusDto(controllerFacade.getProcessorStatus(processorNode.getIdentifier()));
|
final ProcessorStatusDTO status = dtoFactory.createProcessorStatusDto(controllerFacade.getProcessorStatus(processorNode.getIdentifier()));
|
||||||
|
@ -669,6 +674,10 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
||||||
return entityFactory.createProcessorEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletinEntities);
|
return entityFactory.createProcessorEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletinEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void awaitValidationCompletion(final ComponentNode component) {
|
||||||
|
component.getValidationStatus(VALIDATION_WAIT_MILLIS, TimeUnit.MILLISECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LabelEntity updateLabel(final Revision revision, final LabelDTO labelDTO) {
|
public LabelEntity updateLabel(final Revision revision, final LabelDTO labelDTO) {
|
||||||
final Label labelNode = labelDAO.getLabel(labelDTO.getId());
|
final Label labelNode = labelDAO.getLabel(labelDTO.getId());
|
||||||
|
@ -2192,6 +2201,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
||||||
controllerService,
|
controllerService,
|
||||||
() -> controllerServiceDAO.updateControllerService(controllerServiceDTO),
|
() -> controllerServiceDAO.updateControllerService(controllerServiceDTO),
|
||||||
cs -> {
|
cs -> {
|
||||||
|
awaitValidationCompletion(cs);
|
||||||
final ControllerServiceDTO dto = dtoFactory.createControllerServiceDto(cs);
|
final ControllerServiceDTO dto = dtoFactory.createControllerServiceDto(cs);
|
||||||
final ControllerServiceReference ref = controllerService.getReferences();
|
final ControllerServiceReference ref = controllerService.getReferences();
|
||||||
final ControllerServiceReferencingComponentsEntity referencingComponentsEntity =
|
final ControllerServiceReferencingComponentsEntity referencingComponentsEntity =
|
||||||
|
@ -2582,7 +2592,10 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
||||||
final RevisionUpdate<ReportingTaskDTO> snapshot = updateComponent(revision,
|
final RevisionUpdate<ReportingTaskDTO> snapshot = updateComponent(revision,
|
||||||
reportingTask,
|
reportingTask,
|
||||||
() -> reportingTaskDAO.updateReportingTask(reportingTaskDTO),
|
() -> reportingTaskDAO.updateReportingTask(reportingTaskDTO),
|
||||||
rt -> dtoFactory.createReportingTaskDto(rt));
|
rt -> {
|
||||||
|
awaitValidationCompletion(rt);
|
||||||
|
return dtoFactory.createReportingTaskDto(rt);
|
||||||
|
});
|
||||||
|
|
||||||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(reportingTask);
|
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(reportingTask);
|
||||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(reportingTask.getIdentifier()));
|
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(reportingTask.getIdentifier()));
|
||||||
|
|
Loading…
Reference in New Issue