Removed some unused methods.

This commit is contained in:
Kyle Banker 2009-11-24 14:04:39 -05:00
parent 154abda235
commit 3bdd3fdd53
3 changed files with 3 additions and 30 deletions

View File

@ -288,6 +288,7 @@ module Mongo
socket = TCPSocket.new(host, port)
socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
# If we're connected to master, set the @host and @port
result = self['admin'].command({:ismaster => 1}, false, false, socket)
if result['ok'] == 1 && ((is_master = result['ismaster'] == 1) || @slave_ok)
@host, @port = host, port
@ -308,27 +309,6 @@ module Mongo
raise ConnectionFailure, "failed to connect to any given host:port" unless socket
end
# NOTE: might not need this.
# Are we connected to the master node?
def master?
doc = self['admin'].command(:ismaster => 1)
doc['ok'] == 1 && doc['ismaster'] == 1
end
# NOTE: might not need this.
# Returns a string of the form "host:port" that points to the master
# database. Works even if this _is_ the master database.
def master
doc = self['admin'].command(:ismaster => 1)
if doc['ok'] == 1 && doc['ismaster'] == 1
"#@host:#@port"
elsif doc['remote']
doc['remote']
else
raise "Error retrieving master database: #{doc.inspect}"
end
end
# Are we connected to MongoDB? This is determined by checking whether
# @host and @port have values, since they're set to nil on calls to #close.
def connected?

View File

@ -475,14 +475,6 @@ class DBAPITest < Test::Unit::TestCase
end
end
def test_ismaster
assert @@conn.master?
end
def test_master
assert_equal "#{@@conn.host}:#{@@conn.port}", @@conn.master
end
def test_where
@@coll.insert('a' => 2)
@@coll.insert('a' => 3)

View File

@ -10,7 +10,8 @@ class SlaveConnectionTest < Test::Unit::TestCase
@@host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
@@port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
conn = Connection.new(@@host, @@port, :slave_ok => true)
!conn.master?
cmd = conn['admin'].command(:ismaster => 1)
cmd['ok'] == 1 && cmd['ismaster'] != 1
end
if self.connect_to_slave