use of org.jumpmind.db.sql.UniqueKeyException in project symmetric-ds by JumpMind.
the class IncomingBatchService method acquireIncomingBatch.
public boolean acquireIncomingBatch(IncomingBatch batch) {
boolean okayToProcess = true;
if (batch.isPersistable()) {
IncomingBatch existingBatch = null;
if (isRecordOkBatchesEnabled()) {
try {
insertIncomingBatch(batch);
} catch (UniqueKeyException e) {
batch.setRetry(true);
existingBatch = findIncomingBatch(batch.getBatchId(), batch.getNodeId());
}
} else {
existingBatch = findIncomingBatch(batch.getBatchId(), batch.getNodeId());
if (existingBatch != null) {
batch.setRetry(true);
}
}
if (batch.isRetry()) {
if (existingBatch.getStatus() == Status.ER || existingBatch.getStatus() == Status.LD || existingBatch.getStatus() == Status.RS || !parameterService.is(ParameterConstants.INCOMING_BATCH_SKIP_DUPLICATE_BATCHES_ENABLED)) {
okayToProcess = true;
existingBatch.setStatus(Status.LD);
log.info("Retrying batch {}", batch.getNodeBatchId());
} else if (existingBatch.getStatus() == Status.IG) {
okayToProcess = false;
batch.setStatus(Status.OK);
batch.incrementIgnoreCount();
existingBatch.setStatus(Status.OK);
existingBatch.incrementIgnoreCount();
log.info("Ignoring batch {}", batch.getNodeBatchId());
} else {
okayToProcess = false;
batch.setStatus(existingBatch.getStatus());
batch.setByteCount(existingBatch.getByteCount());
batch.setDatabaseMillis(existingBatch.getDatabaseMillis());
batch.setNetworkMillis(existingBatch.getNetworkMillis());
batch.setFilterMillis(existingBatch.getFilterMillis());
batch.setSkipCount(existingBatch.getSkipCount() + 1);
batch.setStatementCount(existingBatch.getStatementCount());
existingBatch.setSkipCount(existingBatch.getSkipCount() + 1);
log.info("Skipping batch {}", batch.getNodeBatchId());
}
updateIncomingBatch(existingBatch);
}
}
return okayToProcess;
}
use of org.jumpmind.db.sql.UniqueKeyException in project symmetric-ds by JumpMind.
the class DataService method insertCreateEvent.
public void insertCreateEvent(ISqlTransaction transaction, Node targetNode, TriggerHistory triggerHistory, String routerId, boolean isLoad, long loadId, String createBy) {
Trigger trigger = engine.getTriggerRouterService().getTriggerById(triggerHistory.getTriggerId(), false);
String reloadChannelId = getReloadChannelIdForTrigger(trigger, engine.getConfigurationService().getChannels(false));
Data data = new Data(triggerHistory.getSourceTableName(), DataEventType.CREATE, null, null, triggerHistory, isLoad ? reloadChannelId : Constants.CHANNEL_CONFIG, null, null);
data.setNodeList(targetNode.getNodeId());
try {
if (isLoad) {
insertDataAndDataEventAndOutgoingBatch(transaction, data, targetNode.getNodeId(), routerId, isLoad, loadId, createBy, Status.NE);
} else {
insertData(transaction, data);
}
} catch (UniqueKeyException e) {
if (e.getRootCause() != null && e.getRootCause() instanceof DataTruncation) {
log.error("Table data definition XML was too large and failed. The feature to send table creates during the initial load may be limited on your platform. You may need to set the initial.load.create.first parameter to false.");
}
throw e;
}
}
use of org.jumpmind.db.sql.UniqueKeyException in project symmetric-ds by JumpMind.
the class NodeService method findOrCreateNodeSecurity.
public NodeSecurity findOrCreateNodeSecurity(String nodeId) {
try {
if (nodeId != null) {
NodeSecurity security = findNodeSecurity(nodeId, false);
if (security == null) {
insertNodeSecurity(nodeId);
security = findNodeSecurity(nodeId, true);
}
return security;
} else {
log.debug("A 'null' node id was passed into findNodeSecurity");
return null;
}
} catch (UniqueKeyException ex) {
log.error("Could not find a node security row for '{}'", nodeId);
throw ex;
}
}
Aggregations