Module: Replication

Included in:
Bdb::Environment
Defined in:
lib/bdb/replication.rb

Constant Summary collapse

DEFAULT_PORT =
3463
NUM_THREADS =
1
ACK_POLICY =
{
  :all       => Bdb::DB_REPMGR_ACKS_ALL,
  :all_peers => Bdb::DB_REPMGR_ACKS_ALL_PEERS,
  :none      => Bdb::DB_REPMGR_ACKS_NONE,
  :one       => Bdb::DB_REPMGR_ACKS_ONE,
  :one_peer  => Bdb::DB_REPMGR_ACKS_ONE_PEER,
  :quorom    => Bdb::DB_REPMGR_ACKS_QUORUM,
}

Instance Method Summary collapse

Instance Method Details

#master?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/bdb/replication.rb', line 19

def master?
  not replicate? or replicate[:master]
end

#replicate(opts = nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bdb/replication.rb', line 23

def replicate(opts = nil)
  return @replicate if opts.nil?

  master  = normalize_host(opts.delete(:from))
  clients = [*opts.delete(:to)].compact.collect {|h| normalize_host(h)}
  local   = normalize_host(opts.delete(:host) || ENV['BDB_REPLICATION_HOST'], opts.delete(:port))
  remote  = clients + [master] - [local]

  opts[:master] = (local == master)
  opts[:local]  = local
  opts[:remote] = remote
  opts[:num_threads] ||= NUM_THREADS
  @replicate = opts

  env
end

#replicate?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/bdb/replication.rb', line 15

def replicate?
  not @replicate.nil?
end