use of org.jumpmind.symmetric.SymmetricException in project symmetric-ds by JumpMind.
the class MsSqlSymmetricDialect method verifyDatabaseIsCompatible.
@Override
public void verifyDatabaseIsCompatible() {
super.verifyDatabaseIsCompatible();
ISqlTemplate template = getPlatform().getSqlTemplate();
if (template.queryForInt("select case when (512 & @@options) = 512 then 1 else 0 end") == 1) {
throw new SymmetricException("NOCOUNT is currently turned ON. SymmetricDS will not function with NOCOUNT turned ON.");
}
}
use of org.jumpmind.symmetric.SymmetricException in project symmetric-ds by JumpMind.
the class BshDatabaseWriterFilter method executeScripts.
@Override
protected void executeScripts(DataContext context, String key, Set<String> scripts, boolean isFailOnError) {
Interpreter interpreter = getInterpreter(context);
String currentScript = null;
try {
bind(interpreter, context, null, null, null);
if (scripts != null) {
for (String script : scripts) {
currentScript = script;
interpreter.eval(script);
}
}
} catch (EvalError e) {
if (e instanceof ParseException) {
String errorMsg = String.format("Evaluation error while parsing the following beanshell script:\n\n%s\n\nThe error was on line %d and the error message was: %s", currentScript, e.getErrorLineNumber(), e.getMessage());
log.error(errorMsg, e);
if (isFailOnError) {
throw new SymmetricException(errorMsg);
}
} else if (e instanceof TargetError) {
Throwable target = ((TargetError) e).getTarget();
String errorMsg = String.format("Evaluation error occured in the following beanshell script:\n\n%s\n\nThe error was on line %d", currentScript, e.getErrorLineNumber());
log.error(errorMsg, target);
if (isFailOnError) {
if (target instanceof RuntimeException) {
throw (RuntimeException) target;
} else {
throw new SymmetricException(target);
}
} else {
log.error("Failed while evaluating script", target);
}
}
}
}
use of org.jumpmind.symmetric.SymmetricException in project symmetric-ds by JumpMind.
the class DataExtractorService method lookupAndOrderColumnsAccordingToTriggerHistory.
protected Table lookupAndOrderColumnsAccordingToTriggerHistory(String routerId, TriggerHistory triggerHistory, boolean setTargetTableName, boolean useDatabaseDefinition) {
String catalogName = triggerHistory.getSourceCatalogName();
String schemaName = triggerHistory.getSourceSchemaName();
String tableName = triggerHistory.getSourceTableName();
Table table = null;
if (useDatabaseDefinition) {
table = platform.getTableFromCache(catalogName, schemaName, tableName, false);
if (table != null && table.getColumnCount() < triggerHistory.getParsedColumnNames().length) {
/*
* If the column count is less than what trigger history
* reports, then chances are the table cache is out of date.
*/
table = platform.getTableFromCache(catalogName, schemaName, tableName, true);
}
if (table != null) {
table = table.copyAndFilterColumns(triggerHistory.getParsedColumnNames(), triggerHistory.getParsedPkColumnNames(), true);
} else {
throw new SymmetricException("Could not find the following table. It might have been dropped: %s", Table.getFullyQualifiedTableName(catalogName, schemaName, tableName));
}
} else {
table = new Table(tableName);
table.addColumns(triggerHistory.getParsedColumnNames());
table.setPrimaryKeys(triggerHistory.getParsedPkColumnNames());
}
Router router = triggerRouterService.getRouterById(true, routerId, false);
if (router != null && setTargetTableName) {
if (router.isUseSourceCatalogSchema()) {
table.setCatalog(catalogName);
table.setSchema(schemaName);
} else {
table.setCatalog(null);
table.setSchema(null);
}
if (StringUtils.equals(Constants.NONE_TOKEN, router.getTargetCatalogName())) {
table.setCatalog(null);
} else if (StringUtils.isNotBlank(router.getTargetCatalogName())) {
table.setCatalog(router.getTargetCatalogName());
}
if (StringUtils.equals(Constants.NONE_TOKEN, router.getTargetSchemaName())) {
table.setSchema(null);
} else if (StringUtils.isNotBlank(router.getTargetSchemaName())) {
table.setSchema(router.getTargetSchemaName());
}
if (StringUtils.isNotBlank(router.getTargetTableName())) {
table.setName(router.getTargetTableName());
}
}
return table;
}
use of org.jumpmind.symmetric.SymmetricException in project symmetric-ds by JumpMind.
the class AbstractService method readAcks.
protected List<BatchAck> readAcks(List<OutgoingBatch> batches, IOutgoingWithResponseTransport transport, ITransportManager transportManager, IAcknowledgeService acknowledgeService) throws IOException {
Set<Long> batchIds = new HashSet<Long>(batches.size());
for (OutgoingBatch outgoingBatch : batches) {
if (outgoingBatch.getStatus() == OutgoingBatch.Status.LD) {
batchIds.add(outgoingBatch.getBatchId());
}
}
BufferedReader reader = transport.readResponse();
String ackString = reader.readLine();
String ackExtendedString = reader.readLine();
log.debug("Reading ack: {}", ackString);
log.debug("Reading extend ack: {}", ackExtendedString);
String line = null;
do {
line = reader.readLine();
if (line != null) {
log.info("Read another unexpected line {}", line);
}
} while (line != null);
if (StringUtils.isBlank(ackString)) {
throw new SymmetricException("Did not receive an acknowledgement for the batches sent. " + "The 'ack string' was: '%s' and the 'extended ack string' was: '%s'", ackString, ackExtendedString);
}
List<BatchAck> batchAcks = transportManager.readAcknowledgement(ackString, ackExtendedString);
long batchIdInError = Long.MAX_VALUE;
for (BatchAck batchInfo : batchAcks) {
batchIds.remove(batchInfo.getBatchId());
if (batchInfo.getStatus() == Status.ER) {
batchIdInError = batchInfo.getBatchId();
}
log.debug("Saving ack: {}, {}", batchInfo.getBatchId(), batchInfo.getStatus());
acknowledgeService.ack(batchInfo);
}
for (Long batchId : batchIds) {
if (batchId < batchIdInError) {
log.error("We expected but did not receive an ack for batch {}", batchId);
}
}
return batchAcks;
}
Aggregations