Class: Flydata::SourceOracle::GenerateSourceDump
- Inherits:
-
Flydata::Source::GenerateSourceDump
- Object
- Flydata::Source::Component
- Flydata::Source::GenerateSourceDump
- Flydata::SourceOracle::GenerateSourceDump
- Includes:
- OracleComponent
- Defined in:
- lib/flydata/source_oracle/generate_source_dump.rb
Constant Summary collapse
- DUMP_SIZE_QUERY =
<<EOS SELECT sum(bytes) as total_size FROM (SELECT segment_name table_name, owner, bytes FROM dba_segments WHERE segment_type IN ('TABLE','TABLE PARTITION','TABLE SUBPARTITION') UNION ALL SELECT i.table_name, i.owner, s.bytes FROM dba_indexes i, dba_segments s WHERE s.segment_name = i.index_name AND s.owner = i.owner AND s.segment_type IN ('INDEX','INDEX PARTITION','INDEX SUBPARTITION') UNION ALL SELECT l.table_name, l.owner, s.bytes FROM dba_lobs l, dba_segments s WHERE s.segment_name = l.segment_name AND s.owner = l.owner AND s.segment_type IN ('LOBSEGMENT','LOB PARTITION') UNION ALL SELECT l.table_name, l.owner, s.bytes FROM dba_lobs l, dba_segments s WHERE s.segment_name = l.index_name AND s.owner = l.owner AND s.segment_type = 'LOBINDEX') WHERE owner = %{schema} and table_name in (%{tables}) EOS
Instance Attribute Summary
Attributes inherited from Flydata::Source::GenerateSourceDump
Instance Method Summary collapse
- #confirmation_items ⇒ Object
- #dump(tables, file_path = nil, &src_pos_callback) ⇒ Object
- #dump_size(tables) ⇒ Object
- #run_compatibility_check(dump_dir, backup_dir) ⇒ Object
Methods included from OracleComponent
Methods inherited from Flydata::Source::GenerateSourceDump
Methods inherited from Flydata::Source::Component
Constructor Details
This class inherits a constructor from Flydata::Source::GenerateSourceDump
Instance Method Details
#confirmation_items ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/flydata/source_oracle/generate_source_dump.rb', line 26 def confirmation_items items = { "host" => de_prefs['host'], "port" => de_prefs['port'], "username" => de_prefs['username'], "database" => de_prefs['database'], "schema" => de_prefs['schema'], } items end |
#dump(tables, file_path = nil, &src_pos_callback) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/flydata/source_oracle/generate_source_dump.rb', line 82 def dump(tables, file_path = nil, &src_pos_callback) io = nil if file_path io = File.open(file_path, "w") else raise "dump via pipe has not been implemented yet" end = Flydata::SourceOracle::TableMeta.new(de_prefs, tables) cli = FlydataCore::Oracle::OracleClient.new(de_prefs) .reload(cli) = tables.select{|t| tm = [t]; tm.nil? || tm.empty?} unless .empty? raise "Tables are not available. Check if the following table(s) exist and are visible: #{.join(",")}" end context = source.sync_generate_table_ddl(dp, nil) source_pos = get_source_pos(.current_scn, &src_pos_callback) = de_prefs.merge(table_meta: ) missing_tables = context.each_source_tabledef(tables, ) do |tabledef, error| dump_table(tabledef, source_pos, io, cli) if tabledef end nil ensure cli.close if cli io.close if io end |
#dump_size(tables) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/flydata/source_oracle/generate_source_dump.rb', line 66 def dump_size(tables) cli = FlydataCore::Oracle::OracleClient.new(de_prefs) query = DUMP_SIZE_QUERY % { schema: FlydataCore::Oracle::QueryHelper.schema_as_value(de_prefs['schema'], de_prefs['username']), tables: FlydataCore::Oracle::QueryHelper.tables_as_value(tables) } cursor = cli.query(query) cursor.fetch_hash['TOTAL_SIZE'].to_i ensure cursor.close rescue nil if cursor cli.close if cli end |
#run_compatibility_check(dump_dir, backup_dir) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/flydata/source_oracle/generate_source_dump.rb', line 17 def run_compatibility_check(dump_dir, backup_dir) %w(host username database).each do |k| if de_prefs[k].to_s.empty? raise "'#{k}' is required. Set the value in the conf file " + "-> #{Flydata::Preference::DataEntryPreference.conf_path(de)}" end end end |