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

apache / iotdb / #9905

23 Aug 2023 06:20AM UTC coverage: 47.785% (-0.1%) from 47.922%
#9905

push

travis_ci

web-flow
[To rel/1.2][Metric] Fix flush point statistics (#10934)

23 of 23 new or added lines in 1 file covered. (100.0%)

79851 of 167106 relevant lines covered (47.78%)

0.48 hits per line

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

90.0
/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/consensus/ConsensusGroupId.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

20
package org.apache.iotdb.commons.consensus;
21

22
import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId;
23
import org.apache.iotdb.common.rpc.thrift.TConsensusGroupType;
24

25
import java.util.Objects;
26

27
/** we abstract this class to hide word `ConsensusGroup` for IoTDB StorageEngine/SchemaEngine. */
28
public abstract class ConsensusGroupId {
1✔
29

30
  protected int id;
31

32
  /**
33
   * get specific id.
34
   *
35
   * @return id.
36
   */
37
  public int getId() {
38
    return id;
1✔
39
  }
40

41
  /**
42
   * get specific type.
43
   *
44
   * @return type.
45
   */
46
  public abstract TConsensusGroupType getType();
47

48
  public TConsensusGroupId convertToTConsensusGroupId() {
49
    return new TConsensusGroupId(getType(), getId());
1✔
50
  }
51

52
  @Override
53
  public int hashCode() {
54
    return Objects.hash(getType(), getId());
1✔
55
  }
56

57
  @Override
58
  public boolean equals(Object o) {
59
    if (this == o) {
1✔
60
      return true;
1✔
61
    }
62
    if (o == null || getClass() != o.getClass()) {
1✔
63
      return false;
×
64
    }
65
    ConsensusGroupId that = (ConsensusGroupId) o;
1✔
66
    return getId() == that.getId() && getType() == that.getType();
1✔
67
  }
68

69
  @Override
70
  public String toString() {
71
    return String.format("%s[%d]", getType(), getId());
1✔
72
  }
73

74
  public static class Factory {
75

76
    private Factory() {
77
      // empty constructor
78
    }
79

80
    public static ConsensusGroupId create(int type, int id) {
81
      ConsensusGroupId groupId;
82
      if (type == TConsensusGroupType.DataRegion.getValue()) {
1✔
83
        groupId = new DataRegionId(id);
1✔
84
      } else if (type == TConsensusGroupType.SchemaRegion.getValue()) {
1✔
85
        groupId = new SchemaRegionId(id);
1✔
86
      } else if (type == TConsensusGroupType.ConfigRegion.getValue()) {
1✔
87
        groupId = new ConfigRegionId(id);
1✔
88
      } else {
89
        throw new IllegalArgumentException(
×
90
            "Unrecognized TConsensusGroupType: " + type + " with id = " + id);
91
      }
92
      return groupId;
1✔
93
    }
94

95
    public static ConsensusGroupId createFromTConsensusGroupId(
96
        TConsensusGroupId tConsensusGroupId) {
97
      return create(tConsensusGroupId.getType().getValue(), tConsensusGroupId.getId());
1✔
98
    }
99
  }
100
}
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