Uploaded image for project: 'Commons Pool'
  1. Commons Pool
  2. POOL-393

BaseGenericObjectPool.jmxRegister may cost too much time

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.2
    • 2.12.0
    • None

    Description

       

      When creating many pools, I find that it tasks too much time to register jmx.

      In the code,  the ObjectName's postfix always starts with 1, so many InstanceAlreadyExistsExceptions may be thrown before registered successfully.

      Maybe a random number is a better choice, or a atomic long.

      private ObjectName jmxRegister(BaseObjectPoolConfig config,
      String jmxNameBase, String jmxNamePrefix)

      Unknown macro: { ObjectName objectName = null; MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); int i = 1; boolean registered = false; String base = config.getJmxNameBase(); if (base == null) Unknown macro}

      while (!registered) {
      try

      Unknown macro: { ObjectName objName; // Skip the numeric suffix for the first pool in case there is // only one so the names are cleaner. if (i == 1) Unknown macro}

      else
      Unknown macro: { objName = new ObjectName(base + jmxNamePrefix + i); }
      mbs.registerMBean(this, objName);
      objectName = objName;
      registered = true;
      } catch (MalformedObjectNameException e)

      Unknown macro: { if (BaseObjectPoolConfig.DEFAULT_JMX_NAME_PREFIX.equals( jmxNamePrefix) && jmxNameBase.equals(base)) Unknown macro}

      else
      Unknown macro: { // Must be an invalid name. Use the defaults instead. jmxNamePrefix = BaseObjectPoolConfig.DEFAULT_JMX_NAME_PREFIX; base = jmxNameBase; }
      } catch (InstanceAlreadyExistsException e)
      Unknown macro: { // Increment the index and try again i++; }
      catch (MBeanRegistrationException e)
      Unknown macro: { // Shouldn't happen. Skip registration if it does. registered = true; }
      catch (NotCompliantMBeanException e)

      }
      return objectName;
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            shichaoyuan Shichao Yuan
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 2h 40m
                2h 40m