Module: Arango::Server::Administration

Included in:
Arango::Server
Defined in:
lib/arango/server/administration.rb

Overview

Arango Server Administration

Instance Method Summary collapse

Instance Method Details

#agent?Boolean

Check if server role is AGENT.

Returns:

  • (Boolean)


155
156
157
# File 'lib/arango/server/administration.rb', line 155

def agent?
  role == 'AGENT'
end

#available?Boolean

Check availability of the server.

Returns:

  • (Boolean)


10
11
12
# File 'lib/arango/server/administration.rb', line 10

def available?
  200 == Arango::Requests::Administration::Availability.execute(server: self).response_code
end

#cluster_endpointsArray<String>

Returns information about all coordinator endpoints (cluster only).

Returns:

  • (Array<String>)


16
17
18
19
20
21
# File 'lib/arango/server/administration.rb', line 16

def cluster_endpoints
  if in_cluster?
    result = Arango::Requests::Administration::ClusterEndpoints.execute(server: self)
    result.endpoints.map { |e| e[:endpoint] }
  end
end

#coordinator?Boolean

Check if server role is COORDINATOR.

Returns:

  • (Boolean)


161
162
163
# File 'lib/arango/server/administration.rb', line 161

def coordinator?
  role == 'COORDINATOR'
end

#detailed_versionArango::Result

Return server version details. The response will contain a details attribute with additional information about included components and their versions. The attribute names and internals of the details object may vary depending on platform and ArangoDB version.

Returns:



229
230
231
# File 'lib/arango/server/administration.rb', line 229

def detailed_version
  Arango::Requests::Administration::Version.execute(server: self, params: {details: true})
end

#echo(request_hash) ⇒ Hash

Send back what was sent in, headers, post body etc.

Parameters:

  • request_hash (Hash)

    The request body.

Returns:

  • (Hash)


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

def echo(request_hash)
  Arango::Requests::Administration::Echo.execute(server: self, body: request_hash)
end

#endpointsArray<String>

Returns information about all server endpoints.

Returns:

  • (Array<String>)


25
26
27
28
# File 'lib/arango/server/administration.rb', line 25

def endpoints
  result = Arango::Requests::Administration::Endpoints.execute(server: self)
  result.map { |e| e[:endpoint] }
end

#engineArango::Result

Return server database engine information

Returns:



39
40
41
# File 'lib/arango/server/administration.rb', line 39

def engine
  @engine ||= Arango::Requests::Administration::Engine.execute(server: self)
end

#enterprise?Boolean

Check if the server has the enterprise license.

Returns:

  • (Boolean)


215
216
217
# File 'lib/arango/server/administration.rb', line 215

def enterprise?
  @enterprise ||= (status.license == 'enterprise')
end

#flush_wal(wait_for_sync: false, wait_for_collector: false) ⇒ Object

Flushes the write-ahead log. By flushing the currently active write-ahead logfile, the data in it can be transferred to collection journals and datafiles. This is useful to ensure that all data for a collection is present in the collection journals and datafiles, for example, when dumping the data of a collection.

Parameters:

  • wait_for_sync (Boolean) (defaults to: false)

    Whether or not the operation should block until the not-yet synchronized data in the write-ahead log was synchronized to disk.

  • wait_for_collector (Boolean) (defaults to: false)

    Whether or not the operation should block until the data in the flushed log has been collected by the write-ahead log garbage collector. Note that setting this option to true might block for a long time if there are long-running transactions and the write-ahead log garbage collector cannot finish garbage collection.



257
258
259
260
261
262
263
# File 'lib/arango/server/administration.rb', line 257

def flush_wal(wait_for_sync: false, wait_for_collector: false)
  params = {
    waitForSync: wait_for_sync,
    waitForCollector: wait_for_collector
  }
  200 == Arango::Requests::Wal::Flush.execute(server: self, params: params).response_code
end

#in_cluster?Boolean

Check if server is part of a cluster.

Returns:

  • (Boolean)


185
186
187
# File 'lib/arango/server/administration.rb', line 185

def in_cluster?
  coordinator? || primary? || agent? || secondary?
end

#log(upto: nil, level: nil, start: nil, size: nil, offset: nil, search: nil, sort: nil) ⇒ Arango::Result

Read global logs from the server. Log levels for the upto and level params:

  • fatal or 0

  • error or 1

  • warning or 2

  • info or 3

  • debug or 4

The parameters upto and level are mutually exclusive. All params are optional.

