Permalink
Browse files

Remove old files

  • Loading branch information...
1 parent ab2dbee commit e73780cb2fb90bb2323d37f4aacd9ee5c857d987 @bernerdschaefer committed Apr 16, 2012
Showing with 0 additions and 354 deletions.
  1. +0 −11 bench_time.rb
  2. +0 −104 connection_manager.rb
  3. +0 −49 multiplexer.rb
  4. +0 −47 node.rb
  5. +0 −124 session.rb
  6. +0 −19 statuses.txt
View
@@ -1,11 +0,0 @@
-require "benchmark"
-$:.unshift "./lib"
-require "moped/bson"
-
-Benchmark.bmbm do |x|
- x.report "OBjectId.new" do
- 100_000.times do
- Moped::BSON::ObjectId.new
- end
- end
-end
View
@@ -1,104 +0,0 @@
-require "socket"
-
-class ConnectionManager
-
- def initialize(servers)
- @timeout = 1
- @servers = servers
- @clients = []
- end
-
- def next_client
- connections = (@servers + @clients).reject do |conn|
- conn.to_io.closed?
- end
-
- readable, _, errors = IO.select(connections, nil, @clients, @timeout)
- return unless readable || errors
-
- errors.each do |client|
- client.close
- @clients.delete client
- end
-
- clients, servers = readable.partition { |s| s.class == TCPSocket }
-
- servers.each do |server|
- @clients << server.accept
- end
-
- closed, open = clients.partition &:eof?
- closed.each { |client| @clients.delete client }
-
- if client = open.shift
- server = lookup_server(client)
-
- return server, client
- else
- nil
- end
- end
-
- def lookup_server(client)
- port = client.addr(false)[1]
-
- @servers.find do |server|
- server.to_io.addr[1] == port
- end
- end
-
-end
-
-servers = [TCPServer.new(0), TCPServer.new(0), TCPServer.new(0)]
-manager = ConnectionManager.new(servers)
-
-loop do
- server, client = manager.next_client
-
- if server
- puts "Message for #{server.addr[1]}: #{client.gets}"
- else
- Thread.pass
- end
-end
-
-class Node
- def initialize(set)
- end
-
- def start
- @server = TCPServer.new 0
- end
-
- def stop
- @server.close
- @server = nil
- end
-
- def proxy(client, mongo)
- incoming_message = client.read(16)
- length, op_code = incoming_message.unpack("l<x8l<")
- incoming_message << client.read(length - 16)
-
- if op_code == OP_QUERY && ismaster_command?(incoming_message)
- # Intercept the ismaster command and send our own reply.
- client.write status_reply
- else
- # This is a normal command, so proxy it to the real mongo instance.
- mongo.write incoming_message
-
- if op_code == OP_QUERY || op_code == OP_GETMORE
- outgoing_message = mongo.read(4)
- length, = outgoing_message.unpack('l<')
- outgoing_message << mongo.read(length - 4)
-
- client.write outgoing_message
- end
- end
- end
-
- def to_io
- @server
- end
-end
-
View
@@ -1,49 +0,0 @@
-require 'socket'
-mongo = TCPSocket.new "127.0.0.1", 27017
-
-@timeout = 1
-@servers = [TCPServer.new(0), TCPServer.new(0), TCPServer.new(0)]
-@connections = []
-
-def get_socket
- ios = IO.select( @servers + @connections, nil, @connections, 1 )
- return unless ios
-
- # Delete connections with errors
- ios[2].each do |socket|
- socket.close
- @connections.delete socket
- end
-
- ready_servers, ready_clients = ios[0].partition { |sock| sock.is_a?(TCPServer) }
-
- ready_servers.each do |server|
- client = server.accept
- @connections << client
- # serve client immediately?
- end
-
- ready_clients.each do |client|
- if client.eof?
- @connections.delete(client)
- else
- server_port = client.addr(false)[1]
- return client
- end
- end
-
- nil
-end
-
-puts @servers.map { |s| s.addr[1] }
-
-Thread.new do
- loop do
- if socket = get_socket
- message = socket.gets
- socket.puts "hello"
- else
- Thread.pass
- end
- end
-end.join
View
47 node.rb
@@ -1,47 +0,0 @@
-
-## speculative
-
-class Collection
- def insert(documents)
- # ...
- session.with_node_for(:write) do |node|
- node.insert database.name, name, documents
- end
- end
-end
-
-class Database
- def command(command)
- session.with_node(:write) do |node|
- node.command name, command
- end
- end
-end
-
-class Cursor
- def load_initial_result_set
- session.with_node(:read) do |node|
- node.query @query_op
- @node = node
- end
- end
-
- def get_more
- @node.get_more @get_more_op
- end
-end
-
-class SessionNodeProxy
- def initialize(session, node)
-
- end
-
- def insert(database, collection, documents, options = {})
- operation = Protocol::SafeOperation.wrap(
- Protocol::Insert.new(database, collection, documents, options),
- session.safety
- )
-
- node.
- end
-end
View
@@ -1,124 +0,0 @@
-class Database
-
- # @consistency strong
- def drop
- session.with(consistency: :strong) do |session|
- session.context.command name, dropDatabase: 1
- end
- end
-
- # @consistency nil
- def command(cmd) end
-
-end
-
-class Collection
-
- # @consistency strong
- def drop() end
-
- # @consistency strong
- def insert() end
-
-end
-
-class Query
-
- # @consistency nil
- def one
- reply = session.query \
- database.name, collection.name, selector, options.merge(limit: -1)
- reply.documents[0]
- end
-
- # @consistency nil
- def distinct() end
-
- # @consistency nil
- def count
- database.command(
- count: collection.name,
- query: selector
- )["n"]
- end
-
- # @consistency strong
- def update() end
-
- # @consistency strong
- def update_all() end
-
- # @consistency strong
- def upsert() end
-
- # @consistency strong
- def remove() end
-
- # @consistency strong
- def remove_all() end
-
-end
-
-class Cursor
-
- # @consistency nil
- def load
- consistency = session.consistency
- @options[:flags] |= :slave_ok if consistency == :eventual
-
- reply, @node = session.context.with_node do |node|
- [node.query(@database, @collection, @selector, @options), node]
- end
-
- @limit -= reply.count if limited?
- @cursor_id = reply.cursor_id
-
- reply.documents
- end
-
- def get_more
- @node.get_more @database, @collection, @cursor_id, @limit
- end
-
- def kill
- @node.kill_cursors [@cursor_id]
- end
-
-end
-
-class Node
-
- def initialize(host, port, options = {}) end
-
- def command(database, cmd)
- command = Protocol::Command.new(database, cmd)
-
- process(command) do |reply|
- p reply
- end
- end
-
- def get_more() end
- def insert() end
- def kill_cursors() end
- def query() end
- def remove() end
- def update() end
-
- # @api semipublic
- def down?() end
- def down_at() end
- def ensure_primary() end
- def needs_refresh?() end
- def primary?() end
- def refresh() end
- def secondary?() end
-
- private
-
- def connect() end
- def down!() end
- def ensure_connected() end
-
-
-end
View
@@ -1,19 +0,0 @@
-# started but not initiated
-
-{"ismaster"=>false, "secondary"=>false, "info"=>"can't get local.system.replset config from self or any seed (EMPTYCONFIG)", "isreplicaset"=>true, "maxBsonObjectSize"=>16777216, "ok"=>1.0}
-
-# up!
-
-{"setName"=>"test-set", "ismaster"=>true, "secondary"=>false, "hosts"=>["Bernerd-Schaefers-MacBook-Pro.local:31000", "Bernerd-Schaefers-MacBook-Pro.local:31002", "Bernerd-Schaefers-MacBook-Pro.local:31001"], "primary"=>"Bernerd-Schaefers-MacBook-Pro.local:31000", "me"=>"Bernerd-Schaefers-MacBook-Pro.local:31000", "maxBsonObjectSize"=>16777216, "ok"=>1.0}
-
-{"setName"=>"test-set", "ismaster"=>false, "secondary"=>false, "hosts"=>["Bernerd-Schaefers-MacBook-Pro.local:31001", "Bernerd-Schaefers-MacBook-Pro.local:31002", "Bernerd-Schaefers-MacBook-Pro.local:31000"], "primary"=>"Bernerd-Schaefers-MacBook-Pro.local:31000", "me"=>"Bernerd-Schaefers-MacBook-Pro.local:31001", "maxBsonObjectSize"=>16777216, "ok"=>1.0}
-
-{"setName"=>"test-set", "ismaster"=>false, "secondary"=>true, "hosts"=>["Bernerd-Schaefers-MacBook-Pro.local:31002", "Bernerd-Schaefers-MacBook-Pro.local:31001", "Bernerd-Schaefers-MacBook-Pro.local:31000"], "primary"=>"Bernerd-Schaefers-MacBook-Pro.local:31000", "me"=>"Bernerd-Schaefers-MacBook-Pro.local:31002", "maxBsonObjectSize"=>16777216, "ok"=>1.0}
-
-# while reconfiguring
-
-{"setName"=>"test-set", "ismaster"=>false, "secondary"=>true, "hosts"=>["Bernerd-Schaefers-MacBook-Pro.local:31000", "Bernerd-Schaefers-MacBook-Pro.local:31002", "Bernerd-Schaefers-MacBook-Pro.local:31001"], "me"=>"Bernerd-Schaefers-MacBook-Pro.local:31000", "maxBsonObjectSize"=>16777216, "ok"=>1.0}
-
-{"setName"=>"test-set", "ismaster"=>false, "secondary"=>true, "hosts"=>["Bernerd-Schaefers-MacBook-Pro.local:31001", "Bernerd-Schaefers-MacBook-Pro.local:31002", "Bernerd-Schaefers-MacBook-Pro.local:31000"], "primary"=>"Bernerd-Schaefers-MacBook-Pro.local:31000", "me"=>"Bernerd-Schaefers-MacBook-Pro.local:31001", "maxBsonObjectSize"=>16777216, "ok"=>1.0}
-
-{"setName"=>"test-set", "ismaster"=>false, "secondary"=>true, "hosts"=>["Bernerd-Schaefers-MacBook-Pro.local:31002", "Bernerd-Schaefers-MacBook-Pro.local:31001", "Bernerd-Schaefers-MacBook-Pro.local:31000"], "me"=>"Bernerd-Schaefers-MacBook-Pro.local:31002", "maxBsonObjectSize"=>16777216, "ok"=>1.0}

0 comments on commit e73780c

Please sign in to comment.