java类javax.management.relation.MBeanServerNotificationFilter的实例源码

JmxDumper.java 文件源码 项目:helix 阅读 25 收藏 0 点赞 0 评论 0
public JmxDumper(String jmxService, String domain, String beanClassName, String namePattern,
    int samplePeriod, List<String> fields, List<String> operations, String outputfile,
    int sampleCount) throws Exception {
  _jmxUrl = jmxService;
  _domain = domain;
  _beanClassName = beanClassName;
  _samplePeriod = samplePeriod;
  _outputFields.addAll(fields);
  _operations.addAll(operations);
  _outputFileName = outputfile;
  _namePattern = namePattern;
  _targetSamples = sampleCount;

  JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + _jmxUrl + "/jmxrmi");
  JMXConnector jmxc = JMXConnectorFactory.connect(url, null);

  _mbeanServer = jmxc.getMBeanServerConnection();
  MBeanServerNotificationFilter filter = new MBeanServerNotificationFilter();
  filter.enableAllObjectNames();
  _mbeanServer.addNotificationListener(MBeanServerDelegate.DELEGATE_NAME, this, filter, null);
  init();
  _timer = new Timer(true);
  _timer.scheduleAtFixedRate(new SampleTask(), _samplePeriod, _samplePeriod);
}
ClusterMBeanObserver.java 文件源码 项目:helix 阅读 22 收藏 0 点赞 0 评论 0
public ClusterMBeanObserver(String domain) throws InstanceNotFoundException, IOException,
    MalformedObjectNameException, NullPointerException {
  // Get a reference to the target MBeanServer
  _domain = domain;
  _server = ManagementFactory.getPlatformMBeanServer();
  MBeanServerNotificationFilter filter = new MBeanServerNotificationFilter();
  filter.enableAllObjectNames();
  _server.addNotificationListener(MBeanServerDelegate.DELEGATE_NAME, this, filter, null);
}
ClusterMBeanObserver.java 文件源码 项目:helix 阅读 21 收藏 0 点赞 0 评论 0
public void disconnect() {
  MBeanServerNotificationFilter filter = new MBeanServerNotificationFilter();
  try {
    _server.removeNotificationListener(MBeanServerDelegate.DELEGATE_NAME, this);
  } catch (Exception e) {
    _logger.error("", e);
  }
}
ReporterAgent.java 文件源码 项目:jmx-cloudwatch-reporter 阅读 25 收藏 0 点赞 0 评论 0
protected void addBeanNotificationListener() throws IOException {
    MBeanServerNotificationFilter filter = new MBeanServerNotificationFilter();
    filter.enableAllObjectNames();
    try {
        mBeanServer.addNotificationListener(MBeanServerDelegate.DELEGATE_NAME, this, filter, null);
    } catch (InstanceNotFoundException e) {
        throw new IOException(e);
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号