mirror of https://github.com/apache/nifi.git
NIFI-1557: Ensure that Reporting Tasks & controller services are ordered by ID before fingerprinting
This commit is contained in:
parent
24a77755de
commit
6af108c0ca
|
@ -248,15 +248,61 @@ public final class FingerprintFactory {
|
|||
|
||||
final Element controllerServicesElem = DomUtils.getChild(flowControllerElem, "controllerServices");
|
||||
if (controllerServicesElem != null) {
|
||||
final List<ControllerServiceDTO> serviceDtos = new ArrayList<>();
|
||||
for (final Element serviceElem : DomUtils.getChildElementsByTagName(controllerServicesElem, "controllerService")) {
|
||||
addControllerServiceFingerprint(builder, serviceElem);
|
||||
final ControllerServiceDTO dto = FlowFromDOMFactory.getControllerService(serviceElem, encryptor);
|
||||
serviceDtos.add(dto);
|
||||
}
|
||||
|
||||
Collections.sort(serviceDtos, new Comparator<ControllerServiceDTO>() {
|
||||
@Override
|
||||
public int compare(final ControllerServiceDTO o1, final ControllerServiceDTO o2) {
|
||||
if (o1 == null && o2 == null) {
|
||||
return 0;
|
||||
}
|
||||
if (o1 == null && o2 != null) {
|
||||
return 1;
|
||||
}
|
||||
if (o1 != null && o2 == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return o1.getId().compareTo(o2.getId());
|
||||
}
|
||||
});
|
||||
|
||||
for (final ControllerServiceDTO dto : serviceDtos) {
|
||||
addControllerServiceFingerprint(builder, dto);
|
||||
}
|
||||
}
|
||||
|
||||
final Element reportingTasksElem = DomUtils.getChild(flowControllerElem, "reportingTasks");
|
||||
if (reportingTasksElem != null) {
|
||||
final List<ReportingTaskDTO> reportingTaskDtos = new ArrayList<>();
|
||||
for (final Element taskElem : DomUtils.getChildElementsByTagName(reportingTasksElem, "reportingTask")) {
|
||||
addReportingTaskFingerprint(builder, taskElem);
|
||||
final ReportingTaskDTO dto = FlowFromDOMFactory.getReportingTask(taskElem, encryptor);
|
||||
reportingTaskDtos.add(dto);
|
||||
}
|
||||
|
||||
Collections.sort(reportingTaskDtos, new Comparator<ReportingTaskDTO>() {
|
||||
@Override
|
||||
public int compare(final ReportingTaskDTO o1, final ReportingTaskDTO o2) {
|
||||
if (o1 == null && o2 == null) {
|
||||
return 0;
|
||||
}
|
||||
if (o1 == null && o2 != null) {
|
||||
return 1;
|
||||
}
|
||||
if (o1 != null && o2 == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return o1.getId().compareTo(o2.getId());
|
||||
}
|
||||
});
|
||||
|
||||
for (final ReportingTaskDTO dto : reportingTaskDtos) {
|
||||
addReportingTaskFingerprint(builder, dto);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -843,11 +889,6 @@ public final class FingerprintFactory {
|
|||
return builder;
|
||||
}
|
||||
|
||||
private void addControllerServiceFingerprint(final StringBuilder builder, final Element controllerServiceElem) {
|
||||
final ControllerServiceDTO dto = FlowFromDOMFactory.getControllerService(controllerServiceElem, encryptor);
|
||||
addControllerServiceFingerprint(builder, dto);
|
||||
}
|
||||
|
||||
private void addControllerServiceFingerprint(final StringBuilder builder, final ControllerServiceDTO dto) {
|
||||
builder.append(dto.getId());
|
||||
builder.append(dto.getType());
|
||||
|
@ -872,11 +913,6 @@ public final class FingerprintFactory {
|
|||
}
|
||||
}
|
||||
|
||||
private void addReportingTaskFingerprint(final StringBuilder builder, final Element element) {
|
||||
final ReportingTaskDTO dto = FlowFromDOMFactory.getReportingTask(element, encryptor);
|
||||
addReportingTaskFingerprint(builder, dto);
|
||||
}
|
||||
|
||||
private void addReportingTaskFingerprint(final StringBuilder builder, final ReportingTaskDTO dto) {
|
||||
builder.append(dto.getId());
|
||||
builder.append(dto.getType());
|
||||
|
|
Loading…
Reference in New Issue