Class: LS4::MDSCacheService

Inherits:
Service show all
Extended by:
Forwardable
Defined in:
lib/ls4/service/mds_cache.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

#initializeMDSCacheService

Returns a new instance of MDSCacheService.



64
65
66
67
# File 'lib/ls4/service/mds_cache.rb', line 64

def initialize
	@uri = ""
	@cache = NullMDSCache.new
end

Instance Method Details

#reopen(uri) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/ls4/service/mds_cache.rb', line 85

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

	cache = klass.new
	cache.open(expr)

	old_cache = @cache
	@cache = cache

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

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

#runObject



69
70
71
72
73
74
75
76
77
# File 'lib/ls4/service/mds_cache.rb', line 69

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

#shutdownObject



79
80
81
82
83
# File 'lib/ls4/service/mds_cache.rb', line 79

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