Skip to content

Commit

Permalink
Merge branch '3.9' of https://github.com/JumpMind/symmetric-ds.git in…
Browse files Browse the repository at this point in the history
…to 3.9
  • Loading branch information
erilong committed Jul 28, 2017
2 parents b850d93 + 871fa65 commit ea6ef8f
Show file tree
Hide file tree
Showing 35 changed files with 556 additions and 596 deletions.
Expand Up @@ -30,19 +30,19 @@ public JobManagerSqlMap(IDatabasePlatform platform, Map<String, String> replacem
super(platform, replacementTokens);

putSql("loadCustomJobs",
"select * from $(schemaName)$(job) order by job_type, job_name");
"select * from $(job) order by job_type, job_name");

putSql("insertJobSql", "insert into $(schemaName)$(job) (description, job_type, job_expression, "
putSql("insertJobSql", "insert into $(job) (description, job_type, job_expression, "
+ "default_auto_start, default_schedule, node_group_id, "
+ "create_by, create_time, last_update_by, last_update_time, job_name) " +
"values (?, ?, ?, ?, ?, ?, ?, current_timestamp, ?, current_timestamp, ?)");

putSql("updateJobSql", "update $(schemaName)$(job) set description = ?, job_type = ?, job_expression = ?, "
putSql("updateJobSql", "update $(job) set description = ?, job_type = ?, job_expression = ?, "
+ "default_auto_start = ?, default_schedule = ?, node_group_id = ?, "
+ "create_by = ?, last_update_by = ?, last_update_time = current_timestamp "
+ "where job_name = ?");

putSql("deleteJobSql", "delete from $(schemaName)$(job) where job_name = ? and job_type <> 'BUILT_IN'");
putSql("deleteJobSql", "delete from $(job) where job_name = ? and job_type <> 'BUILT_IN'");
}

}
Expand Up @@ -169,7 +169,7 @@ public String createInitalLoadSql(Node node, TriggerRouter triggerRouter, Table
}
sql = FormatUtils.replace("columns", columnsText, sql);
} else {
sql = "select $(columns) from $(schemaName)$(tableName) t where $(whereClause)";
sql = "select $(columns) from $(tableName) t where $(whereClause)";
StringBuilder columnList = new StringBuilder();
for (int i = 0; i < columns.length; i++) {
Column column = columns[i];
Expand Down
Expand Up @@ -141,17 +141,12 @@ public static Map<String, String> createSqlReplacementTokens(String tablePrefix,
String quotedIdentifier, IDatabasePlatform platform) {
Map<String, String> map = new HashMap<String, String>();
List<String> tables = TableConstants.getTablesWithoutPrefix();
// if(platform instanceof NuoDbDatabasePlatform){
// for(String table : tables){
// map.put(table, String.format("%s%s%s%s%s", platform.getDefaultSchema(), ".", tablePrefix,
// StringUtils.isNotBlank(tablePrefix) ? "_": "", table));
// }
// }else{

for (String table : tables) {
map.put(table, String.format("%s%s%s", tablePrefix,
StringUtils.isNotBlank(tablePrefix) ? "_" : "", table));
}
// }

return map;
}

Expand Down
Expand Up @@ -30,7 +30,7 @@ public AcknowledgeServiceSqlMap(IDatabasePlatform platform,
Map<String, String> replacementTokens) {
super(platform, replacementTokens);
putSql("selectDataIdSql",
"select data_id from $(schemaName)$(data_event) b where batch_id = ? order by data_id ");
"select data_id from $(data_event) b where batch_id = ? order by data_id ");
}

}
Expand Up @@ -29,59 +29,59 @@ public class ClusterServiceSqlMap extends AbstractSqlMap {
public ClusterServiceSqlMap(IDatabasePlatform platform, Map<String, String> replacementTokens) {
super(platform, replacementTokens);

putSql("deleteSql", "delete from $(schemaName)$(lock)");
putSql("deleteSql", "delete from $(lock)");

putSql("acquireClusterLockSql",
"update $(schemaName)$(lock) set locking_server_id=?, lock_time=? " +
"update $(lock) set locking_server_id=?, lock_time=? " +
"where lock_action=? and lock_type=? and (lock_time is null or lock_time < ? or locking_server_id=?)");

putSql("acquireSharedLockSql",
"update $(schemaName)$(lock) set lock_type=?, locking_server_id=?, lock_time=?, " +
"update $(lock) set lock_type=?, locking_server_id=?, lock_time=?, " +
"shared_enable=(case when shared_count = 0 then 1 else shared_enable end), shared_count=shared_count+1 " +
"where lock_action=? and (lock_type=? or lock_time is null or lock_time < ?) " +
"and (shared_enable = 1 or shared_count = 0)");

putSql("disableSharedLockSql",
"update $(schemaName)$(lock) set shared_enable=0 where lock_action=? and lock_type=?");
"update $(lock) set shared_enable=0 where lock_action=? and lock_type=?");

putSql("acquireExclusiveLockSql",
"update $(schemaName)$(lock) set lock_type=?, locking_server_id=?, lock_time=?, shared_count=0 " +
"update $(lock) set lock_type=?, locking_server_id=?, lock_time=?, shared_count=0 " +
"where lock_action=? and ((lock_type=? and shared_count = 0) or lock_time is null or lock_time < ?)");

putSql("releaseClusterLockSql",
"update $(schemaName)$(lock) set last_locking_server_id=locking_server_id, locking_server_id=null, last_lock_time=lock_time, lock_time=null " +
"update $(lock) set last_locking_server_id=locking_server_id, locking_server_id=null, last_lock_time=lock_time, lock_time=null " +
"where lock_action=? and lock_type=? and locking_server_id=?");

putSql("resetClusterLockSql",
"update $(schemaName)$(lock) set last_locking_server_id=null, locking_server_id=null, last_lock_time=null, lock_time=null " +
"update $(lock) set last_locking_server_id=null, locking_server_id=null, last_lock_time=null, lock_time=null " +
"where lock_action=? and lock_type=? and locking_server_id=?");

putSql("releaseSharedLockSql",
"update $(schemaName)$(lock) set last_lock_time=lock_time, last_locking_server_id=locking_server_id, " +
"update $(lock) set last_lock_time=lock_time, last_locking_server_id=locking_server_id, " +
"shared_enable=(case when shared_count = 1 then 0 else shared_enable end), " +
"locking_server_id = (case when shared_count = 1 then null else locking_server_id end), " +
"lock_time = (case when shared_count = 1 then null else lock_time end), " +
"shared_count=(case when shared_count > 1 then shared_count-1 else 0 end) " +
"where lock_action=? and lock_type=?");

putSql("releaseExclusiveLockSql",
"update $(schemaName)$(lock) set last_locking_server_id=locking_server_id, locking_server_id=null, last_lock_time=lock_time, lock_time=null " +
"update $(lock) set last_locking_server_id=locking_server_id, locking_server_id=null, last_lock_time=lock_time, lock_time=null " +
"where lock_action=? and lock_type=?");

putSql("initLockSql",
"update $(schemaName)$(lock) set last_locking_server_id=locking_server_id, locking_server_id=null, last_lock_time=lock_time, " +
"update $(lock) set last_locking_server_id=locking_server_id, locking_server_id=null, last_lock_time=lock_time, " +
"lock_time=null, shared_count=0, shared_enable=0 " +
"where locking_server_id=?");

putSql("insertLockSql", "insert into $(schemaName)$(lock) (lock_action, lock_type) values(?,?)");
putSql("insertLockSql", "insert into $(lock) (lock_action, lock_type) values(?,?)");

putSql("insertCompleteLockSql",
"insert into $(schemaName)$(lock) (lock_action, lock_type, locking_server_id, lock_time, shared_count, shared_enable, last_lock_time, last_locking_server_id) values(?,?,?,?,?,?,?,?)");
"insert into $(lock) (lock_action, lock_type, locking_server_id, lock_time, shared_count, shared_enable, last_lock_time, last_locking_server_id) values(?,?,?,?,?,?,?,?)");

