Giter VIP home page Giter VIP logo

Comments (5)

enebo avatar enebo commented on August 24, 2024

@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.

ksekhar avatar ksekhar commented on August 24, 2024

@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.

enebo avatar enebo commented on August 24, 2024

I don't know if this will help there are really only two changes I made:

  1. list = []
  2. @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.

enebo avatar enebo commented on August 24, 2024

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.

ksekhar avatar ksekhar commented on August 24, 2024

I tried the first and got undefined method setAttributes
Thank You for trying to solve my problem.

from jmx.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.