Parameters:

  • upto (Symbol, String, Integer) (defaults to: nil)

    Returns all log entries up to log level upto. The default value is info.

  • level (Symbol, String, Integer) (defaults to: nil)

    Returns all log entries of log level level.

  • start (defaults to: nil)

    Returns all log entries such that their log entry identifier (lid value) is greater or equal to start.

  • size (Integer) (defaults to: nil)

    Restricts the result to at most size log entries.

  • offset (Integer) (defaults to: nil)

    Starts to return log entries skipping the first offset log entries. offset and size can be used for pagination.

  • search (String) (defaults to: nil)

    Only return the log entries containing the text specified in search.

  • sort (Symbol, String) (defaults to: nil)

    Sort the log entries either ascending (if sort is :asc) or descending (if sort is :desc) according to their lid values.

Returns:



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/arango/server/administration.rb', line 72

def log(upto: nil, level: nil, start: nil, size: nil, offset: nil, search: nil, sort: nil)
  sort = sort.to_s if sort
  satisfy_category?(sort, [nil, "asc", "desc"])
  query = Hash.new
  query[:start] = start if start
  query[:size] = size if size
  query[:offset] = offset if offset
  query[:search] = search if search
  query[:sort] = sort if sort
  if upto
    upto = upto.to_s
    satisfy_category?(upto, [nil, "fatal", 0, "error", 1, "warning", 2, "info", 3, "debug", 4])
    query[:upto] = upto
  elsif level
    level = level.to_s
    satisfy_category?(level, [nil, "fatal", 0, "error", 1, "warning", 2, "info", 3, "debug", 4])
    query[:level] = level
  end
  Arango::Requests::Administration::Log.execute(server: self, params: query)
end

#log_levelArango::Result

Returns the current log level settings

Returns:



95
96
97
# File 'lib/arango/server/administration.rb', line 95

def log_level
  Arango::Requests::Administration::GetLogLevel.execute(server: self)
end

#log_level=(log_level_object) ⇒ Object

Modifies the current log level settings

Parameters:

  • log_level_object (Arango::Result, Hash)

    Must contain all keys as obtained by log_level. Best is to get the object by calling log_level, modifying it, and passing it here.

Returns:

  • Arango::Result



103
104
105
106
107
108
109
110
# File 'lib/arango/server/administration.rb', line 103

def log_level=(log_level_object)
  body = if log_level_object.class == Arango::Result
           log_level_object.to_h
         else
           log_level_object
         end
  Arango::Requests::Administration::SetLogLevel.execute(server: self, body: body)
end

#mmfiles?Boolean

Return true if the server uses the mmfiles engine.

Returns:

  • (Boolean)


45
46
47
# File 'lib/arango/server/administration.rb', line 45

def mmfiles?
  'mmfiles' == engine.name
end

#modeSymbol

Return mode information about a server.

Returns:

  • (Symbol)

    one of :default or :readonly



114
115
116
# File 'lib/arango/server/administration.rb', line 114

def mode
  Arango::Requests::Administration::GetMode.execute(server: self).mode.to_sym
end

#mode=(mode) ⇒ Symbol

Set server mode.

Parameters:

  • mode (String, Symbol)

    one of :default or :readonly

Returns:

  • (Symbol)

    one of :default or :readonly



121
122
123
124
125
# File 'lib/arango/server/administration.rb', line 121

def mode=(mode)
  satisfy_category?(mode, ["default", "readonly", :default, :readonly])
  body = { mode: mode.to_s }
  Arango::Requests::Administration::SetMode.execute(server: self, body: body).mode.to_sym
end

#primary?Boolean

Check if server role is PRIMARY.

Returns:

  • (Boolean)


167
168
169
# File 'lib/arango/server/administration.rb', line 167

def primary?
  role == 'PRIMARY'
end

#read_only?Boolean

Check if server is read only.

Returns:

  • (Boolean)


129
130
131
# File 'lib/arango/server/administration.rb', line 129

def read_only?
  :readonly == mode
end

#reload_routingObject

Reloads the routing information from the collection routing.

Returns:

  • true



135
136
137
138
# File 'lib/arango/server/administration.rb', line 135

def reload_routing
  Arango::Requests::Administration::ReloadRouting.execute(server: self)
  true
end

#rocksdb?Boolean

Return true if the server uses the rocksdb engine.

Returns:

  • (Boolean)


51
52
53
# File 'lib/arango/server/administration.rb', line 51

def rocksdb?
  'rocksdb' == engine.name
end

#roleString

Returns the role of a server in a cluster. SINGLE: the server is a standalone server without clustering COORDINATOR: the server is a Coordinator in a cluster PRIMARY: the server is a DBServer in a cluster SECONDARY: this role is not used anymore AGENT: the server is an Agency node in a cluster UNDEFINED: in a cluster, UNDEFINED is returned if the server role cannot be determined.

Returns:

  • (String)


149
150
151
# File 'lib/arango/server/administration.rb', line 149

def role
  @role ||= Arango::Requests::Administration::Role.execute(server: self).role
end

#secondary?Boolean

Check if server role is SECONDARY.

Returns:

  • (Boolean)


173
174
175
# File 'lib/arango/server/administration.rb', line 173

def secondary?
  role == 'SECONDARY'
end

#server_idBoolean

Returns the id of a server in a cluster.

Returns:

  • (Boolean)


191
192
193
# File 'lib/arango/server/administration.rb', line 191

def server_id
  request(get: "_admin/server/id").serverId if in_cluster?
end

#shutdownBoolean

Shutdown the server.

Returns:

  • (Boolean)

    True if request was successful.



299
300
301
# File 'lib/arango/server/administration.rb', line 299

def shutdown
  200 == request(delete: "_admin/shutdown").response_code
end

#single?Boolean

Check if server role is SINGLE.

Returns:

  • (Boolean)


179
180
181
# File 'lib/arango/server/administration.rb', line 179

def single?
  role == 'SINGLE'
end

#statisticsArango::Result

Returns the statistics information.

Returns:



197
198
199
# File 'lib/arango/server/administration.rb', line 197

def statistics
  Arango::Requests::Administration::Statistics.execute(server: self)
end

#statistics_descriptionArango::Result

Returns a description of the statistics returned by /_admin/statistics.

Returns:



203
204
205
# File 'lib/arango/server/administration.rb', line 203

def statistics_description
  Arango::Requests::Administration::StatisticsDescription.execute(server: self)
end

#statusArango::Result

Returns status information about the server.

Returns:



209
210
211
# File 'lib/arango/server/administration.rb', line 209

def status
  Arango::Requests::Administration::Status.execute(server: self)
end

#target_versionString

Returns the database version that this server requires.

Returns:

  • (String)


242
243
244
# File 'lib/arango/server/administration.rb', line 242

def target_version
  Arango::Requests::Administration::TargetVersion.execute(server: self).version
end

#timeFloat

The servers current system time as a Unix timestamp with microsecond precision of the server

Returns:

  • (Float)


221
222
223
# File 'lib/arango/server/administration.rb', line 221

def time
  Arango::Requests::Administration::Time.execute(server: self).time
end

#versionString

The server version string. The string has the format “major.minor.sub”. major and minor will be numeric, and sub may contain a number or a textual version.

Returns:

  • (String)


236
237
238
# File 'lib/arango/server/administration.rb', line 236

def version
  Arango::Requests::Administration::Version.execute(server: self).version
end

#wal_propertiesObject

Retrieves the configuration of the write-ahead log. Properties:

  • allow_oversize_entries: whether or not operations that are bigger than a single logfile can be executed and stored

  • log_file_size: the size of each write-ahead logfile

  • historic_logfiles: the maximum number of historic logfiles to keep

  • reserve_logfiles: the maximum number of reserve logfiles that ArangoDB allocates in the background

  • throttle_wait: the maximum wait time that operations will wait before they get aborted if case of write-throttling (in milliseconds)

  • throttle_when_pending: the number of unprocessed garbage-collection operations that, when reached, will activate write-throttling.

    A value of 0 means that write-throttling will not be triggered.
    

return [Arango::Result]



274
275
276
277
278
# File 'lib/arango/server/administration.rb', line 274

def wal_properties
  result = Arango::Requests::Wal::GetProperties.execute(server: self)
  raise "WAL properties not available." if result.response_code >= 500
  result
end

#wal_properties=(properties_object) ⇒ Object

Configures the behavior of the write-ahead log.

Parameters:

  • properties_object (Arango::Result)

    Obtain the object with wal_properties, modify and pass here.



283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/arango/server/administration.rb', line 283

def wal_properties=(properties_object)
  body = {
    allowOversizeEntries: properties_object.allow_oversize_entries,
    logfileSize: properties_object.logfile_size,
    historicLogfiles: properties_object.historic_logfiles,
    reserveLogfiles: properties_object.reserve_logfiles,
    throttleWait: properties_object.throttle_wait,
    throttleWhenPending: properties_object.throttle_when_pending
  }
  result = request(put: "_admin/wal/properties", body: body)
  raise "WAL properties not available." if result.response_code >= 500
  result
end