Exemplo n.º 1
0
        /// <summary>
        /// Register the MBean using our standard MBeanName format
        /// "hadoop:service=<serviceName>,name=<nameName>"
        /// Where the <serviceName> and <nameName> are the supplied parameters
        /// </summary>
        /// <param name="serviceName"/>
        /// <param name="nameName"/>
        /// <param name="theMbean">- the MBean to register</param>
        /// <returns>the named used to register the MBean</returns>
        public static ObjectName Register(string serviceName, string nameName, object theMbean
                                          )
        {
            MBeanServer mbs  = ManagementFactory.GetPlatformMBeanServer();
            ObjectName  name = GetMBeanName(serviceName, nameName);

            try
            {
                mbs.RegisterMBean(theMbean, name);
                Log.Debug("Registered " + name);
                return(name);
            }
            catch (InstanceAlreadyExistsException iaee)
            {
                if (Log.IsTraceEnabled())
                {
                    Log.Trace("Failed to register MBean \"" + name + "\"", iaee);
                }
                else
                {
                    Log.Warn("Failed to register MBean \"" + name + "\": Instance already exists.");
                }
            }
            catch (Exception e)
            {
                Log.Warn("Failed to register MBean \"" + name + "\"", e);
            }
            return(null);
        }
Exemplo n.º 2
0
 public void RegisterMBeanPermissionTest()
 {
     DoPermissionTest(
         null,
         delegate()
     {
         IMBeanServer server = new MBeanServer();
         server.RegisterMBean(new Dummy(), new ObjectName("dummy:"));
     }, null, null, MBeanPermissionAction.RegisterMBean, MBeanPermissionAction.UnregisterMBean);
 }
Exemplo n.º 3
0
        public void SetAttributePermissionTest()
        {
            IMBeanServer server = null;

            DoPermissionTest(
                delegate()
            {
                server = new MBeanServer();
                server.RegisterMBean(new Dummy(), new ObjectName("dummy:"));
            },
                delegate()
            {
                server.SetAttribute(new ObjectName("dummy:"), "IntValue", 5);
            }, "IntValue", "DoSomething", MBeanPermissionAction.SetAttribute, MBeanPermissionAction.GetAttribute);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Register the MBean using our standard MBeanName format
        /// "hadoop:service=<serviceName>,name=<nameName>"
        /// Where the <serviceName> and <nameName> are the supplied parameters
        /// </summary>
        /// <param name="serviceName"/>
        /// <param name="nameName"/>
        /// <param name="theMbean">- the MBean to register</param>
        /// <returns>the named used to register the MBean</returns>
        public static ObjectName RegisterMBean(string serviceName, string nameName, object
                                               theMbean)
        {
            MBeanServer mbs  = ManagementFactory.GetPlatformMBeanServer();
            ObjectName  name = GetMBeanName(serviceName, nameName);

            try
            {
                mbs.RegisterMBean(theMbean, name);
                return(name);
            }
            catch (InstanceAlreadyExistsException)
            {
            }
            catch (Exception e)
            {
                // Ignore if instance already exists
                Runtime.PrintStackTrace(e);
            }
            return(null);
        }
Exemplo n.º 5
0
        public void RegisterMBeanSuccessTest()
        {
            IMBeanServer server = new MBeanServer();

            server.RegisterMBean(new Trusted(), new ObjectName("trusted:"));
        }
Exemplo n.º 6
0
        public void RegisterMBeanFailureTest()
        {
            IMBeanServer server = new MBeanServer();

            server.RegisterMBean(new Untrusted(), new ObjectName("trusted:"));
        }