flydata 0.7.16 → 0.7.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/flydata.gemspec +0 -0
- data/lib/flydata/command/sync.rb +52 -26
- data/lib/flydata/source/sync_generate_table_ddl.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 340f31b8701b211b25628d5690237565ff5e46c6
|
4
|
+
data.tar.gz: 25bbb20fa4a67ca4f25f20917a350e649a224b80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae89812c8d23ad80ec1777ec1a6c39764808d7279ff54db865b7bc1cd090045cef87f426af834aaf50d147f1d7c2d9eef1a16150b6844d79701313f84c7b3a17
|
7
|
+
data.tar.gz: 4f6c6c97c6c04ebee65780bf31930fc58a6316cf7830bcac5defd63bc8a9db68d3062577d142e09cd1d86f9cc66b7c4bd207d6b5094ae6c4c89f48b983c88d57
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.17
|
data/flydata.gemspec
CHANGED
Binary file
|
data/lib/flydata/command/sync.rb
CHANGED
@@ -279,13 +279,15 @@ EOS
|
|
279
279
|
def generate_table_ddl(*tables)
|
280
280
|
# Compatibility check
|
281
281
|
de = data_entry
|
282
|
-
context = source.sync_generate_table_ddl(flydata.data_port.get
|
282
|
+
context = source.sync_generate_table_ddl(flydata.data_port.get)
|
283
283
|
context.run_compatibility_check
|
284
284
|
|
285
285
|
# Set instance variables
|
286
286
|
set_current_tables(tables, include_all_tables: true)
|
287
287
|
|
288
|
-
|
288
|
+
unless generate_and_print_table_ddl(context, de)
|
289
|
+
raise "There are no valid unsynced tables, if you want to just get ddl for all tables, please run \`flydata sync:generate_table_ddl --all-tables\`"
|
290
|
+
end
|
289
291
|
end
|
290
292
|
run_exclusive :generate_table_ddl
|
291
293
|
|
@@ -355,7 +357,7 @@ EOS
|
|
355
357
|
# Command: flydata sync:compat_check
|
356
358
|
# - Entry method
|
357
359
|
def compat_check
|
358
|
-
context = source.sync_generate_table_ddl(flydata.data_port.get
|
360
|
+
context = source.sync_generate_table_ddl(flydata.data_port.get)
|
359
361
|
context.run_compatibility_check
|
360
362
|
end
|
361
363
|
run_exclusive :compat_check
|
@@ -561,7 +563,12 @@ EOS
|
|
561
563
|
|
562
564
|
# Delete query queue items for the tables
|
563
565
|
log_info_stdout "Deleting data stuck in the server buffer..."
|
564
|
-
|
566
|
+
unless broken_tables.empty?
|
567
|
+
cleanup_sync_server(de, broken_tables, queue_only: true)
|
568
|
+
# refetch table_status to get the latest seq and source_pos info. The values
|
569
|
+
# may have been updated since the last fetch called from #_check
|
570
|
+
table_status_hash = get_table_status(broken_tables, context)
|
571
|
+
end
|
565
572
|
|
566
573
|
# Save the positions (source_pos and seq)
|
567
574
|
log_info_stdout "Fixing table positions..."
|
@@ -893,15 +900,7 @@ EOM
|
|
893
900
|
end
|
894
901
|
|
895
902
|
# Prepare forwarder
|
896
|
-
|
897
|
-
server_port = dp['server_port']
|
898
|
-
data_servers = source.sync.data_servers
|
899
|
-
servers = data_servers ? data_servers.split(',') :
|
900
|
-
dp["servers#{env_suffix}"].collect{|s| "#{s}:#{server_port}"}
|
901
|
-
forwarder_type = source.sync.forwarder ||
|
902
|
-
(dp['ssl_enabled'] ? 'sslforwarder' : 'tcpforwarder')
|
903
|
-
forwarder = Flydata::Output::ForwarderFactory.create(forwarder_type, de_tag_name, servers)
|
904
|
-
|
903
|
+
forwarder = build_forwarder(dp, de)
|
905
904
|
log_info_stdout("Sending data to FlyData Server...")
|
906
905
|
|
907
906
|
# initialize stats
|
@@ -1220,32 +1219,42 @@ EOM
|
|
1220
1219
|
log_info_stdout("Done.")
|
1221
1220
|
end
|
1222
1221
|
|
1223
|
-
# Generate table ddl
|
1222
|
+
# Generate and print table ddl
|
1223
|
+
def generate_and_print_table_ddl(context, de)
|
1224
|
+
generate_flydata_tabledefs(context, de) do |flydata_tabledef|
|
1225
|
+
puts FlydataCore::TableDef::SyncRedshiftTableDef.from_flydata_tabledef(flydata_tabledef, flydata_tabledef[:ddl_options])
|
1226
|
+
end
|
1227
|
+
end
|
1224
1228
|
|
1225
|
-
def
|
1226
|
-
error_list = []
|
1229
|
+
def generate_flydata_tabledefs(context, de)
|
1227
1230
|
schema_name = (de['schema_name'] || nil)
|
1228
|
-
|
1229
1231
|
tables = opts.all_tables? ? @full_tables : (@input_tables.empty? ? @unsynced_tables : @input_tables)
|
1230
1232
|
|
1231
|
-
|
1232
|
-
|
1233
|
-
if tables.empty?
|
1234
|
-
raise "`tables` (or `tables_append_only`) is neither defined in the data entry nor the local config file"
|
1235
|
-
end
|
1233
|
+
# Target table checks
|
1234
|
+
return nil if tables.empty?
|
1236
1235
|
|
1236
|
+
# Create flydata table definitions with error list
|
1237
1237
|
flydata_tabledefs, error_list, uk_as_pk_override = context.generate_flydata_tabledef(tables,
|
1238
1238
|
skip_primary_key_check: opts.skip_primary_key_check?)
|
1239
1239
|
|
1240
|
+
# Output DDL for Redshift
|
1240
1241
|
create_flydata_ctl_table = true
|
1241
1242
|
append_only = tables & @append_only_tables
|
1242
1243
|
flydata_tabledefs.each do |flydata_tabledef|
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1244
|
+
ddl_options = {
|
1245
|
+
flydata_ctl_table: create_flydata_ctl_table,
|
1246
|
+
schema_name: schema_name,
|
1247
|
+
ctl_only: opts.ctl_only?,
|
1248
|
+
skip_drop_table: opts.drop_append_only? ? false : append_only.include?(flydata_tabledef[:table_name]),
|
1249
|
+
skip_primary_key_check: opts.skip_primary_key_check? }
|
1250
|
+
flydata_tabledef[:ddl_options] = ddl_options
|
1251
|
+
if block_given?
|
1252
|
+
yield flydata_tabledef
|
1253
|
+
end
|
1246
1254
|
create_flydata_ctl_table = false
|
1247
1255
|
end
|
1248
1256
|
|
1257
|
+
# Set error info to table_validity_hash for error tables
|
1249
1258
|
table_validity_hash = Hash.new {|h,k| h[k] = {}}
|
1250
1259
|
tables_without_error = tables
|
1251
1260
|
unless error_list.empty?
|
@@ -1270,17 +1279,34 @@ The other tables are ready to sync. To start sync, run the generated script on
|
|
1270
1279
|
EOS
|
1271
1280
|
end
|
1272
1281
|
end
|
1282
|
+
|
1283
|
+
# Reset table error of tables having no error
|
1273
1284
|
tables_without_error.each {|table| table_validity_hash[table][TableAttribute::INVALID_TABLE_REASON] = nil }
|
1274
1285
|
|
1275
|
-
#
|
1286
|
+
# Update table validity and uk_as_pk info on web server
|
1276
1287
|
uk_as_pk_override.each_pair {|table, val| table_validity_hash[table][TableAttribute::UK_AS_PK_OVERRIDE] = val}
|
1277
1288
|
(tables - uk_as_pk_override.keys).each {|table| table_validity_hash[table][TableAttribute::UK_AS_PK_OVERRIDE] = nil }
|
1278
1289
|
|
1290
|
+
# Update table validity on flydata-web
|
1279
1291
|
flydata.data_entry.update_table_validity(de['id'], updated_tables: table_validity_hash) unless table_validity_hash.empty?
|
1280
1292
|
|
1293
|
+
# Create per-table generated_ddl file on postiions directory
|
1281
1294
|
sync_fm = create_sync_file_manager(de)
|
1282
1295
|
sync_fm.save_generated_ddl(tables_without_error, TableDdl::VERSION)
|
1283
1296
|
sync_fm.close
|
1297
|
+
|
1298
|
+
flydata_tabledefs
|
1299
|
+
end
|
1300
|
+
|
1301
|
+
def build_forwarder(dp, de)
|
1302
|
+
de_tag_name = de["tag_name#{env_suffix}"]
|
1303
|
+
server_port = dp['server_port']
|
1304
|
+
data_servers = source.sync.data_servers
|
1305
|
+
servers = data_servers ? data_servers.split(',') :
|
1306
|
+
dp["servers#{env_suffix}"].collect{|s| "#{s}:#{server_port}"}
|
1307
|
+
forwarder_type = source.sync.forwarder ||
|
1308
|
+
(dp['ssl_enabled'] ? 'sslforwarder' : 'tcpforwarder')
|
1309
|
+
Flydata::Output::ForwarderFactory.create(forwarder_type, de_tag_name, servers)
|
1284
1310
|
end
|
1285
1311
|
|
1286
1312
|
ALL_DONE_MESSAGE_TEMPLATE = <<-EOM
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flydata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koichi Fujikawa
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2017-01-
|
15
|
+
date: 2017-01-17 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rest-client
|