Skip to content

Commit

Permalink
0004631: Default Conflict resolution (IS_CAPTURE_TIME_NEWER) doesn't
Browse files Browse the repository at this point in the history
work when target node is a load only node
  • Loading branch information
Philip Marzullo committed Nov 9, 2020
1 parent fb0185a commit 535888e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Expand Up @@ -248,6 +248,7 @@ protected DatabaseWriterSettings buildDatabaseWriterSettings(List<IDatabaseWrite
List<IDatabaseWriterErrorHandler> errorHandlers, List<? extends Conflict> conflictSettings,
List<ResolvedData> resolvedDatas) {
DatabaseWriterSettings settings = buildParameterDatabaseWritterSettings();
settings.setLoadOnlyNode(engine.getParameterService().is(ParameterConstants.NODE_LOAD_ONLY));
settings.setDatabaseWriterFilters(filters);
settings.setDatabaseWriterErrorHandlers(errorHandlers);

Expand Down
Expand Up @@ -60,6 +60,8 @@ public class DatabaseWriterSettings {

protected boolean logConflictResolution = false;

protected boolean loadOnlyNode = false;

protected String textColumnExpression;

protected Map<String, Conflict> conflictSettingsByChannel;
Expand Down Expand Up @@ -303,4 +305,12 @@ public void setApplyChangesOnly(boolean applyChangesOnly) {
public boolean isApplyChangesOnly() {
return applyChangesOnly;
}

public boolean isLoadOnlyNode() {
return loadOnlyNode;
}

public void setLoadOnlyNode(boolean loadOnlyNode) {
this.loadOnlyNode = loadOnlyNode;
}
}
Expand Up @@ -126,8 +126,9 @@ protected boolean isCaptureTimeNewer(Conflict conflict, AbstractDatabaseWriter w
Timestamp loadingTs = data.getAttribute(CsvData.ATTRIBUTE_CREATE_TIME);
Date existingTs = null;
String existingNodeId = null;
boolean isLoadOnlyNode = databaseWriter.getWriterSettings().isLoadOnlyNode();

if (loadingTs != null) {
if (loadingTs != null && !isLoadOnlyNode) {
if (log.isDebugEnabled()) {
log.debug("Finding last capture time for table {} with pk of {}", targetTable.getName(), ArrayUtils.toString(pkData));
}
Expand Down Expand Up @@ -163,7 +164,7 @@ protected boolean isCaptureTimeNewer(Conflict conflict, AbstractDatabaseWriter w
}
}

boolean isWinner = existingTs == null || (loadingTs != null && (loadingTs.getTime() > existingTs.getTime()
boolean isWinner = isLoadOnlyNode || existingTs == null || (loadingTs != null && (loadingTs.getTime() > existingTs.getTime()
|| (loadingTs.getTime() == existingTs.getTime() && writer.getContext().getBatch().getSourceNodeId().hashCode() > existingNodeId.hashCode())));
writer.getContext().put(DatabaseConstants.IS_CONFLICT_WINNER, isWinner);

Expand Down

0 comments on commit 535888e

Please sign in to comment.