Method: Aerospike::AdminCommand#execute_command

Defined in:
lib/aerospike/command/admin_command.rb

#execute_command(cluster, policy) ⇒ Object

[View source]

338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/aerospike/command/admin_command.rb', line 338

def execute_command(cluster, policy)
  # TODO: Remove the workaround in the future
  sleep(0.010)

  write_size
  node = cluster.random_node

  timeout = 1
  timeout = policy.timeout if policy && policy.timeout > 0

  conn = node.get_connection(timeout)

  begin
    conn.write(@data_buffer, @data_offset)
    conn.read(@data_buffer, HEADER_SIZE)
    node.put_connection(conn)
  rescue => e
    conn.close if conn
    raise e
  end

  result = @data_buffer.read(RESULT_CODE)
  raise Exceptions::Aerospike.new(result) if result != 0

  Buffer.put(@data_buffer)
end