putSql("findLocksSql",
"select lock_action, lock_type, locking_server_id, lock_time, shared_count, shared_enable, " +
"last_locking_server_id, last_lock_time " +
"from $(schemaName)$(lock)");
"from $(lock)");

}

Expand Down
Expand Up @@ -32,42 +32,42 @@ public ConfigurationServiceSqlMap(IDatabasePlatform platform,

// @formatter:off

putSql("updateNodeChannelLastExtractTime", "update $(schemaName)$(node_channel_ctl) set last_extract_time=? where channel_id=? and node_id=?");
putSql("updateNodeChannelLastExtractTime", "update $(node_channel_ctl) set last_extract_time=? where channel_id=? and node_id=?");

putSql("selectDataEventActionsByIdSql",
" select data_event_action from $(schemaName)$(node_group_link) where "
" select data_event_action from $(node_group_link) where "
+ " source_node_group_id = ? and target_node_group_id = ? ");

putSql("groupsLinksSql", ""
+ "select source_node_group_id, target_node_group_id, data_event_action, sync_config_enabled, is_reversible, last_update_time, last_update_by, create_time from "
+ " $(schemaName)$(node_group_link) order by source_node_group_id ");
+ " $(node_group_link) order by source_node_group_id ");

putSql("updateNodeGroupSql",
" update $(schemaName)$(node_group) set description=?, last_update_time=?, last_update_by=? where "
" update $(node_group) set description=?, last_update_time=?, last_update_by=? where "
+ " node_group_id=? ");

