Class: Arango::Replication

Inherits:
Object
  • Object
show all
Includes:
Helper::Satisfaction
Defined in:
lib/arango/replication.rb

Overview

Arango Replication

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper::Satisfaction

#satisfy_category?, #satisfy_class?, #satisfy_class_or_string?, #satisfy_module?, #satisfy_module_or_nil?, #satisfy_module_or_string?, #warning_deprecated

Constructor Details

#initialize(master:, slave:, adaptive_polling: nil, auto_resync: nil, auto_resync_retries: nil, chunk_size: nil, connect_timeout: nil, connection_retry_wait_time: nil, idle_max_wait_time: nil, idle_min_wait_time: nil, include_system: true, incremental: nil, initial_sync_max_wait_time: nil, max_connect_retries: nil, request_timeout: nil, require_from_present: nil, restrict_collections: nil, restrict_type: nil, verbose: nil) ⇒ Replication

Returns a new instance of Replication.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/arango/replication.rb', line 8

def initialize(master:, slave:, adaptive_polling: nil, auto_resync: nil, auto_resync_retries: nil, chunk_size: nil, connect_timeout: nil,
               connection_retry_wait_time: nil, idle_max_wait_time: nil, idle_min_wait_time: nil, include_system: true, incremental: nil,
               initial_sync_max_wait_time: nil, max_connect_retries: nil, request_timeout: nil, require_from_present: nil,
               restrict_collections: nil, restrict_type: nil, verbose: nil)
  @adaptive_polling = adaptive_polling
  @auto_resync = auto_resync
  @auto_resync_retries = auto_resync_retries
  @chunk_size = chunk_size
  @connect_timeout = connect_timeout
  @connection_retry_wait_time = connection_retry_wait_time
  @idle_max_wait_time = idle_max_wait_time
  @idle_min_wait_time = idle_min_wait_time
  @include_system = include_system
  @incremental = incremental
  @initial_sync_max_wait_time = initial_sync_max_wait_time,
  @max_connect_retries = max_connect_retries
  @request_timeout = request_timeout
  @require_from_present = require_from_present
  @verbose = verbose
  assign_master(master)
  assign_restrict_collections(restrict_collections)
  assign_restrict_type(restrict_type)
  assign_slave(slave)
end

Instance Attribute Details

#adaptive_pollingObject

Returns the value of attribute adaptive_polling.



33
34
35
# File 'lib/arango/replication.rb', line 33

def adaptive_polling
  @adaptive_polling
end

#auto_resyncObject

Returns the value of attribute auto_resync.



33
34
35
# File 'lib/arango/replication.rb', line 33

def auto_resync
  @auto_resync
end

#auto_resync_retriesObject

Returns the value of attribute auto_resync_retries.



33
34
35
# File 'lib/arango/replication.rb', line 33

def auto_resync_retries
  @auto_resync_retries
end

#chunk_sizeObject

Returns the value of attribute chunk_size.



33
34
35
# File 'lib/arango/replication.rb', line 33

def chunk_size
  @chunk_size
end

#connect_timeoutObject

Returns the value of attribute connect_timeout.



33
34
35
# File 'lib/arango/replication.rb', line 33

def connect_timeout
  @connect_timeout
end

#connection_retry_wait_timeObject

Returns the value of attribute connection_retry_wait_time.



33
34
35
# File 'lib/arango/replication.rb', line 33

def connection_retry_wait_time
  @connection_retry_wait_time
end

#endpointObject

Returns the value of attribute endpoint.



33
34
35
# File 'lib/arango/replication.rb', line 33

def endpoint
  @endpoint
end

#idle_max_wait_timeObject

Returns the value of attribute idle_max_wait_time.



33
34
35
# File 'lib/arango/replication.rb', line 33

def idle_max_wait_time
  @idle_max_wait_time
end

#idle_min_wait_timeObject

Returns the value of attribute idle_min_wait_time.



33
34
35
# File 'lib/arango/replication.rb', line 33

def idle_min_wait_time
  @idle_min_wait_time
