Class: Murmur::API::Meta
- Inherits:
-
Object
- Object
- Murmur::API::Meta
- Defined in:
- lib/murmur/ice_interface.rb
Instance Method Summary collapse
- #add_proxy_router(prx) ⇒ Object
- #destroy ⇒ Object
-
#initialize(options = {}) ⇒ Meta
constructor
A new instance of Meta.
- #meta ⇒ Object
- #new_server(options = {}) ⇒ Object
- #new_server_interface ⇒ Object
- #server(id) ⇒ Object
- #servers ⇒ Object
- #uncache_server(id) ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Meta
Returns a new instance of Meta.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/murmur/ice_interface.rb', line 9 def initialize( = {}) # Default options = {:host => '127.0.0.1', :port => 6502}.merge() if [:ice_secret] props = ::Ice::createProperties props.setProperty "Ice.ImplicitContext", "Shared" props.setProperty "Ice.Default.EncodingVersion", "1.0" ice_init_data = ::Ice::InitializationData.new ice_init_data.properties = props ice_context = ::Ice::initialize ice_init_data ice_context.getImplicitContext.put("secret", [:ice_secret]) else props = ::Ice::createProperties props.setProperty "Ice.Default.EncodingVersion", "1.0" ice_init_data = ::Ice::InitializationData.new ice_init_data.properties = props ice_context = ::Ice::initialize ice_init_data end if [:glacier_host] prx = ice_context.stringToProxy("Glacier2/router:tcp -h #{[:glacier_host]} -p #{[:glacier_port]}") @router = ::Glacier2::RouterPrx::uncheckedCast(prx).ice_router(nil) @session = @router.createSession([:glacier_user], [:glacier_pass]) end conn = "tcp -h #{[:host]} -p #{[:port]}" proxy = ice_context.stringToProxy("Meta:#{conn}") @meta = add_proxy_router(Murmur::MetaPrx::checkedCast(proxy)) raise "Invalid proxy" unless @meta @servers = {} end |
Instance Method Details
#add_proxy_router(prx) ⇒ Object
56 57 58 |
# File 'lib/murmur/ice_interface.rb', line 56 def add_proxy_router(prx) @router ? prx.ice_router(@router) : prx end |
#destroy ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/murmur/ice_interface.rb', line 47 def destroy begin @router.destroySession @session unless @router.nil? rescue ::Ice::ConnectionLostException end nil end |
#meta ⇒ Object
88 89 90 |
# File 'lib/murmur/ice_interface.rb', line 88 def @meta end |
#new_server(options = {}) ⇒ Object
79 80 81 |
# File 'lib/murmur/ice_interface.rb', line 79 def new_server( = {}) Server.new(self, @meta, ) end |
#new_server_interface ⇒ Object
75 76 77 |
# File 'lib/murmur/ice_interface.rb', line 75 def new_server_interface server = @meta.newServer end |
#server(id) ⇒ Object
60 61 62 |
# File 'lib/murmur/ice_interface.rb', line 60 def server(id) @servers[id] ||= Server.new(self, @meta, {:id => id}) end |
#servers ⇒ Object
68 69 70 71 72 73 |
# File 'lib/murmur/ice_interface.rb', line 68 def servers @meta.send(:getAllServers).collect do |server| server = add_proxy_router server @servers[server.id] ||= Server.new(self, @meta, {:interface => server}) end end |
#uncache_server(id) ⇒ Object
64 65 66 |
# File 'lib/murmur/ice_interface.rb', line 64 def uncache_server(id) @servers[id] = nil end |
#validate ⇒ Object
83 84 85 86 |
# File 'lib/murmur/ice_interface.rb', line 83 def validate @meta.getVersion true end |