Class: Backstage::Cache

Inherits:
Object show all
Includes:
HasMBean, Resource
Defined in:
lib/caches/models/cache.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resource

#association_chain, #available_actions, included, #resource, #to_hash

Methods included from HasMBean

#<=>, #full_name, included, #initialize, #mbean_info, #method_missing

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Backstage::HasMBean

Class Method Details

.filterObject



22
23
24
# File 'lib/caches/models/cache.rb', line 22

def self.filter
  "jboss.infinispan:component=CacheManager,*"
end

.to_hash_attributesObject



26
27
28
# File 'lib/caches/models/cache.rb', line 26

def self.to_hash_attributes
  super + [:name, :cache_manager_status, :created_cache_count, :defined_cache_count, :running_cache_count, :version, :defined_cache_names]
end

Instance Method Details

#cache_namesObject

reformat the defined_cache_names string



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/caches/models/cache.rb', line 38

def cache_names
  names = {}
  dcns = self.defined_cache_names.sub('[', '')

  list = dcns.split(')')
    list.each do |cache_name|
      unless cache_name == "]"
        if cache_name.include? "(not created"
          names.store(cache_name.sub("(not created", ""), "not created")
        else
          names.store(cache_name.sub("(created", ""), "created")
        end
     end
  end

  names
end

#nameObject Also known as: cache_manager_name



30
31
32
# File 'lib/caches/models/cache.rb', line 30

def name
  $1 if full_name =~ /name="(.*?)"(,|$)/
end

#rpc_cachesObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/caches/models/cache.rb', line 56

def rpc_caches
  rpc = JMX::MBeanServer.new
  manager = self.name
  rpc_caches = []   # JMX::MBeans::Org::Infinispan::Remoting::Rpc::RpcManagerImpl

  # find the name of the cluster connection control 
  filter_str = 'org.infinispan:component=RpcManager,manager="' + manager + '",*'

  rpc.query_names( filter_str ).collect do |name|
    data = name.to_s.split(',')
    cache_name = data[1].sub('name=', '')
 
    rpc_caches << [ cache_name, JMX::MBeanServer.new[ name ] ]
  end
 
  rpc_caches 
end