Skip to content

Commit

Permalink
MID-8842 ninja - bugfixing distribution upgrade
Browse files Browse the repository at this point in the history
(cherry picked from commit 47d74eb)
  • Loading branch information
1azyman committed Jul 27, 2023
1 parent f92cd3c commit 54a9e11
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,20 @@ private boolean checkDatabaseSchemaVersion(RepositoryService repository) {

boolean result = validateChangeNumber(
diag.getAdditionalDetails(), SqaleUtils.SCHEMA_CHANGE_NUMBER,
SqaleUtils.SCHEMA_CHANGE_NUMBER);
SqaleUtils.CURRENT_SCHEMA_CHANGE_NUMBER);
if (!result) {
return false;
}

// todo this will not work if audit was not configured or is in different database!
return validateChangeNumber(
diag.getAdditionalDetails(), SqaleUtils.SCHEMA_AUDIT_CHANGE_NUMBER,
SqaleUtils.SCHEMA_AUDIT_CHANGE_NUMBER);
SqaleUtils.CURRENT_SCHEMA_AUDIT_CHANGE_NUMBER);
}

private boolean validateChangeNumber(List<LabeledString> list, String label, String expected) {
private boolean validateChangeNumber(List<LabeledString> list, String label, int expected) {
String number = getValue(list, label);
boolean equals = Objects.equals(number, expected);
boolean equals = Objects.equals(number, Integer.toString(expected));

if (!equals) {
log.error(ConsoleFormat.formatError(
Expand Down Expand Up @@ -120,7 +120,7 @@ private boolean checkNodesVersion(RepositoryService repository) throws SchemaExc
String version = versions.iterator().next();
if (!Objects.equals(version, UpgradeConstants.SUPPORTED_VERSION)) {
log.error(ConsoleFormat.formatErrorMessageWithParameter(
"There are midPoint nodes with versions that doesn't match supported version for upgrade (" +
"There are midPoint nodes with versions {} that doesn't match supported version for upgrade (" +
UpgradeConstants.SUPPORTED_VERSION + ")", Arrays.toString(versions.toArray())));
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void setCreateDeltaFile(boolean createDeltaFile) {
}

public void destroy() {
if (createDeltaFile) {
if (deltaWriter != null) {
try {
deltaWriter.write("</deltas>\n");
} catch (IOException ex) {
Expand Down Expand Up @@ -227,11 +227,13 @@ private void writeDeltaXml(UpgradeValidationResult result) {
continue;
}

try {
deltaWriter.write(DeltaConvertor.serializeDelta(
(ObjectDelta) item.getDelta(), DeltaConversionOptions.createSerializeReferenceNames(), "xml"));
} catch (SchemaException | IOException ex) {
log.error("Couldn't write object delta to XML file", ex);
if (deltaWriter != null) {
try {
deltaWriter.write(DeltaConvertor.serializeDelta(
(ObjectDelta) item.getDelta(), DeltaConversionOptions.createSerializeReferenceNames(), "xml"));
} catch (SchemaException | IOException ex) {
log.error("Couldn't write object delta to XML file", ex);
}
}
}
}
Expand Down

0 comments on commit 54a9e11

Please sign in to comment.