• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

apache / iotdb / #9940

28 Aug 2023 02:34PM CUT coverage: 47.667% (-0.02%) from 47.686%
#9940

Pull #10978

travis_ci

web-flow
Merge 64f220724 into ebd2a6f63
Pull Request #10978: [To rel/1.2] Pipe: Increase the injection frequency of HeartBeatEvent to reduce the delay in log transferring (#10970)

30 of 30 new or added lines in 7 files covered. (100.0%)

79985 of 167800 relevant lines covered (47.67%)

0.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

52.0
/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/JMXService.java
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements.  See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership.  The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License.  You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied.  See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19
package org.apache.iotdb.commons.service;
20

21
import org.apache.iotdb.commons.conf.IoTDBConstant;
22

23
import org.slf4j.Logger;
24
import org.slf4j.LoggerFactory;
25

26
import javax.management.InstanceAlreadyExistsException;
27
import javax.management.InstanceNotFoundException;
28
import javax.management.MBeanRegistrationException;
29
import javax.management.MBeanServer;
30
import javax.management.MalformedObjectNameException;
31
import javax.management.NotCompliantMBeanException;
32
import javax.management.ObjectName;
33

34
import java.lang.management.ManagementFactory;
35

36
public class JMXService implements IService {
37

38
  private static final Logger logger = LoggerFactory.getLogger(JMXService.class);
1✔
39

40
  public JMXService() {
×
41
    // Empty constructor
42
  }
×
43

44
  /** function for registering MBean. */
45
  public static void registerMBean(Object mbean, String name) {
46
    try {
47
      MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
1✔
48
      ObjectName objectName = new ObjectName(name);
1✔
49
      if (!mbs.isRegistered(objectName)) {
1✔
50
        mbs.registerMBean(mbean, objectName);
1✔
51
      }
52
    } catch (MalformedObjectNameException
×
53
        | InstanceAlreadyExistsException
54
        | MBeanRegistrationException
55
        | NotCompliantMBeanException e) {
56
      logger.error("Failed to registerMBean {}", name, e);
×
57
    }
1✔
58
  }
1✔
59

60
  /** function for deregistering MBean. */
61
  public static void deregisterMBean(String name) {
62
    try {
63
      MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
1✔
64
      ObjectName objectName = new ObjectName(name);
1✔
65
      if (mbs.isRegistered(objectName)) {
1✔
66
        mbs.unregisterMBean(objectName);
1✔
67
      }
68
    } catch (MalformedObjectNameException
×
69
        | MBeanRegistrationException
70
        | InstanceNotFoundException e) {
71
      logger.error("Failed to unregisterMBean {}", name, e);
×
72
    }
1✔
73
  }
1✔
74

75
  @Override
76
  public ServiceType getID() {
77
    return ServiceType.JMX_SERVICE;
×
78
  }
79

80
  @Override
81
  public void start() {
82
    String jmxPort = System.getProperty(IoTDBConstant.IOTDB_JMX_PORT);
×
83
    if (jmxPort == null) {
×
84
      logger.debug("{} JMX port is undefined", this.getID().getName());
×
85
    }
86
  }
×
87

88
  @Override
89
  public void stop() {
90
    // do nothing.
91
  }
×
92
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc