Class: JayAPI::Elasticsearch::Stats::Node::Storage

Inherits:
Object
  • Object
show all
Defined in:
lib/jay_api/elasticsearch/stats/node/storage.rb

Overview

Holds storage information related to one of the nodes in the Elasticsearch cluster.

Constant Summary collapse

TOTAL_KEY =
'total_in_bytes'
FREE_KEY =
'free_in_bytes'
AVAILABLE_KEY =
'available_in_bytes'

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Storage

Returns a new instance of Storage.

Parameters:

  • data (Hash)

    Data about the Node’s storage.



15
16
17
# File 'lib/jay_api/elasticsearch/stats/node/storage.rb', line 15

def initialize(data)
  @data = data
end

Instance Method Details

#+(other) ⇒ self

Returns A new instance of the class with the added storage of the receiver and other.

Returns:

  • (self)

    A new instance of the class with the added storage of the receiver and other.

Raises:

  • (ArgumentError)


38
39
40
41
42
43
44
45
46
# File 'lib/jay_api/elasticsearch/stats/node/storage.rb', line 38

def +(other)
  raise ArgumentError, "Cannot add #{self.class} and #{other.class} together" unless other.is_a?(self.class)

  self.class.new(
    TOTAL_KEY => total + other.total,
    FREE_KEY => free + other.free,
    AVAILABLE_KEY => available + other.available
  )
end

#availableInteger

Returns The total number of bytes that are available on the node. In general this is equal to #free, but not always.

Returns:

  • (Integer)

    The total number of bytes that are available on the node. In general this is equal to #free, but not always.



32
33
34
# File 'lib/jay_api/elasticsearch/stats/node/storage.rb', line 32

def available
  @available ||= data[AVAILABLE_KEY]
end

#freeInteger

Returns The total number of bytes that are free on the node.

Returns:

  • (Integer)

    The total number of bytes that are free on the node.



26
27
28
# File 'lib/jay_api/elasticsearch/stats/node/storage.rb', line 26

def free
  @free ||= data[FREE_KEY]
end

#totalInteger

Returns The total size of the storage (in bytes).

Returns:

  • (Integer)

    The total size of the storage (in bytes)



20
21
22
# File 'lib/jay_api/elasticsearch/stats/node/storage.rb', line 20

def total
  @total ||= data[TOTAL_KEY]
end