Skip to content

Commit

Permalink
swap out messages for inline messages
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Jan 12, 2012
1 parent 666b31b commit 2645483
Show file tree
Hide file tree
Showing 64 changed files with 254 additions and 261 deletions.
Expand Up @@ -46,17 +46,17 @@ protected boolean createTablesIfNecessary() {
+ parameterService.getTablePrefix() + "_trigger_hist") + 1;
platform.getSqlTemplate().update("alter table " + parameterService.getTablePrefix()
+ "_trigger_hist alter column trigger_hist_id restart with " + triggerHistId);
log.info("DB2ResettingAutoIncrementColumns", parameterService.getTablePrefix() + "_trigger_hist");
log.info("Resetting auto increment columns for %s", parameterService.getTablePrefix() + "_trigger_hist");
long outgoingBatchId = platform.getSqlTemplate().queryForLong("select max(batch_id) from "
+ parameterService.getTablePrefix() + "_outgoing_batch") + 1;
platform.getSqlTemplate().update("alter table " + parameterService.getTablePrefix()
+ "_outgoing_batch alter column batch_id restart with " + outgoingBatchId);
log.info("DB2ResettingAutoIncrementColumns", parameterService.getTablePrefix() + "_outgoing_batch");
log.info("Resetting auto increment columns for %s", parameterService.getTablePrefix() + "_outgoing_batch");
long dataId = platform.getSqlTemplate().queryForLong("select max(data_id) from " + parameterService.getTablePrefix()
+ "_data") + 1;
platform.getSqlTemplate().update("alter table " + parameterService.getTablePrefix()
+ "_data alter column data_id restart with " + dataId);
log.info("DB2ResettingAutoIncrementColumns", parameterService.getTablePrefix() + "_data");
log.info("Resetting auto increment columns for %s", parameterService.getTablePrefix() + "_data");
}
return tablesCreated;
}
Expand Down
Expand Up @@ -47,11 +47,11 @@ protected void initTablesAndFunctionsForSpecificDialect() {
transaction.commit();
} catch (Exception e) {
try {
log.info("EnvironmentVariablesCreating", SYNC_TRIGGERS_DISABLED_USER_VARIABLE,
log.info("Creating environment variables %s and %s", SYNC_TRIGGERS_DISABLED_USER_VARIABLE,
SYNC_TRIGGERS_DISABLED_NODE_VARIABLE);
new SqlScript(getSqlScriptUrl(), getPlatform().getSqlTemplate(), ";").execute();
} catch (Exception ex) {
log.error("DB2DialectInitializingError", ex);
log.error("Error while initializing DB2 dialect", ex);
}
} finally {
close(transaction);
Expand Down
Expand Up @@ -49,9 +49,9 @@ protected void createRequiredFunctions() {
platform.getSqlTemplate().queryForInt("select char_length(sym_escape('')) from rdb$database");
} catch (UncategorizedSQLException e) {
if (e.getSQLException().getErrorCode() == -804) {
log.error("FirebirdSymUdfMissing");
log.error("Please install the sym_udf.so/dll to your {firebird_home}/UDF folder");
}
throw new RuntimeException("FirebirdSymEscapeMissing", e);
throw new RuntimeException("Function SYM_ESCAPE is not installed", e);
}
}

Expand Down
Expand Up @@ -68,14 +68,14 @@ public void removeTrigger(StringBuilder sqlBuffer, String catalogName, String sc
try {
int count = platform.getSqlTemplate().update(dropSql);
if (count > 0) {
log.info("TriggerDropped", triggerName);
log.info("Just dropped trigger %s", triggerName);
}
count = platform.getSqlTemplate().update(dropTable);
if (count > 0) {
log.info("TableDropped", triggerName);
log.info("Just dropped table %s_CONFIG", triggerName);
}
} catch (Exception e) {
log.warn("TriggerDropError", triggerName, e.getMessage());
log.warn("Error removing %s: %s", triggerName, e.getMessage());
}
}
}
Expand Down
Expand Up @@ -92,18 +92,18 @@ public void removeTrigger(StringBuilder sqlBuffer, String catalogName, String sc
try {
int count = platform.getSqlTemplate().update(dropSql);
if (count > 0) {
log.info("TriggerDropped", triggerName);
log.info("Just dropped trigger %s", triggerName);
}
} catch (Exception e) {
log.warn("TriggerDropError", triggerName, e.getMessage());
log.warn("Error removing %s: %s", triggerName, e.getMessage());
}
try {
int count = platform.getSqlTemplate().update(dropTable);
if (count > 0) {
log.info("TableDropped", triggerName);
log.info("Just dropped table %s_CONFIG", triggerName);
}
} catch (Exception e) {
log.warn("TriggerDropError", triggerName, e.getMessage());
log.warn("Error removing %s: %s", triggerName, e.getMessage());
}
}
}
Expand Down
Expand Up @@ -58,10 +58,10 @@ public void removeTrigger(StringBuilder sqlBuffer, String catalogName, String sc
try {
int count = platform.getSqlTemplate().update(dropSql);
if (count > 0) {
log.info("TriggerDropped", triggerName);
log.info("Just dropped trigger %s", triggerName);
}
} catch (Exception e) {
log.warn("TriggerDropError", triggerName, e.getMessage());
log.warn("Error removing %s: %s", triggerName, e.getMessage());
}
}
}
Expand Down
Expand Up @@ -60,10 +60,10 @@ protected void initTablesAndFunctionsForSpecificDialect() {
platform.getSqlTemplate().queryForInt("select count(*) from " + contextTableName);
} catch (Exception e) {
try {
log.info("GlobalTempTableCreating", contextTableName);
log.info("Creating global temporary table %s", contextTableName);
platform.getSqlTemplate().update(String.format(CONTEXT_TABLE_CREATE, contextTableName));
} catch (Exception ex) {
log.error("InterbaseDialectInitializingError", ex);
log.error("Error while initializing Interbase dialect", ex);
}
}
}
Expand All @@ -75,9 +75,9 @@ protected void createRequiredFunctions() {
platform.getSqlTemplate().queryForObject("select sym_escape('') from rdb$database", String.class);
} catch (UncategorizedSQLException e) {
if (e.getSQLException().getErrorCode() == -804) {
log.error("InterbaseSymUdfMissing");
log.error("Please install the sym_udf.so/dll to your {interbase_home}/UDF folder");
}
throw new RuntimeException("InterbaseSymEscapeMissing", e);
throw new RuntimeException("Function SYM_ESCAPE is not installed", e);
}
}