end

#include_systemObject

Returns the value of attribute include_system.



33
34
35
# File 'lib/arango/replication.rb', line 33

def include_system
  @include_system
end

#incrementalObject

Returns the value of attribute incremental.



33
34
35
# File 'lib/arango/replication.rb', line 33

def incremental
  @incremental
end

#initial_sync_max_wait_timeObject

Returns the value of attribute initial_sync_max_wait_time.



33
34
35
# File 'lib/arango/replication.rb', line 33

def initial_sync_max_wait_time
  @initial_sync_max_wait_time
end

#masterObject

Returns the value of attribute master.



36
37
38
# File 'lib/arango/replication.rb', line 36

def master
  @master
end

#max_connect_retriesObject

Returns the value of attribute max_connect_retries.



33
34
35
# File 'lib/arango/replication.rb', line 33

def max_connect_retries
  @max_connect_retries
end

#passwordObject

Returns the value of attribute password.



33
34
35
# File 'lib/arango/replication.rb', line 33

def password
  @password
end

#request_timeoutObject

Returns the value of attribute request_timeout.



33
34
35
# File 'lib/arango/replication.rb', line 33

def request_timeout
  @request_timeout
end

#require_from_presentObject

Returns the value of attribute require_from_present.



33
34
35
# File 'lib/arango/replication.rb', line 33

def require_from_present
  @require_from_present
end

#restrict_collectionsObject

Returns the value of attribute restrict_collections.



36
37
38
# File 'lib/arango/replication.rb', line 36

def restrict_collections
  @restrict_collections
end

#restrict_typeObject

Returns the value of attribute restrict_type.



36
37
38
# File 'lib/arango/replication.rb', line 36

def restrict_type
  @restrict_type
end

#slaveObject

Returns the value of attribute slave.



36
37
38
# File 'lib/arango/replication.rb', line 36

def slave
  @slave
end

#usernameObject

Returns the value of attribute username.



33
34
35
# File 'lib/arango/replication.rb', line 33

def username
  @username
end

#verboseObject

Returns the value of attribute verbose.



33
34
35
# File 'lib/arango/replication.rb', line 33

def verbose
  @verbose
end

Instance Method Details

#configurationObject



168
169
170
# File 'lib/arango/replication.rb', line 168

def configuration
  @slave.request("GET", "_api/replication/applier-config")
end

#enslaveObject

ENSLAVING



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/arango/replication.rb', line 128

def enslave
  body = {
    username: @master_server.username,
    password: @master_server.password,
    database: @database.name,
    endpoint: @server.endpoint,
    adaptivePolling:   @adaptive_polling,
    autoResync:        @auto_resync,
    autoResyncRetries: @auto_resync_retries,
    chunkSize:         @chunk_size,
    connectionRetryWaitTime: @connection_retry_wait_time,
    connectTimeout:    @connect_timeout,
    idleMaxWaitTime:   @idle_max_wait_time,
    idleMinWaitTime:   @idle_min_wait_time,
    includeSystem:     @include_system,
    initialSyncMaxWaitTime: @initial_sync_max_wait_time,
    maxConnectRetries: @max_connect_retries,
    requestTimeout:    @request_timeout,
    requireFromPresent: @require_from_present,
    restrictCollections: @restrict_collections,
    restrictType:      @restrict_type,
    verbose:           @verbose
  }
  @slave.request("PUT", "_api/replication/make-slave", body: body)
end

#loggerObject

LOGGER



202
203
204
# File 'lib/arango/replication.rb', line 202

def logger
  @slave.request("GET", "_api/replication/logger-state")
end

#logger_first_tickObject



216
217
218
# File 'lib/arango/replication.rb', line 216

def logger_first_tick
  @slave.request("GET", "_api/replication/logger-first-tick", key: :firstTick)
end

#logger_follow(from: nil, to: nil, chunk_size: nil, include_system: nil) ⇒ Object



206
207
208
209
210
211
212
213
214
# File 'lib/arango/replication.rb', line 206

