Class: LS4::MDSService

Inherits:
Service show all
Extended by:
Forwardable
Defined in:
lib/ls4/service/mds.rb

Instance Method Summary collapse

Methods inherited from Service

init

Methods included from EventBus::SingletonMixin

#ebus_bind!, #ebus_connect, extended

Methods included from EventBus::BusMixin

#ebus_all_slots, #ebus_disconnect!

Methods included from EventBus::DeclarerBase::Methods

#connect, #ebus_all_slots, #ebus_call_log, #ebus_call_slots, #ebus_signal_error, #ebus_signal_log, #ebus_signal_slots

Methods included from EventBus::DeclarerBase

#call_slot, #signal_slot

Constructor Details

#initializeMDSService

Returns a new instance of MDSService.



97
98
99
100
# File 'lib/ls4/service/mds.rb', line 97

def initialize
  @uri = ""
  @mds = NullMDS.new
end

Instance Method Details

#reopen(uri) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/ls4/service/mds.rb', line 118

def reopen(uri)
  klass, expr = MDSSelector.select_class(uri)

  mds = klass.new
  mds.open(expr)

  old_mds = @mds
  @mds = mds

  $log.info "using MDS: #{@mds}"

  begin
    old_mds.close
  rescue
    $log.error "MDS close error: #{$!}"
    $log.error_backtrace $!.backtrace
  end
end

#runObject



102
103
104
105
106
107
108
109
110
# File 'lib/ls4/service/mds.rb', line 102

def run
  SyncBus.register_callback(SYNC_MDS_URI,
            MDSConfigService.hash_uri(@uri)) do |obj|
    uri = obj
    reopen(uri)
    @uri = uri
    MDSConfigService.hash_uri(@uri)
  end
end

#shutdownObject



112
113
114
115
116
# File 'lib/ls4/service/mds.rb', line 112

def shutdown
  if @mds
    @mds.close rescue nil
  end
end