Skip to content

Commit

Permalink
quoted delimiter mode is always on.
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Jan 31, 2012
1 parent 9964c96 commit 56708da
Show file tree
Hide file tree
Showing 49 changed files with 659 additions and 789 deletions.
14 changes: 12 additions & 2 deletions symmetric/symmetric-assemble/TODO.txt
Expand Up @@ -34,6 +34,12 @@ DONE = +
* unit test
+ purge job for staging manager
+ make sure memory buffer is cleared when state goes to done

* Make SymmetricDS case sensitive
* Get rid of delimited identifier "force" properties
* Add property to platform that identifies the default case used by the database
* Pre-process SQL to make sure symmetric tables are quoted and use the default case of the database
* Pre-process symmetric tables to default them to the case of the database

* Hook up JMX

Expand All @@ -57,7 +63,8 @@ DONE = +
* Test timezone columns. Do other databases other than oracle and postgres have timezone columns?

Performance Improvement Opportunities
* Pluggable data loaders.
* Pluggable data loaders
* Make push/pull/routing of channels asynchronous
* Sync based on updated column values (timestamp or flag)
* Transaction Log Parsing (vs. triggers)
* Optimize triggers (don't capture old data. option to capture only primary keys)
Expand All @@ -83,4 +90,7 @@ Documentation
* No longer stop purge from running if there wasn't an initial load
* Extensions no longer have services injected into them. If they need acccess to services, they should implement ISymmetricEngineAware
* Node concurrency manager no longer allows the same node to make a second request while it already has a reservation
* Added stage management job (that purges staged files)
* Added stage management job (that purges staged files)
* Removed support for db.force.delimited.identifier.mode.on & db.force.delimited.identifier.mode.off
* Removed support for db.metadata.ignore.case

Expand Up @@ -2,14 +2,12 @@

import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;

import org.apache.commons.io.FileUtils;
import org.jumpmind.db.io.DatabaseIO;
import org.jumpmind.db.model.Database;
import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.db.platform.IDdlBuilder;
Expand All @@ -24,16 +22,18 @@
import org.slf4j.LoggerFactory;

abstract public class TestSetupUtil {

private static final Logger logger = LoggerFactory.getLogger(TestSetupUtil.class);

static private ISymmetricEngine engine;

public static ISymmetricEngine prepareForServiceTests() {
if (engine == null) {
removeEmbededdedDatabases();
EnvironmentSpecificProperties properties = new EnvironmentSpecificProperties(new URL[] {getResource("/test-db.properties"), getResource("/symmetric-test.properties")},
"test.root", new String[] { "root" });
EnvironmentSpecificProperties properties = new EnvironmentSpecificProperties(
new URL[] { getResource("/test-db.properties"),
getResource("/symmetric-test.properties") }, "test.root",
new String[] { "root" });
properties.setProperty(ParameterConstants.AUTO_CONFIGURE_REG_SVR_SQL_SCRIPT,
"/test-services-setup.sql");
engine = new ClientSymmetricEngine(properties);
Expand All @@ -56,7 +56,7 @@ protected static void dropAndCreateDatabaseTables(String databaseType, ISymmetri
new SqlScript(url, dialect.getPlatform().getSqlTemplate(), false).execute(true);
}

Database testDb = getTestDatabase();
Database testDb = getTestDatabase(dialect.getPlatform());
IDdlBuilder builder = platform.getDdlBuilder();
String sql = builder.dropTables(testDb);
new SqlScript(sql, dialect.getPlatform().getSqlTemplate(), false).execute(true);
Expand All @@ -79,9 +79,8 @@ protected static void dropAndCreateDatabaseTables(String databaseType, ISymmetri
}
}

protected static Database getTestDatabase() throws IOException {
return new DatabaseIO().read(new InputStreamReader(getResource("/test-schema.xml")
.openStream()));
protected static Database getTestDatabase(IDatabasePlatform platform) throws IOException {
return platform.readDatabaseFromXml("/test-schema.xml", true);
}

protected static boolean isConnectionValid(Properties properties) throws Exception {
Expand Down Expand Up @@ -116,7 +115,7 @@ protected static void removeEmbededdedDatabases() {
logger.info("Removing root database files");
FileUtils.deleteDirectory(rootDbDir);
} catch (IOException e) {
logger.error(e.getMessage(),e);
logger.error(e.getMessage(), e);
}
}
}
Expand Down
Expand Up @@ -188,11 +188,6 @@ protected void init() {

MDC.put("engineName", this.parameterService.getEngineName());

if (parameterService.is(ParameterConstants.DB_FORCE_DELIMITED_IDENTIFIER_ON)) {
this.platform.setDelimitedIdentifierModeOn(true);
} else if (parameterService.is(ParameterConstants.DB_FORCE_DELIMITED_IDENTIFIER_OFF)) {
this.platform.setDelimitedIdentifierModeOn(false);
}
this.platform.setClearCacheModelTimeoutInMs(parameterService
.getLong(ParameterConstants.CACHE_TIMEOUT_TABLES_IN_MS));

Expand Down
Expand Up @@ -158,11 +158,8 @@ private ParameterConstants() {
public final static String DBPOOL_CONNECTION_PROPERTIES = "db.connection.properties";

public final static String DB_NATIVE_EXTRACTOR = "db.native.extractor";
public final static String DB_METADATA_IGNORE_CASE = "db.metadata.ignore.case";
public final static String DB_QUERY_TIMEOUT_SECS = "db.sql.query.timeout.seconds";
public final static String DB_FETCH_SIZE = "db.jdbc.streaming.results.fetch.size";
public final static String DB_FORCE_DELIMITED_IDENTIFIER_ON = "db.force.delimited.identifier.mode.on";
public final static String DB_FORCE_DELIMITED_IDENTIFIER_OFF = "db.force.delimited.identifier.mode.off";

public final static String RUNTIME_CONFIG_TABLE_PREFIX = "sync.table.prefix";

Expand Down
Expand Up @@ -16,46 +16,111 @@
* "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.common;

import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang.StringUtils;

/**
* Constants that represent SymmetricDS tables
*/
public class TableConstants {

public static final String SYM_PARAMETER = "parameter";
public static final String SYM_LOCK = "lock";
public static final String SYM_OUTGOING_BATCH = "outgoing_batch";
public static final String SYM_INCOMING_BATCH = "incoming_batch";
public static final String SYM_TRIGGER = "trigger";
public static final String SYM_TRIGGER_ROUTER = "trigger_router";
public static final String SYM_ROUTER = "router";
public static final String SYM_TRANSFORM_TABLE = "transform_table";
public static final String SYM_TRANSFORM_COLUMN = "transform_column";
public static final String SYM_TRIGGER_HIST = "trigger_hist";
public static final String SYM_CHANNEL = "channel";
public static final String SYM_NODE_GROUP = "node_group";
public static final String SYM_NODE_GROUP_LINK = "node_group_link";

public static final String SYM_NODE = "node";
public static final String SYM_NODE_HOST = "node_host";
public static final String SYM_DATA = "data";
public static final String SYM_DATA_GAP = "data_gap";
public static final String SYM_DATA_EVENT = "data_event";
public static final String SYM_TRANSFORM_TABLE = "transform_table";
public static final String SYM_TRANSFORM_COLUMN = "transform_column";
public static final String SYM_TRIGGER_ROUTER = "trigger_router";
public static final String SYM_CHANNEL = "channel";
public static final String SYM_NODE_SECURITY = "node_security";
public static final String SYM_NODE_IDENTITY = "node_identity";
public static final String SYM_NODE_GROUP_LINK = "node_group_link";
public static final String SYM_NODE_HOST_STATS = "node_host_stats";
public static final String SYM_NODE_HOST_JOB_STATS = "node_host_job_stats";
public static final String SYM_REGISTRATION_REQUEST = "registration_request";
public static final String SYM_REGISTRATION_REDIRECT = "registration_redirect";
public static final String SYM_NODE_CHANNEL_CTL = "node_channel_ctl";
public static final String SYM_NODE_GROUP_CHANNEL_WINDOW = "node_group_channel_window";
public static final String SYM_PARAMETER = "parameter";
public static final String SYM_NODE_HOST_CHANNEL_STATS = "node_host_channel_stats";

private static Set<String> tablesWithPrefix;

private static Set<String> tablesWithoutPrefix;

public static String[] NODE_TABLES = { SYM_NODE, SYM_NODE_SECURITY, SYM_NODE_IDENTITY };

public static final Set<String> getTables(String tablePrefix) {
if (tablesWithPrefix == null) {
tablesWithPrefix = populateAllTables(tablePrefix);
}
return tablesWithPrefix;
}

public static final Set<String> getTablesWithoutPrefix() {
if (tablesWithoutPrefix == null) {
tablesWithoutPrefix = populateAllTables("");
}
return tablesWithoutPrefix;
}

protected static Set<String> populateAllTables(String tablePrefix) {
HashSet<String> tables = new HashSet<String>();
tables.add(getTableName(tablePrefix, SYM_TRIGGER));
tables.add(getTableName(tablePrefix, SYM_TRIGGER_ROUTER));
tables.add(getTableName(tablePrefix, SYM_ROUTER));
tables.add(getTableName(tablePrefix, SYM_TRANSFORM_TABLE));
tables.add(getTableName(tablePrefix, SYM_TRANSFORM_COLUMN));
tables.add(getTableName(tablePrefix, SYM_TRIGGER_HIST));
tables.add(getTableName(tablePrefix, SYM_CHANNEL));
tables.add(getTableName(tablePrefix, SYM_NODE_GROUP));
tables.add(getTableName(tablePrefix, SYM_NODE_GROUP_LINK));
tables.add(getTableName(tablePrefix, SYM_NODE));
tables.add(getTableName(tablePrefix, SYM_NODE_HOST));
tables.add(getTableName(tablePrefix, SYM_NODE_SECURITY));
tables.add(getTableName(tablePrefix, SYM_NODE_IDENTITY));
tables.add(getTableName(tablePrefix, SYM_NODE_SECURITY));
tables.add(getTableName(tablePrefix, SYM_NODE_CHANNEL_CTL));
tables.add(getTableName(tablePrefix, SYM_NODE_GROUP_CHANNEL_WINDOW));
tables.add(getTableName(tablePrefix, SYM_PARAMETER));
tables.add(getTableName(tablePrefix, SYM_NODE_HOST_CHANNEL_STATS));
tables.add(getTableName(tablePrefix, SYM_NODE_HOST_STATS));
tables.add(getTableName(tablePrefix, SYM_NODE_HOST_JOB_STATS));
tables.add(getTableName(tablePrefix, SYM_REGISTRATION_REDIRECT));
tables.add(getTableName(tablePrefix, SYM_REGISTRATION_REQUEST));
tables.add(getTableName(tablePrefix, SYM_DATA));
tables.add(getTableName(tablePrefix, SYM_DATA_GAP));
tables.add(getTableName(tablePrefix, SYM_DATA_EVENT));
tables.add(getTableName(tablePrefix, SYM_OUTGOING_BATCH));
tables.add(getTableName(tablePrefix, SYM_INCOMING_BATCH));
tables.add(getTableName(tablePrefix, SYM_LOCK));
return tables;
}

public static final Set<String> getTablesThatDoNotSync(String tablePrefix) {
Set<String> tables = new HashSet<String>();
Set<String> tables = new HashSet<String>(2);
tables.add(getTableName(tablePrefix, SYM_NODE_IDENTITY));
tables.add(getTableName(tablePrefix, SYM_NODE_CHANNEL_CTL));
return tables;
}

public static String getTableName(String tablePrefix, String tableSuffix) {
return String.format("%s_%s", tablePrefix, tableSuffix);
return String.format("%s%s%s", tablePrefix, StringUtils.isNotBlank(tablePrefix) ? "_" : "",
tableSuffix);
}
}

0 comments on commit 56708da

Please sign in to comment.