Comments (5)
@ksekhar I am sorry about the tardiness of this response. It got lost in a sea of tabs in my browser.
I think I need a bit more detail on your problem. I think you are interacting with an already written MBean and it only persists if attributes are set through setAttributes right? Does it persist if they are set through setAttribute?
The second part of what I think you are asking confuses me a little. The attributes seem to be using []= which does call setAttribute. I half wonder if perhaps you might have an operand and an attribute with the same name? Could their be an name collision?
from jmx.
@enebo Thanks for the reply. I was always resigned about replies from code owners. You proved me wrong.
I tried using setAttribute, but the results are the same. It would update in JVM but it won't in DB.
I am not overriding any operands in my code, unless jruby or rails is inserting one behind the scenes. And I don't see any name collision.
I even checked out Twiddle (https://community.jboss.org/wiki/Twiddle) source code and it does exactly what I do I call the setAttributes method on the RMIServerConnection object that JMXConnectionFactory returns.
heres my code if that helps (Pardon if its horrible)
#@conn ||= JMX.connect :host => @hostname,:port => @port, :user => FreBean.user_pass1[0], :password => FreBean.user_pass1[1]
def update(name, data)
attributes = @conn[name].attributes #returns MBeanInfo object (I modified the method in gem to return type along with name)
o = ObjectName.new(name)
list = AttributeList.new
data.each do |mbean_name,att_val_hash|
att_val_hash.each do |att, val|
val = javax.management.ObjectName.new(val) if attributes.find{|a| a.first.downcase == att.camelcase.downcase}[1] == "javax.management.ObjectName" unless val.blank?
cast_val = val.to_java(attributes.find{|a| a.first.downcase == att.camelcase.downcase}[1])
a = Attribute.new(attributes.find{|a| a.first.downcase == att.camelcase.downcase}.first,cast_val)
list.add(a)
end
end
@conn.server.setAttributes(o,list)
return @conn[name]
end
from jmx.
I don't know if this will help there are really only two changes I made:
- list = []
- @conn[name].setAttributes(list)
#@conn ||= JMX.connect :host => @hostname,:port => @port, :user => FreBean.user_pass1[0], :password => FreBean.user_pass1[1]
def update(name, data)
attributes = @conn[name].attributes #returns MBeanInfo object (I modified the method in gem to return type along with name)
list = []
data.each do |mbean_name,att_val_hash|
att_val_hash.each do |att, val|
n, type = attributes.find{|a| a.first.downcase == att.camelcase.downcase }
val = javax.management.ObjectName.new(val) if type == "javax.management.ObjectName" unless val.blank?
list.add(Attribute.new(n, val.to_java(type)))
end
end
@conn[name].setAttributes(list)
end
If this does not work I am wondering if there is something Open Sourced as a MBean which I can reproduce this issue. Looking informally at the library I feel like it should really be calling setAttributes.
from jmx.
It is possible my simplification of your find is wrong too but it was difficult to tell. Still I think you should be able to to something similar.
from jmx.
I tried the first and got undefined method setAttributes
Thank You for trying to solve my problem.
from jmx.
Related Issues (9)
- JMX::MBeans.parent_for unreliable in Jruby 9000 HOT 5
- Gem doesn't allow specifying a service url
- MBean attributes shouldn't be tied to MBean instance variables. HOT 4
- MBeans created by another MBean don't have attributes/operations show up HOT 2
- Extended MBeans don't have parents operations/attributes. HOT 2
- JMX::MBeanProxy#method_missing is broken HOT 3
- MBeanServer#[] crashes in const_defined? when MBean class name contains $ HOT 5
- The url in the gemspec points to the old repo location (enebo/jmx) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jmx.