def logger_follow(from: nil, to: nil, chunk_size: nil, include_system: nil)
  query = {
    from: from,
    to:   to,
    chunkSize:     chunk_size,
    includeSystem: include_system
  }
  @slave.request("GET", "_api/replication/logger-follow", query: query)
end

#logger_range_tickObject



220
221
222
# File 'lib/arango/replication.rb', line 220

def logger_range_tick
  @slave.request("GET", "_api/replication/logger-tick-ranges")
end

#modifyObject Also known as: modify_replication



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/arango/replication.rb', line 172

def modify
  body = {
    username: @master_server.username,
    password: @master_server.password,
    database: @master.name,
    endpoint: @master_server.endpoint,
    adaptivePolling:  @adaptive_polling,
    autoResync: @auto_resync,
    autoResyncRetries: @auto_resync_retries,
    autoStart:  @auto_start, # TODO
    chunkSize:  @chunk_size,
    connectionRetryWaitTime: @connection_retry_wait_time,
    connectTimeout:  @connect_timeout,
    idleMaxWaitTime: @idle_max_wait_time,
    idleMinWaitTime: @idle_min_wait_time,
    includeSystem:   @include_system,
    initialSyncMaxWaitTime: @initial_sync_max_wait_time,
    maxConnectRetries: @max_connect_retries,
    requestTimeout:  @request_timeout,
    requireFromPresent: @require_from_present,
    restrictCollections: @restrict_collections,
    restrictType:    @restrict_type,
    verbose:  @verbose
  }
  @slave.request("PUT", "_api/replication/applier-config", body: body)
end

#server_idObject

SERVER-ID



226
227
228
# File 'lib/arango/replication.rb', line 226

def server_id
  @slave.request("GET", "_api/replication/server-id", key: :serverId)
end

#start(from: nil) ⇒ Object

REPLICATION



156
157
158
# File 'lib/arango/replication.rb', line 156

def start(from: nil)
  @slave.request("PUT", "_api/replication/applier-start", query: {from: from})
end

#stateObject



164
165
166
# File 'lib/arango/replication.rb', line 164

def state
  @slave.request("GET", "_api/replication/applier-state")
end

#stopObject



160
161
162
# File 'lib/arango/replication.rb', line 160

def stop
  @slave.request("PUT", "_api/replication/applier-stop")
end

#syncObject

SYNCRONISATION



111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/arango/replication.rb', line 111

def sync
  body = {
    username: @master_server.username,
    password: @master_server.password,
    database: @master.name,
    endpoint: @master_server.endpoint,
    includeSystem: @include_system,
    incremental:   @incremental,
    initialSyncMaxWaitTime: @initial_sync_max_wait_time,
    restrictCollections:    @restrict_collections,
    restrictType:  @restrict_type
  }
  @slave.request("PUT", "_api/replication/sync", body: body)
end

#to_hObject



74
75
76
77
78
79
80
81
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
# File 'lib/arango/replication.rb', line 74

def to_h
  master
  {
    master: {
      database: @master.name,
      username: @master_server.username,
      endpoint: @master_server.endpoint
    },
    slave: {
      database: @slave.name,
      username: @slave_server.username,
      endpoint: @slave_server.endpoint
    },
    options: {
      adaptivePolling: @adaptive_polling,
      autoResync: @auto_resync,
      autoResyncRetries: @auto_resync_retries,
      chunkSize: @chunk_size,
      connectionRetryWaitTime: @connection_retry_wait_time,
      connectTimeout: @connect_timeout,
      idleMaxWaitTime: @idle_max_wait_time,
      idleMinWaitTime: @idle_min_wait_time,
      includeSystem: @include_system,
      incremental: @incremental,
      initialSyncMaxWaitTime: @initial_sync_max_wait_time,
      maxConnectRetries: @max_connect_retries,
      requestTimeout: @request_timeout,
      requireFromPresent: @require_from_present,
      restrictCollections: @restrict_collections,
      restrictType: @restrict_type,
      verbose: @verbose
    }.delete_if{|k,v| v.nil?}
  }
end