Class: PuppetX::EnterpriseModules::Oracle::SqlplusDaemon

Inherits:
SqlplusCommand show all
Defined in:
lib/puppet_x/enterprisemodules/oracle/sqlplus_daemon.rb

Overview

rubocop:disable Style/Documentation

Instance Attribute Summary

Attributes inherited from SqlplusCommand

#catch_errors, #catch_extra_errors, #daemonized, #failonsqlfail, #os_user, #parse, #password, #sid, #timeout, #username

Attributes inherited from Command

#os_user, #password, #sid, #timeout, #username

Instance Method Summary collapse

Methods inherited from SqlplusCommand

#command_string, #execute

Methods included from Settings

#asm_sid?, #asm_sids, #configuration, #configuration_for, #configuration_value_for, #container_db?, #database_sid?, #database_sids, #default_asm_sid, #default_database_sid, #default_sids, included, #local_pdb?, #mgmt_sid?, #mgmt_sids, #normal_db?, #num_default_asm_sids, #num_default_database_sids, #read_from_yaml, #registered_sids, #remote_sid?, #running_asm_sids, #running_database_sids, #running_db?, #running_mgmt_sids, #running_mt_database_sids, #running_nopdb_database_sids, #running_normal_database_sids, #running_pdb?, #running_primary_database_sids, #running_sids, #settings_file, #valid_asm_sid?, #valid_database_sid, #valid_sid?

Methods included from Information

#cached_sid_value, #cluster?, #cluster_instances, #containerdb?, #database_properties, #database_version, #db_create_file_dest, #db_domain, #db_for, #diagnostic_dest, included, #local_sid_for_db, #open_pdbs, #oracle_major_version, #oracle_managed_files_enabled?, #pdb?, #primary?, #rootdb?, #seeddb?, #sid_for, #value_for_init_param

Methods inherited from Command

#command_string, #execute

Constructor Details

#initialize(options = {}) ⇒ SqlplusDaemon

rubocop:enable Style/Documentation



11
12
13
14
15
16
# File 'lib/puppet_x/enterprisemodules/oracle/sqlplus_daemon.rb', line 11

def initialize(options = {})
  super
  @catch_errors = Regexp.union(@catch_errors, /ORA-\d+:.*$/) if @failonsqlfail == :true
  @daemon = ::EasyType::Daemon.run(identity)
  start_daemon if @daemon.nil?
end

Instance Method Details

#execute_sql_command(command, output_file, timeout = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/puppet_x/enterprisemodules/oracle/sqlplus_daemon.rb', line 18

def execute_sql_command(command, output_file, timeout = nil)
  timeout ||= @timeout
  ensure_connection
  begin
    Puppet.debug "Executing daemonized sql-command #{command}"
    @daemon.execute_command template('ora_config/ora_config/daemon_execute.sql.erb', binding)
    @daemon.sync(timeout) do |line|
      raise ThreadError if /ORA-03135|ORA-03114/.match?(line)

      if line&.match?(@catch_errors)
        @daemon.sync(timeout) # Clear buffer till end string
        fail "Error in execution of SQL command: #{command}.\nFound error #{line}"
      end
    end
  rescue ThreadError
    @retries = @retries.nil? ? 1 : @retries + 1
    fail 'maximum number of retries for daemon restart exhausted.' if @retries == 3

    Puppet.debug 'Detected disconnected daemon. restarting it...'
    @daemon.kill
    start_daemon
    retry
  end
  File.read(output_file)
end