putSql("insertNodeGroupSql",
"insert into $(schemaName)$(node_group) "
"insert into $(node_group) "
+ " (description, node_group_id, last_update_time, last_update_by, create_time) values(?,?,?,?,?) ");

putSql("updateNodeGroupLinkSql", ""
+ "update $(schemaName)$(node_group_link) set data_event_action=?, sync_config_enabled=?, is_reversible=?, last_update_time=?, last_update_by=? where "
+ "update $(node_group_link) set data_event_action=?, sync_config_enabled=?, is_reversible=?, last_update_time=?, last_update_by=? where "
+ " source_node_group_id=? and target_node_group_id=? ");

putSql("insertNodeGroupLinkSql",
"insert into $(schemaName)$(node_group_link) "
"insert into $(node_group_link) "
+ " (data_event_action, source_node_group_id, target_node_group_id, sync_config_enabled, is_reversible, last_update_time, last_update_by, create_time) values(?,?,?,?,?,?,?,?)");

putSql("selectNodeGroupsSql", ""
+ "select node_group_id, description, last_update_time, last_update_by, create_time from $(schemaName)$(node_group) order by node_group_id ");
+ "select node_group_id, description, last_update_time, last_update_by, create_time from $(node_group) order by node_group_id ");

putSql("groupsLinksForSql",
"select source_node_group_id, target_node_group_id, data_event_action, sync_config_enabled, last_update_time, last_update_by, create_time from "
+ " $(schemaName)$(node_group_link) where source_node_group_id = ? ");
+ " $(node_group_link) where source_node_group_id = ? ");

putSql("countGroupLinksForSql","select count(*) from $(schemaName)$(node_group_link) where source_node_group_id = ? and target_node_group_id = ?");
putSql("countGroupLinksForSql","select count(*) from $(node_group_link) where source_node_group_id = ? and target_node_group_id = ?");

putSql("isChannelInUseSql", "select count(*) from $(schemaName)$(trigger) where channel_id = ? ");
putSql("isChannelInUseSql", "select count(*) from $(trigger) where channel_id = ? ");

putSql("selectChannelsSql",
"select c.channel_id, c.processing_order, c.max_batch_size, c.enabled, " +
Expand All @@ -76,7 +76,7 @@ public ConfigurationServiceSqlMap(IDatabasePlatform platform,
" c.batch_algorithm, c.extract_period_millis, c.data_loader_type, " +
" c.last_update_time, c.last_update_by, c.create_time, c.reload_flag, c.file_sync_flag, " +
" c.queue, c.max_network_kbps, c.data_event_action " +
" from $(schemaName)$(channel) c order by c.processing_order asc, c.channel_id ");
" from $(channel) c order by c.processing_order asc, c.channel_id ");