Expand Down Expand Up @@ -171,6 +171,6 @@ public void cleanupTriggers() {
for (String name : names) {
count += platform.getSqlTemplate().update("drop trigger " + name);
}
log.info("RemovedTriggers", count);
log.info("Remove %d triggers", count);
}
}
Expand Up @@ -74,7 +74,7 @@ public Boolean execute(Connection con) throws SQLException {
stmt = con.createStatement();
stmt.execute(sql);
} catch (Exception e) {
log.warn("TriggerDropError", triggerName, e.getMessage());
log.warn("Error removing %s: %s", triggerName, e.getMessage());
} finally {
if (catalogName != null) {
con.setCatalog(previousCatalog);
Expand Down
Expand Up @@ -83,7 +83,7 @@ protected void createRequiredFunctions() {
platform.getSqlTemplate().update(
triggerText.getFunctionSql(functions[i], funcName,
platform.getDefaultSchema()));
log.info("FunctionInstalled", funcName);
log.info("Just installed %s", funcName);
}
}
}
Expand Down Expand Up @@ -114,7 +114,7 @@ public void removeTrigger(StringBuilder sqlBuffer, String catalogName, String sc
try {
platform.getSqlTemplate().update(sql);
} catch (Exception e) {
log.warn("TriggerDoesNotExist");
log.warn("Trigger does not exist");
}
}
}
Expand Down
Expand Up @@ -54,7 +54,7 @@ public PostgreSqlSymmetricDialect(IParameterService parameterService, IDatabaseP
@Override
protected void initTablesAndFunctionsForSpecificDialect() {
if (getMajorVersion() > 8 || (getMajorVersion() == 8 && getMinorVersion() >= 3)) {
log.info("TransactionIDSupportEnabling");
log.info("Enabling transaction ID support");
supportsTransactionId = true;
transactionIdExpression = TRANSACTION_ID_EXPRESSION;
}
Expand All @@ -63,8 +63,9 @@ protected void initTablesAndFunctionsForSpecificDialect() {
transaction = platform.getSqlTemplate().startSqlTransaction();
enableSyncTriggers(transaction);
} catch (Exception e) {
log.error("PostgreSqlCustomVariableMissing");
throw new SymmetricException("PostgreSqlCustomVariableMissing", e);
String message = "Please add \"custom_variable_classes = 'symmetric'\" to your postgresql.conf file";
log.error(message);
throw new SymmetricException(message, e);
} finally {
if (transaction != null) {
transaction.close();
Expand Down Expand Up @@ -98,7 +99,7 @@ public void removeTrigger(StringBuilder sqlBuffer, String catalogName, String sc
platform.getSqlTemplate().update(dropSql);
platform.getSqlTemplate().update(dropFunction);
} catch (Exception e) {
log.warn("TriggerDoesNotExist");
log.warn("Trigger does not exist");
}
}
}
Expand Down
Expand Up @@ -75,7 +75,7 @@ public Boolean execute(Connection con) throws SQLException {
stmt = con.createStatement();
stmt.execute(sql);
} catch (Exception e) {
log.warn("TriggerDropError", triggerName, e.getMessage());
log.warn("Error removing %s: %s", triggerName, e.getMessage());
} finally {
if (catalogName != null) {
con.setCatalog(previousCatalog);
Expand Down
Expand Up @@ -337,7 +337,7 @@ public synchronized boolean start(boolean startJobs) {
}

public synchronized void stop() {
log.info("SymmetricDSClosing", getParameterService().getExternalId(), Version.version(),
log.info("Closing SymmetricDS externalId=%s version=%s database=%s", getParameterService().getExternalId(), Version.version(),
symmetricDialect.getName());
if (jobManager != null) {
jobManager.stopJobs();
Expand Down
Expand Up @@ -16,7 +16,8 @@
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License. */
* under the License.
*/

package org.jumpmind.symmetric;

Expand All @@ -38,21 +39,16 @@ public SymmetricException(Throwable cause) {
super(cause);
}

public SymmetricException(String messageKey) {
super(Message.get(messageKey));
}

public SymmetricException(String messageKey, Object... args) {
super(Message.get(messageKey, args));
public SymmetricException(String message, Object... args) {
super(String.format(message, args));
}

public SymmetricException(String messageKey, Throwable cause) {
super(Message.get(messageKey), cause);
public SymmetricException(String message, Throwable cause) {
super(message, cause);
}

public SymmetricException(String messageKey, Throwable cause,
Object... args) {
super(Message.get(messageKey, args), cause);
public SymmetricException(String message, Throwable cause, Object... args) {
super(String.format(message, args), cause);
}

}
Expand Up @@ -167,7 +167,7 @@ final public boolean doesTriggerExist(String catalogName, String schema, String
try {
return doesTriggerExistOnPlatform(catalogName, schema, tableName, triggerName);
} catch (Exception ex) {
log.warn("TriggerMayExist", ex);
log.warn("Could not figure out if the trigger exists. Assuming that is does not", ex);
return false;
}
}
Expand All @@ -181,7 +181,7 @@ protected void createRequiredFunctions() {
this.platform.getSqlTemplate().update(
triggerText.getFunctionSql(functions[i], funcName,
platform.getDefaultSchema()));
log.info("FunctionInstalled", funcName);
log.info("Just installed %s", funcName);
}
}
}
Expand Down Expand Up @@ -248,7 +248,7 @@ public void removeTrigger(StringBuilder sqlBuffer, String catalogName, String sc
try {
this.platform.getSqlTemplate().update(sql);
} catch (Exception e) {
log.warn("TriggerDoesNotExist");
log.warn("Trigger does not exist");
}
}
}
Expand Down Expand Up @@ -495,7 +495,7 @@ protected Database readSymmetricSchemaFromXml() {
readDatabaseFromXml("/console-schema.xml"));

if (prefixConfigDatabase(database)) {
log.info("TablesMissing");
log.info("There are SymmetricDS tables missing. They will be auto created.");
}
return database;
} catch (RuntimeException ex) {
Expand Down
Expand Up @@ -131,9 +131,9 @@ public List<ExtensionPointMetaData> getExtensionPoints() {
protected boolean registerExtension(String beanName, IExtensionPoint ext) {
boolean installed = false;
if (ext instanceof IBuiltInExtensionPoint) {
log.debug("ExtensionRegistering", beanName, ext.getClass().getSimpleName());
log.debug("Registering an extension point named %s of type '%s' with SymmetricDS", beanName, ext.getClass().getSimpleName());
} else {
log.info("ExtensionRegistering", beanName, ext.getClass().getSimpleName());
log.info("Registering an extension point named %s of type '%s' with SymmetricDS", beanName, ext.getClass().getSimpleName());
}

if (ext instanceof ISyncUrlExtension) {
Expand Down
Expand Up @@ -94,7 +94,7 @@ public boolean isAutoStartConfigured() {

public void start() {
if (this.scheduledJob == null) {
log.info("JobStarting", jobName);
log.info("Starting %s", jobName);
if (!StringUtils.isBlank(cronExpression)) {
this.scheduledJob = taskScheduler.schedule(this, new CronTrigger(cronExpression));
started = true;
Expand All @@ -107,7 +107,7 @@ public void start() {
this.timeBetweenRunsInMs);
started = true;
} else {
log.error("JobFailedToSchedule", jobName);
log.error("Failed to schedule this job, %s", jobName);
}
}
}
Expand All @@ -119,10 +119,10 @@ public boolean stop() {
success = this.scheduledJob.cancel(true);
this.scheduledJob = null;
if (success) {
log.info("JobCancelled", jobName);
log.info("The %s job has been cancelled.", jobName);
started = false;
} else {
log.warn("JobFailedToCancel", jobName);
log.warn("Failed to cancel this job, %s", jobName);
}
}
return success;
Expand All @@ -141,7 +141,7 @@ public boolean invoke(boolean force) {
boolean ran = false;
try {
if (engine == null) {
log.info("SymmetricEngineMissing", jobName);
log.info("Could not find a reference to the SymmetricEngine from %s", jobName);
} else if (engine.isStarted()) {
if (!paused || force) {
if (!running) {
Expand All @@ -158,7 +158,7 @@ public boolean invoke(boolean force) {
processCount = doJob();
} else {
if (!hasNotRegisteredMessageBeenLogged) {
log.warn("SymmetricEngineNotRegistered", getName());
log.warn("Did not run the %s job because the engine is not registered.", getName());
hasNotRegisteredMessageBeenLogged = true;
}
}
Expand All @@ -180,7 +180,7 @@ public boolean invoke(boolean force) {
}
}
} else {
log.info("SymmetricEngineNotStarted");
log.info("The engine is not currently started.");
}
} catch (final Throwable ex) {
log.error(ex);
Expand Down
Expand Up @@ -56,7 +56,7 @@ public DefaultOfflineServerListener(Log log, IStatisticManager statisticManager,
* outgoing batches.
*/
public void clientNodeOffline(Node node) {
log.warn("NodeOffline", node.getNodeId(), node.getHeartbeatTime(), node.getTimezoneOffset());
log.warn("Node %s is offline. Last heartbeat was %s, timezone %s. Syncing will be disabled and node security deleted.", node.getNodeId(), node.getHeartbeatTime(), node.getTimezoneOffset());
statisticManager.incrementNodesDisabled(1);
node.setSyncEnabled(false);
nodeService.updateNode(node);
Expand Down
Expand Up @@ -44,7 +44,7 @@ public long doJob() throws Exception {
while (engine.getNodeService().isDataLoadStarted() &&
!statuses.errorOccurred() &&
statuses.wasBatchProcessed()) {
log.info("DataPullingInReloadMode");
log.info("Immediate pull requested while in reload mode.");
statuses = engine.getPullService().pullData();
}

Expand Down
Expand Up @@ -137,12 +137,12 @@ public <R extends IDataReader, W extends IDataWriter> void batchCommitted(
if (context.get(CTX_KEY_RESYNC_NEEDED) != null
&& parameterService.is(ParameterConstants.AUTO_SYNC_CONFIGURATION)
&& parameterService.is(ParameterConstants.AUTO_SYNC_TRIGGERS)) {
log.info("ConfigurationChanged");
log.info(".");
triggerRouterService.syncTriggers();
}
if (context.get(CTX_KEY_FLUSH_TRANSFORMS_NEEDED) != null
&& parameterService.is(ParameterConstants.AUTO_SYNC_CONFIGURATION)) {
log.info("ConfigurationChanged");
log.info(".");
transformService.resetCache();
}
}
Expand Down
Expand Up @@ -240,6 +240,6 @@ protected Set<String> toExternalIds(Set<Node> nodes) {
* Override if needed.
*/
public void completeBatch(SimpleRouterContext context, OutgoingBatch batch) {
log.debug("BatchCompleting", batch.getBatchId());
log.debug("Completing batch %d", batch.getBatchId());
}
}
Expand Down

0 comments on commit 2645483

Please sign in to comment.