Class: TungstenScriptDatasource

Inherits:
Object
  • Object
show all
Defined in:
lib/tungsten/datasource.rb

Direct Known Subclasses

TungstenScriptMySQLDatasource

Instance Method Summary collapse

Constructor Details

#initialize(ti, service, is_direct = false) ⇒ TungstenScriptDatasource

Returns a new instance of TungstenScriptDatasource.



2
3
4
5
6
# File 'lib/tungsten/datasource.rb', line 2

def initialize(ti, service, is_direct = false)
  @ti = ti
  @service = service
  @is_direct = is_direct
end

Instance Method Details

#_stop_serverObject



37
38
39
# File 'lib/tungsten/datasource.rb', line 37

def _stop_server
  raise "Undefined function: #{self.class.name()}._stop_server"
end

#can_lock_tables?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/tungsten/datasource.rb', line 62

def can_lock_tables?
  false
end

#can_manage_service?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/tungsten/datasource.rb', line 12

def can_manage_service?
  false
end

#can_sql?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/tungsten/datasource.rb', line 78

def can_sql?
  @ti.can_sql?(@service, @is_direct)
end

#hostObject



103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/tungsten/datasource.rb', line 103

def host
  begin
    TU.log_cmd_results?(false)
    if @is_direct == true
      return @ti.setting(@ti.setting_key(REPL_SERVICES, @service, "repl_direct_datasource_host"))
    else
      return @ti.setting(@ti.setting_key(REPL_SERVICES, @service, "repl_datasource_host"))
    end
  ensure
    TU.log_cmd_results?(true)
  end
end

#is_running?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/tungsten/datasource.rb', line 16

def is_running?
  raise "Undefined function: #{self.class.name()}.is_running?"
end

#lock_tablesObject



66
67
68
# File 'lib/tungsten/datasource.rb', line 66

def lock_tables
  raise "Undefined function: #{self.class.name()}.lock_tables"
end

#passwordObject



142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/tungsten/datasource.rb', line 142

def password
  begin
    # Disable logging of command results so the password doesn't end up in a log file
    TU.log_cmd_results?(false)
    if @is_direct == true
      return @ti.setting(@ti.setting_key(REPL_SERVICES, @service, "repl_direct_datasource_password"))
    else
      return @ti.setting(@ti.setting_key(REPL_SERVICES, @service, "repl_datasource_password"))
    end
  ensure
    TU.log_cmd_results?(true)
  end
end

#portObject



116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/tungsten/datasource.rb', line 116

def port
  begin
    TU.log_cmd_results?(false)
    if @is_direct == true
      return @ti.setting(@ti.setting_key(REPL_SERVICES, @service, "repl_direct_datasource_port"))
    else
      return @ti.setting(@ti.setting_key(REPL_SERVICES, @service, "repl_datasource_port"))
    end
  ensure
    TU.log_cmd_results?(true)
  end
end

#snapshot_pathsObject



74
75
76
# File 'lib/tungsten/datasource.rb', line 74

def snapshot_paths
  raise "Undefined function: #{self.class.name()}.snapshot_paths"
end

#sql_result(sql) ⇒ Object



86
87
88
# File 'lib/tungsten/datasource.rb', line 86

def sql_result(sql)
  @ti.sql_result(@service, sql, @is_direct)
end

#sql_results(sql) ⇒ Object



82
83
84
# File 'lib/tungsten/datasource.rb', line 82

def sql_results(sql)
  @ti.sql_results(@service, sql, @is_direct)
end

#startObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/tungsten/datasource.rb', line 41

def start
  if @is_direct == true
    raise "Unable to start the direct datasource for #{@service} replication service"
  end
  
  unless can_manage_service?()
    raise "Unable to start the datasource for #{@service} replication service"
  end
  
  if is_running?() == true
    return
  end
  
  TU.notice("Start the #{self.title()} service")
  _start_server()
end

#stopObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/tungsten/datasource.rb', line 20

def stop
  if @is_direct == true
    raise "Unable to stop the direct datasource for #{@service} replication service"
  end
  
  unless can_manage_service?()
    raise "Unable to stop the datasource for #{@service} replication service"
  end
  
  if is_running?() == false
    return
  end
  
  TU.notice("Stop the #{self.title()} service")
  _stop_server()
end

#titleObject



8
9
10
# File 'lib/tungsten/datasource.rb', line 8

def title
  raise "Undefined function: #{self.class.name()}.title"
end

#unlock_tablesObject



70
71
72
# File 'lib/tungsten/datasource.rb', line 70

def unlock_tables
  raise "Undefined function: #{self.class.name()}.unlock_tables"
end

#urlObject



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/tungsten/datasource.rb', line 90

def url
  begin
    TU.log_cmd_results?(false)
    if @is_direct == true
      return @ti.setting(@ti.setting_key(REPL_SERVICES, @service, "repl_direct_datasource_jdbcqueryurl"))
    else
      return @ti.setting(@ti.setting_key(REPL_SERVICES, @service, "repl_datasource_jdbcqueryurl"))
    end
  ensure
    TU.log_cmd_results?(true)
  end
end

#userObject



129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/tungsten/datasource.rb', line 129

def user
  begin
    TU.log_cmd_results?(false)
    if @is_direct == true
      return @ti.setting(@ti.setting_key(REPL_SERVICES, @service, "repl_direct_datasource_user"))
    else
      return @ti.setting(@ti.setting_key(REPL_SERVICES, @service, "repl_datasource_user"))
    end
  ensure
    TU.log_cmd_results?(true)
  end
end