putSql("selectNodeChannelsSql",
"select c.channel_id, nc.node_id, nc.ignore_enabled, nc.suspend_enabled, c.processing_order, "
Expand All @@ -85,60 +85,60 @@ public ConfigurationServiceSqlMap(IDatabasePlatform platform,
+ " nc.last_extract_time, c.extract_period_millis, c.data_loader_type, "
+ " last_update_time, last_update_by, create_time, c.reload_flag, c.file_sync_flag, c.queue, "
+ " c.max_network_kbps, c.data_event_action "
+ " from $(schemaName)$(channel) c left outer join "
+ " $(schemaName)$(node_channel_ctl) nc on c.channel_id = nc.channel_id and nc.node_id = ? "
+ " from $(channel) c left outer join "
+ " $(node_channel_ctl) nc on c.channel_id = nc.channel_id and nc.node_id = ? "
+ " order by c.processing_order asc, c.channel_id ");

putSql("selectNodeChannelControlLastExtractTimeSql", ""
+ "select channel_id, last_extract_time "
+ " from $(schemaName)$(node_channel_ctl) where node_id = ? "
+ " from $(node_channel_ctl) where node_id = ? "
+ " order by channel_id ");

putSql("insertChannelSql",
"insert into $(schemaName)$(channel) (channel_id, processing_order, max_batch_size, "
"insert into $(channel) (channel_id, processing_order, max_batch_size, "
+ " max_batch_to_send, max_data_to_route, use_old_data_to_route, use_row_data_to_route, "
+ " use_pk_data_to_route, contains_big_lob, enabled, batch_algorithm, description, "
+ " extract_period_millis, data_loader_type, last_update_time, last_update_by, "
+ " create_time, reload_flag, file_sync_flag, queue, max_network_kbps, data_event_action) "
+ " values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, null, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");

putSql("updateChannelSql",
"update $(schemaName)$(channel) set processing_order=?, max_batch_size=?, "
"update $(channel) set processing_order=?, max_batch_size=?, "
+ " max_batch_to_send=?, max_data_to_route=?, use_old_data_to_route=?, use_row_data_to_route=?, "
+ " use_pk_data_to_route=?, contains_big_lob=?, enabled=?, batch_algorithm=?, extract_period_millis=?, "
+ " data_loader_type=?, last_update_time=?, last_update_by=?, reload_flag=?, file_sync_flag=?, queue=?, "
+ " max_network_kbps = ?, data_event_action=? "
+ " where channel_id=? ");

putSql("deleteNodeGroupLinkSql",
"delete from $(schemaName)$(node_group_link) where source_node_group_id=? and target_node_group_id=? ");
"delete from $(node_group_link) where source_node_group_id=? and target_node_group_id=? ");

putSql("deleteAllNodeGroupLinksSql", "delete from $(schemaName)$(node_group_link)");
putSql("deleteAllNodeGroupLinksSql", "delete from $(node_group_link)");

putSql("deleteNodeGroupSql", "delete from $(schemaName)$(node_group) where node_group_id=? ");
putSql("deleteNodeGroupSql", "delete from $(node_group) where node_group_id=? ");

putSql("deleteChannelSql", "delete from $(schemaName)$(channel) where channel_id=? ");
putSql("deleteChannelSql", "delete from $(channel) where channel_id=? ");

putSql("deleteNodeChannelSql", "delete from $(schemaName)$(node_channel_ctl) where channel_id=? ");
putSql("deleteNodeChannelSql", "delete from $(node_channel_ctl) where channel_id=? ");

putSql("selectNodeGroupChannelWindowSql",
"select node_group_id, channel_id, start_time, end_time, enabled "
+ " from $(schemaName)$(node_group_channel_wnd) where node_group_id=? and channel_id=? ");
+ " from $(node_group_channel_wnd) where node_group_id=? and channel_id=? ");

putSql("insertNodeChannelControlSql", ""
+ "insert into $(schemaName)$(node_channel_ctl) (node_id, channel_id, "
+ "insert into $(node_channel_ctl) (node_id, channel_id, "
+ " suspend_enabled, ignore_enabled,last_extract_time) values (?, ?, ?, ?, ?) ");

putSql("updateNodeChannelControlSql",
"update $(schemaName)$(node_channel_ctl) set "
"update $(node_channel_ctl) set "
+ " suspend_enabled=?, ignore_enabled=?, last_extract_time=? where node_id=? and channel_id=? ");

putSql("getRegistrationRedirectSql",
"select registrant_external_id, registration_node_id from $(schemaName)$(registration_redirect)");
"select registrant_external_id, registration_node_id from $(registration_redirect)");

putSql("selectMaxChannelLastUpdateTime" ,"select max(last_update_time) from $(schemaName)$(channel) where last_update_time is not null" );
putSql("selectMaxNodeGroupLastUpdateTime" ,"select max(last_update_time) from $(schemaName)$(node_group) where last_update_time is not null" );
putSql("selectMaxNodeGroupLinkLastUpdateTime" ,"select max(last_update_time) from $(schemaName)$(node_group_link) where last_update_time is not null" );
putSql("selectMaxChannelLastUpdateTime" ,"select max(last_update_time) from $(channel) where last_update_time is not null" );
putSql("selectMaxNodeGroupLastUpdateTime" ,"select max(last_update_time) from $(node_group) where last_update_time is not null" );
putSql("selectMaxNodeGroupLinkLastUpdateTime" ,"select max(last_update_time) from $(node_group_link) where last_update_time is not null" );

}

Expand Down

0 comments on commit ea6ef8f

Please sign in to comment.