Skip to content

Commit

Permalink
0005091: Table Reload Requests: create schema, delete data, before
Browse files Browse the repository at this point in the history
custom sql should honor initial load order less than 0
  • Loading branch information
Philip Marzullo committed Sep 27, 2021
1 parent ebf1c07 commit 34f5db3
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,9 @@ private int insertCreateBatchesForReload(Node targetNode, long loadId, String cr
}

//Check the create flag on the specific table reload request
if (currentRequest != null && currentRequest.isCreateTable()
if (triggerRouter.getInitialLoadOrder() > -1
&& currentRequest != null
&& currentRequest.isCreateTable()
&& engine.getGroupletService().isTargetEnabled(triggerRouter,
targetNode)) {
insertCreateEvent(transaction, targetNode, triggerHistory, triggerRouter.getTrigger().getReloadChannelId(), true,
Expand Down Expand Up @@ -1363,7 +1365,8 @@ private int insertDeleteBatchesForReload(Node targetNode, long loadId, String cr
}

//Check the delete flag on the specific table reload request
if (currentRequest != null && currentRequest.isDeleteFirst()
if (triggerRouter.getInitialLoadOrder() > -1
&& currentRequest.isDeleteFirst()
&& engine.getGroupletService().isTargetEnabled(triggerRouter,
targetNode)) {
insertPurgeEvent(transaction, targetNode, triggerRouter, triggerHistory,
Expand Down Expand Up @@ -1438,7 +1441,8 @@ private int insertSQLBatchesForReload(Node targetNode, long loadId, String creat
}

//Check the before custom sql is present on the specific table reload request
if (currentRequest != null
if (triggerRouter.getInitialLoadOrder() > -1
&& currentRequest != null
&& currentRequest.getBeforeCustomSql() != null
&& currentRequest.getBeforeCustomSql().length() > 0
&& engine.getGroupletService().isTargetEnabled(triggerRouter,
Expand Down Expand Up @@ -2535,7 +2539,10 @@ public void reloadMissingForeignKeyRowsReverse(String sourceNodeId, Table table,
}

public void reloadMissingForeignKeyRowsForLoad(String sourceNodeId, long batchId, long rowNumber, Table table, CsvData data, String channelId) {
String rowData = CsvUtils.escapeCsvData(data.getCsvData(CsvData.ROW_DATA));
String rowData = data.getCsvData(CsvData.ROW_DATA);
// Replace all actual newlines and carriage returns with \n and \r strings
rowData = rowData.replaceAll("\n", "\\n").replaceAll("\r", "\\r");
rowData = CsvUtils.escapeCsvData(rowData);
Node sourceNode = engine.getNodeService().findNode(sourceNodeId);
String script = "try { engine.getDataService().sendMissingForeignKeyRowsForLoad(" + batchId + ", \""
+ engine.getNodeId() + "\", " + rowNumber + ", " + rowData + "); } catch (Exception e) { }";
Expand Down

0 comments on commit 34f5db3

Please sign in to comment.