use of org.jumpmind.symmetric.model.TableReloadRequest in project symmetric-ds by JumpMind.
the class DataService method insertDeleteBatchesForReload.
private void insertDeleteBatchesForReload(Node targetNode, long loadId, String createBy, List<TriggerHistory> triggerHistories, Map<Integer, List<TriggerRouter>> triggerRoutersByHistoryId, boolean transactional, ISqlTransaction transaction, Map<String, TableReloadRequest> reloadRequests) {
if (reloadRequests != null && reloadRequests.size() > 0) {
int deleteEventsSent = 0;
for (ListIterator<TriggerHistory> triggerHistoryIterator = triggerHistories.listIterator(triggerHistories.size()); triggerHistoryIterator.hasPrevious(); ) {
TriggerHistory triggerHistory = triggerHistoryIterator.previous();
List<TriggerRouter> triggerRouters = triggerRoutersByHistoryId.get(triggerHistory.getTriggerHistoryId());
TableReloadRequest currentRequest = reloadRequests.get(ParameterConstants.ALL + ParameterConstants.ALL);
boolean fullLoad = currentRequest == null ? false : true;
for (ListIterator<TriggerRouter> iterator = triggerRouters.listIterator(triggerRouters.size()); iterator.hasPrevious(); ) {
TriggerRouter triggerRouter = iterator.previous();
if (!fullLoad) {
currentRequest = reloadRequests.get(triggerRouter.getTriggerId() + triggerRouter.getRouterId());
}
//Check the delete flag on the specific table reload request
if (currentRequest != null && currentRequest.isDeleteFirst() && engine.getGroupletService().isTargetEnabled(triggerRouter, targetNode)) {
insertPurgeEvent(transaction, targetNode, triggerRouter, triggerHistory, true, currentRequest.getBeforeCustomSql(), loadId, createBy);
deleteEventsSent++;
if (!transactional) {
transaction.commit();
}
}
}
}
if (deleteEventsSent > 0) {
log.info("Before sending load {} to target node {} delete data events were sent for {} tables", new Object[] { loadId, targetNode, deleteEventsSent });
}
} else {
if (parameterService.is(ParameterConstants.INITIAL_LOAD_DELETE_BEFORE_RELOAD)) {
for (ListIterator<TriggerHistory> triggerHistoryIterator = triggerHistories.listIterator(triggerHistories.size()); triggerHistoryIterator.hasPrevious(); ) {
TriggerHistory triggerHistory = triggerHistoryIterator.previous();
List<TriggerRouter> triggerRouters = triggerRoutersByHistoryId.get(triggerHistory.getTriggerHistoryId());
for (ListIterator<TriggerRouter> iterator = triggerRouters.listIterator(triggerRouters.size()); iterator.hasPrevious(); ) {
TriggerRouter triggerRouter = iterator.previous();
if (triggerRouter.getInitialLoadOrder() >= 0 && engine.getGroupletService().isTargetEnabled(triggerRouter, targetNode) && (!StringUtils.isBlank(parameterService.getString(ParameterConstants.INITIAL_LOAD_DELETE_FIRST_SQL)) || !StringUtils.isEmpty(triggerRouter.getInitialLoadDeleteStmt()))) {
insertPurgeEvent(transaction, targetNode, triggerRouter, triggerHistory, true, null, loadId, createBy);
if (!transactional) {
transaction.commit();
}
}
}
}
}
}
}
use of org.jumpmind.symmetric.model.TableReloadRequest in project symmetric-ds by JumpMind.
the class DataService method insertCreateBatchesForReload.
private void insertCreateBatchesForReload(Node targetNode, long loadId, String createBy, List<TriggerHistory> triggerHistories, Map<Integer, List<TriggerRouter>> triggerRoutersByHistoryId, boolean transactional, ISqlTransaction transaction, Map<String, TableReloadRequest> reloadRequests) {
if (reloadRequests != null && reloadRequests.size() > 0) {
int createEventsSent = 0;
for (TriggerHistory triggerHistory : triggerHistories) {
List<TriggerRouter> triggerRouters = triggerRoutersByHistoryId.get(triggerHistory.getTriggerHistoryId());
TableReloadRequest currentRequest = reloadRequests.get(ParameterConstants.ALL + ParameterConstants.ALL);
boolean fullLoad = currentRequest == null ? false : true;
for (TriggerRouter triggerRouter : triggerRouters) {
if (!fullLoad) {
currentRequest = reloadRequests.get(triggerRouter.getTriggerId() + triggerRouter.getRouterId());
}
//Check the create flag on the specific table reload request
if (currentRequest != null && currentRequest.isCreateTable() && engine.getGroupletService().isTargetEnabled(triggerRouter, targetNode)) {
insertCreateEvent(transaction, targetNode, triggerHistory, triggerRouter.getRouter().getRouterId(), true, loadId, createBy);
createEventsSent++;
if (!transactional) {
transaction.commit();
}
}
}
}
if (createEventsSent > 0) {
log.info("Before sending load {} to target node {} create table events were sent for {} tables", new Object[] { loadId, targetNode, createEventsSent });
}
} else {
if (parameterService.is(ParameterConstants.INITIAL_LOAD_CREATE_SCHEMA_BEFORE_RELOAD)) {
for (TriggerHistory triggerHistory : triggerHistories) {
List<TriggerRouter> triggerRouters = triggerRoutersByHistoryId.get(triggerHistory.getTriggerHistoryId());
for (TriggerRouter triggerRouter : triggerRouters) {
if (triggerRouter.getInitialLoadOrder() >= 0 && engine.getGroupletService().isTargetEnabled(triggerRouter, targetNode)) {
insertCreateEvent(transaction, targetNode, triggerHistory, triggerRouter.getRouter().getRouterId(), true, loadId, createBy);
if (!transactional) {
transaction.commit();
}
}
}
}
}
}
}
Aggregations